|
YARP
Yet Another Robot Platform
|
|
Go to the documentation of this file.
24 #define SAMPLING_RATE 44100
45 if( config.
check(
"period"))
49 yCInfo(FAKESPEAKER) <<
"Using chosen period of " << period <<
" s";
57 m_cfg_numSamples = config.
check(
"samples",
Value(
SAMPLING_RATE),
"Number of samples per network packet.").asInt32();
58 m_cfg_numChannels = config.
check(
"channels",
Value(
HW_CHANNELS),
"Number of audio channels.").asInt32();
60 m_cfg_bytesPerSample = config.
check(
"channels",
Value(2),
"Bytes per sample.").asInt8();
62 AudioBufferSize buffer_size(m_cfg_numSamples, m_cfg_numChannels, m_cfg_bytesPerSample);
75 delete m_outputBuffer;
82 bool fakeSpeaker::threadInit()
97 void fakeSpeaker::run()
109 size_t buffer_size = siz_sam * siz_chn;
110 for (
size_t i = 0; i<buffer_size; i++)
115 yCDebug(FAKESPEAKER) <<
"Sound Playback complete";
116 yCDebug(FAKESPEAKER) <<
"Played " << siz_sam <<
" samples, " << siz_chn <<
" channels, " << siz_byt <<
" bytes";
119 #ifdef ADVANCED_DEBUG
120 yCDebug(FAKESPEAKER) <<
"b_pnt" << m_bpnt <<
"/" << fsize_in_bytes <<
" bytes";
133 size = this->m_outputBuffer->
size();
140 m_outputBuffer->
clear();
146 if (m_renderSoundImmediate) m_outputBuffer->
clear();
152 for (
size_t i = 0; i<num_samples; i++)
153 for (
size_t j = 0; j<num_channels; j++)
154 m_outputBuffer->
write(sound.
get(i, j));
A base class for nested structures that can be searched.
size_t getSamples() const
Get the number of samples contained in the sound.
bool close() override
Close the DeviceDriver.
#define YARP_LOG_COMPONENT(name,...)
size_t getChannels() const
Get the number of channels of the sound.
An interface for the device drivers.
bool start()
Call this to start the thread.
bool open(yarp::os::Searchable &config) override
Open the DeviceDriver.
virtual bool check(const std::string &key) const =0
Check if there exists a property of the given name.
bool setPeriod(double period)
Set the (new) period of the thread.
virtual Value & find(const std::string &key) const =0
Gets a value corresponding to a given keyword.
audio_sample get(size_t sample, size_t channel=0) const
virtual bool resetPlaybackAudioBuffer() override
virtual bool getPlaybackAudioBufferCurrentSize(yarp::dev::AudioBufferSize &size) override
virtual bool renderSound(const yarp::sig::Sound &sound) override
Render a sound using a device (i.e.
An abstraction for a periodic thread.
virtual bool getPlaybackAudioBufferMaxSize(yarp::dev::AudioBufferSize &size) override
unsigned short int audio_sample_16t
#define yCInfo(component,...)
An interface to the operating system, including Port based communication.
#define yCDebug(component,...)
Class for storing sounds.
yarp::dev::CircularAudioBuffer< unsigned short int > CircularAudioBuffer_16t
std::vector< std::reference_wrapper< audio_sample > > getInterleavedAudioRawData() const
Returns a serialized version of the sound, in interleaved format, e.g.
void stop()
Call this to stop the thread, this call blocks until the thread is terminated (and releaseThread() ca...
virtual bool stopPlayback() override
Stop the playback.
unsigned short int audio_sample_16t
A single value (typically within a Bottle).
yarp::dev::AudioBufferSize getMaxSize()
virtual yarp::conf::float64_t asFloat64() const
Get 64-bit floating point value.
virtual bool startPlayback() override
Start the playback.