43 yCInfo(AUDIOFROMFILE) <<
"Not yet implemented";
49 if (config.
check(
"help"))
51 yCInfo(AUDIOFROMFILE,
"Some examples:");
52 yCInfo(AUDIOFROMFILE,
"yarpdev --device audioFromFileDevice --help");
53 yCInfo(AUDIOFROMFILE,
"yarpdev --device AudioRecorderWrapper --subdevice audioFromFileDevice --start");
54 yCInfo(AUDIOFROMFILE,
"yarpdev --device AudioRecorderWrapper --subdevice audioFromFileDevice --start --file_name myaudio.wav");
59 if (!b) {
return false; }
62 if(config.
check(
"period"))
66 yCInfo(AUDIOFROMFILE) <<
"Using chosen period of " << period <<
" s";
74 if (config.
check(
"driver_frame_size"))
76 m_samples_to_be_copied = config.
find(
"driver_frame_size").
asFloat64();
78 yCDebug(AUDIOFROMFILE) << m_samples_to_be_copied <<
" will be processed every iteration";
81 if (config.
check(
"file_name"))
84 yCInfo(AUDIOFROMFILE) <<
"Audio will loaded from file:" << m_audio_filename;
88 yCInfo(AUDIOFROMFILE) <<
"No `file_name` option specified. Audio will be loaded from default file:" << m_audio_filename;
95 yCError(AUDIOFROMFILE) <<
"Unable to open file" << m_audio_filename.c_str();
99 if (m_audioFile.
getChannels() != this->m_audiorecorder_cfg.numChannels)
101 yCInfo(AUDIOFROMFILE) <<
"Number of channels mismatch!";
111 m_fsize_in_samples = m_audioFile.
getSamples();
125 bool audioFromFileDevice::threadInit()
131 void audioFromFileDevice::run()
145 for (
size_t i = 0; i < m_samples_to_be_copied; i++)
147 if (m_bpnt >= m_fsize_in_samples)
151 for (
size_t c=0; c< chan_num; c++)
160 yCDebug(AUDIOFROMFILE) <<
"b_pnt" << m_bpnt <<
"/" << m_fsize_in_samples <<
" samples";
constexpr double c_DEFAULT_PERIOD
unsigned short int audio_sample_16t
bool close() override
Close the DeviceDriver.
~audioFromFileDevice() override
bool open(yarp::os::Searchable &config) override
Open the DeviceDriver.
bool setHWGain(double gain) override
Sets the hardware gain of the grabbing device (if supported by the hardware)
yarp::dev::CircularAudioBuffer_16t * m_inputBuffer
bool configureRecorderAudioDevice(yarp::os::Searchable &config, std::string device_name)
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.
virtual Bottle & findGroup(const std::string &key) const =0
Gets a list corresponding to a given keyword.
virtual yarp::conf::float64_t asFloat64() const
Get 64-bit floating point value.
virtual std::string asString() const
Get string value.
size_t getBytesPerSample() const
Get the number of bytes per sample.
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.
size_t getSamples() const
Get the number of samples contained in the sound.
#define yCInfo(component,...)
#define yCError(component,...)
#define yCDebug(component,...)
#define YARP_LOG_COMPONENT(name,...)
An interface for the device drivers.
An interface to the operating system, including Port based communication.
bool read(ImageOf< PixelRgb > &dest, const std::string &src, image_fileformat format=FORMAT_ANY)