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));
virtual bool getPlaybackAudioBufferMaxSize(yarp::dev::AudioBufferSize &size) override
virtual bool stopPlayback() override
Stop the playback.
virtual bool renderSound(const yarp::sig::Sound &sound) override
Render a sound using a device (i.e.
bool close() override
Close the DeviceDriver.
virtual bool resetPlaybackAudioBuffer() override
virtual bool startPlayback() override
Start the playback.
virtual bool getPlaybackAudioBufferCurrentSize(yarp::dev::AudioBufferSize &size) override
bool open(yarp::os::Searchable &config) override
Open the DeviceDriver.
yarp::dev::AudioBufferSize getMaxSize()
An abstraction for a periodic thread.
bool setPeriod(double period)
Set the (new) period of the thread.
bool start()
Call this to start the thread.
void stop()
Call this to stop the thread, this call blocks until the thread is terminated (and releaseThread() ca...
A base class for nested structures that can be searched.
virtual Value & find(const std::string &key) const =0
Gets a value corresponding to a given keyword.
virtual bool check(const std::string &key) const =0
Check if there exists a property of the given name.
A single value (typically within a Bottle).
virtual yarp::conf::float64_t asFloat64() const
Get 64-bit floating point value.
Class for storing sounds.
std::vector< std::reference_wrapper< audio_sample > > getInterleavedAudioRawData() const
Returns a serialized version of the sound, in interleaved format, e.g.
size_t getChannels() const
Get the number of channels of the sound.
audio_sample get(size_t sample, size_t channel=0) const
size_t getSamples() const
Get the number of samples contained in the sound.
unsigned short int audio_sample_16t
unsigned short int audio_sample_16t
#define yCInfo(component,...)
#define yCDebug(component,...)
#define YARP_LOG_COMPONENT(name,...)
An interface for the device drivers.
yarp::dev::CircularAudioBuffer< unsigned short int > CircularAudioBuffer_16t
An interface to the operating system, including Port based communication.