6#define _USE_MATH_DEFINES
23#define DEBUG_TIME_SPENT 0
26#define DEFAULT_SAMPLE_RATE (44100)
27#define DEFAULT_NUM_CHANNELS (2)
28#define DEFAULT_SAMPLE_SIZE (2)
34 yCError(
AUDIOPLAYER_BASE) <<
"getPlaybackAudioBufferCurrentSize() called, but no audio buffer is allocated yet";
61 std::lock_guard<std::recursive_mutex> lock(
m_mutex);
72 std::lock_guard<std::recursive_mutex> lock(
m_mutex);
82 std::lock_guard<std::recursive_mutex> lock(
m_mutex);
103 std::lock_guard<std::recursive_mutex> lock(
m_mutex);
114 for (
size_t i = 0; i < num_samples; i++) {
115 for (
size_t j = 0; j < num_channels; j++) {
131 for (
size_t i = 0; i < num_samples; i++) {
132 for (
size_t j = 0; j < num_channels; j++) {
143 std::lock_guard<std::recursive_mutex> lock(
m_mutex);
166 chans != this->m_audioplayer_cfg.numChannels)
174 chans <<
"channels, " << freq <<
" Hz";
208 m_audioplayer_cfg.
numSamples = config.
check(
"samples",
Value(0),
"number of samples per network packet (0=automatic). For chunks of 1 second of recording set samples=rate. Channels number is handled internally.").asInt32();
223 if (config.
check(
"render_mode_append"))
227 if (config.
check(
"render_mode_immediate"))
259 yCError(
AUDIOPLAYER_BASE) <<
"waitUntilPlaybackStreamIsComplete() called, but no audio buffer is allocated yet";
const yarp::os::LogComponent & AUDIOPLAYER_BASE()
#define DEFAULT_NUM_CHANNELS
#define DEFAULT_SAMPLE_RATE
constexpr double c_sleep_time
virtual bool immediateSound(const yarp::sig::Sound &sound)
virtual bool isPlaying(bool &playback_enabled) override
Check if the playback has been enabled (e.g.
virtual bool configureDeviceAndStart()=0
bool m_enable_buffer_autoclear
virtual bool renderSound(const yarp::sig::Sound &sound) override
Render a sound using a device (i.e.
std::recursive_mutex m_mutex
virtual void waitUntilPlaybackStreamIsComplete()
virtual bool resetPlaybackAudioBuffer() override
virtual bool getPlaybackAudioBufferMaxSize(yarp::dev::AudioBufferSize &size) override
virtual ~AudioPlayerDeviceBase()
virtual bool setSWGain(double gain) override
Sets a software gain for the played audio.
virtual bool appendSound(const yarp::sig::Sound &sound)
enum yarp::dev::AudioPlayerDeviceBase::@87 m_renderMode
yarp::dev::CircularAudioBuffer_16t * m_outputBuffer
virtual bool startPlayback() override
Start the playback.
virtual bool stopPlayback() override
Stop the playback.
bool configurePlayerAudioDevice(yarp::os::Searchable &config, std::string device_name)
virtual bool interruptDeviceAndClose()=0
AudioDeviceDriverSettings m_audioplayer_cfg
yarp::dev::AudioBufferSize getMaxSize()
A base class for nested structures that can be searched.
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).
Class for storing sounds See Audio in YARP for additional documentation on YARP audio.
size_t getChannels() const
Get the number of channels of the sound.
void amplify(double gain)
amplify a sound
int getFrequency() const
Get the frequency of the sound (i.e.
audio_sample get(size_t sample, size_t channel=0) const
size_t getSamples() const
Get the number of samples contained in the sound.
#define yCInfo(component,...)
#define yCError(component,...)
#define YARP_LOG_COMPONENT(name,...)
For streams capable of holding different kinds of content, check what they actually have.
yarp::dev::CircularAudioBuffer< unsigned short int > CircularAudioBuffer_16t
void delay(double seconds)
Wait for a certain number of seconds.
An interface to the operating system, including Port based communication.