Skip to content

Commit

Permalink
Base parameters have been grouped in [AUDIO_BASE] section and are now…
Browse files Browse the repository at this point in the history
… parsed by AudioPlayerDeviceBase, AudioRecorderDeviceBase classes
  • Loading branch information
randaz81 committed Mar 9, 2021
1 parent 999dfcd commit a72bc5a
Show file tree
Hide file tree
Showing 13 changed files with 43 additions and 33 deletions.
2 changes: 1 addition & 1 deletion src/devices/audioFromFileDevice/audioFromFileDevice.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ bool audioFromFileDevice::open(yarp::os::Searchable &config)
return false;
}

bool b = configureRecorderAudioDevice(config, "audioFromFileDevice");
bool b = configureRecorderAudioDevice(config.findGroup("AUDIO_BASE"), "audioFromFileDevice");
if (!b) { return false; }

//sets the thread period
Expand Down
2 changes: 2 additions & 0 deletions src/devices/audioFromFileDevice/audioFromFileDevice.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,12 @@
*
* \brief `audioFromFileDevice` : This device driver, wrapped by default by AudioRecorderWrapper,
* is used to read data from a file and stream it to the network.
* This device driver derives from AudioRecorderDeviceBase base class. Please check its documentation for additional details.
*
* Parameters required by this device are:
* | Parameter name | SubParameter | Type | Units | Default Value | Required | Description | Notes |
* |:-----------------:|:--------------:|:-------:|:--------------:|:------------------------:|:--------------------------: |:-----------------------------------------------------------------:|:-----:|
* | AUDIO_BASE | *** | | - | - | No | For the documentation of AUDIO_BASE group, please refer to the documentation of the base class AudioRecorderDeviceBase | |
* | file_name | - | string | - | audio.wav | No | The name of the file opened by the module | Only .wav files supported |
* | period | - | double | s | 0.010 | No | the period of thread which processes the file | On each iteration xxx samples are processed |
* | driver_frame_size | - | int | samples | 512 | No | the number of samples to process on each iteration of the thread | - |
Expand Down
3 changes: 3 additions & 0 deletions src/devices/audioToFileDevice/audioToFileDevice.h
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,12 @@
* if save_mode = "rename_file", the output file is written every time the stop() method is called or when the module terminates.
* The file name is modified, using an incremental counter appended at the end of the file name.
*
* This device driver derives from AudioPlayerDeviceBase base class. Please check its documentation for additional details.
*
* Parameters required by this device are:
* | Parameter name | SubParameter | Type | Units | Default Value | Required | Description | Notes |
* |:--------------:|:--------------:|:-------:|:--------------:|:------------------------:|:--------------------------: |:-----------------------------------------------------------------:|:-----:|
* | AUDIO_BASE | *** | | - | - | No | For the documentation of AUDIO_BASE group, please refer to the documentation of the base class AudioPlayerDeviceBase | |
* | file_name | - | string | - | audio_out.wav | No | The name of the file written by the module | Only .wav files supported |
* | save_mode | - | string | - | overwrite_file | No | Affects the behavior of the module and defines the save mode, as described in the documentation. | |
*/
Expand Down
2 changes: 1 addition & 1 deletion src/devices/fakeMicrophone/fakeMicrophone.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ bool fakeMicrophone::open(yarp::os::Searchable &config)
return false;
}

bool b = configureRecorderAudioDevice(config, "fakeMicrophone");
bool b = configureRecorderAudioDevice(config.findGroup("AUDIO_BASE"), "fakeMicrophone");
if (!b) { return false; }

//sets the thread period
Expand Down
2 changes: 2 additions & 0 deletions src/devices/fakeMicrophone/fakeMicrophone.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,12 @@
*
* \brief `fakeMicrophone` : fake microphone device implementing the IAudioGrabberSound interface to generate a test sound.
* It can generate various signals, i.e. sine, sawtooth, square wave, constant.
* This device driver derives from AudioRecorderDeviceBase base class. Please check its documentation for additional details.
*
* Parameters used by this device are:
* | Parameter name | SubParameter | Type | Units | Default Value | Required | Description | Notes |
* |:-----------------:|:--------------:|:-------:|:--------------:|:------------------------:|:--------------------------: |:-----------------------------------------------------------------:|:-----:|
* | AUDIO_BASE | *** | | - | - | No | For the documentation of AUDIO_BASE group, please refer to the documentation of the base class AudioRecorderDeviceBase | |
* | period | - | double | s | 0.010 | No | the period of processing thread | A value of 10ms is recommended. Do to not modify it |
* | waveform | - | string | - | sine | No | Defines the shape of the waveform. Can be one of the following: sine,sawtooth,square,constant | - |
* | signal_frequency | - | int | Hz | 440 | No | Frequency of the generated signal | - |
Expand Down
2 changes: 1 addition & 1 deletion src/devices/fakeSpeaker/fakeSpeaker.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ bool fakeSpeaker::open(yarp::os::Searchable &config)
return false;
}

bool b = configurePlayerAudioDevice(config, "fakeSpeaker");
bool b = configurePlayerAudioDevice(config.findGroup("AUDIO_BASE"), "fakeSpeaker");
if (!b) { return false; }

//sets the thread period
Expand Down
3 changes: 3 additions & 0 deletions src/devices/fakeSpeaker/fakeSpeaker.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,12 @@
*
* \brief `fakeSpeaker` : fake device implementing the IAudioRender device interface to play sound
*
* This device driver derives from AudioPlayerDeviceBase base class. Please check its documentation for additional details.
*
* Parameters used by this device are:
* | Parameter name | SubParameter | Type | Units | Default Value | Required | Description | Notes |
* |:----------------:|:--------------:|:-------:|:--------------:|:------------------------:|:--------------------------: |:-----------------------------------------------------------------:|:-----:|
* | AUDIO_BASE | *** | | - | - | No | For the documentation of AUDIO_BASE group, please refer to the documentation of the base class AudioPlayerDeviceBase | |
* | period | - | double | s | 0.010 | No | the period of processing thread | A value of 10ms is recommended. Do to not modify it |
*/

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -276,7 +276,7 @@ bool PortAudioPlayerDeviceDriver::open(yarp::os::Searchable& config)
return false;
}

bool b = configurePlayerAudioDevice(config, "portaudioPlayer");
bool b = configurePlayerAudioDevice(config.findGroup("AUDIO_BASE"), "portaudioPlayer");
if (!b) { return false; }

m_device_id = config.check("id", Value(-1), "which portaudio index to use (-1=automatic)").asInt32();
Expand Down
10 changes: 6 additions & 4 deletions src/devices/portaudioPlayer/PortAudioPlayerDeviceDriver.h
Original file line number Diff line number Diff line change
Expand Up @@ -34,12 +34,14 @@
* \brief `portaudioPlayer`: A device driver for an audio playback device wrapped by PortAudio library.
* Requires the PortAudio library (http://www.portaudio.com), at least v19.
* Only 16bits sample format is currently supported by this device.
* This device driver derives from AudioPlayerDeviceBase base class. Please check its documentation for additional details.
*
* Parameters used by this device are:
* | Parameter name | SubParameter | Type | Units | Default Value | Required | Description | Notes |
* |:--------------:|:--------------:|:-------:|:--------------:|:------------------------:|:--------------------------: |:-----------------------------------------------------------------:|:-----:|
* | id | - | int | - | - | No | The device id, if multiple sound cards are present | if not specified, the default system device will be used |
* | driver_frame_size | - | int | samples | 512 | No | the number of samples to process on each iteration of the main thread | - | *
* | Parameter name | SubParameter | Type | Units | Default Value | Required | Description | Notes |
* |:-----------------:|:--------------:|:-------:|:--------------:|:------------------------:|:--------------------------: |:-----------------------------------------------------------------:|:-----:|
* | AUDIO_BASE | *** | | - | - | No | For the documentation of AUDIO_BASE group, please refer to the documentation of the base class AudioPlayerDeviceBase | |
* | id | - | int | - | - | No | The device id, if multiple sound cards are present | if not specified, the default system device will be used |
* | driver_frame_size | - | int | samples | 512 | No | the number of samples to process on each iteration of the main thread | - | *
*/

class PortAudioPlayerDeviceDriver :
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,7 @@ bool PortAudioRecorderDeviceDriver::open(yarp::os::Searchable& config)
return false;
}

bool b = configureRecorderAudioDevice(config,"portaudioRecorder");
bool b = configureRecorderAudioDevice(config.findGroup("AUDIO_BASE"),"portaudioRecorder");
if (!b) { return false; }

m_device_id = config.check("id", Value(-1), "which portaudio index to use (-1=automatic)").asInt32();
Expand Down
14 changes: 6 additions & 8 deletions src/devices/portaudioRecorder/PortAudioRecorderDeviceDriver.h
Original file line number Diff line number Diff line change
Expand Up @@ -33,16 +33,14 @@
* \brief `portaudioRecorder`: A device driver for an audio source wrapped by PortAudio library.
* Requires the PortAudio library (http://www.portaudio.com), at least v19.
* Only 16bits sample format is currently supported by this device.
* This device driver derives from AudioRecorderDeviceBase base class. Please check its documentation for additional details.
*
* Parameters used by this device are:
* | Parameter name | SubParameter | Type | Units | Default Value | Required | Description | Notes |
* |:--------------:|:--------------:|:-------:|:--------------:|:------------------------:|:--------------------------: |:-----------------------------------------------------------------:|:-----:|
* | rate | - | int | Hz | 44100 | No | bitrate / sampling frequency | |
* | samples | - | int | samples | 44100 | No | The size of the internal circular buffer | By default this value is equal to the sampling rate, so the buffer size is one second |
* | channels | - | int | - | 2 | No | Number of channels (e.g. 1=mono, 2 =stereo etc | |
* | sample_format | - | int | bits | 16 cannot be modified | Not yet implemented | Not yet implemented | Not yet implemented |
* | driver_frame_size | - | int | samples | 512 | No | Number of samples grabbed by the device in a single uninterruptible operation | It is recommended to NOT CHANGE this value from its default=512 |
* | id | - | int | - | -1 | No | Id of the sound card. | if == -1, portaudio will choose automatically |
* | Parameter name | SubParameter | Type | Units | Default Value | Required | Description | Notes |
* |:-----------------:|:--------------:|:-------:|:--------------:|:------------------------:|:--------------------------: |:-----------------------------------------------------------------:|:-----:|
* | AUDIO_BASE | *** | | - | - | No | For the documentation of AUDIO_BASE group, please refer to the documentation of the base class AudioRecorderDeviceBase | |
* | driver_frame_size | - | int | samples | 512 | No | Number of samples grabbed by the device in a single uninterruptible operation | It is recommended to NOT CHANGE this value from its default=512 |
* | id | - | int | - | -1 | No | Id of the sound card. | if == -1, portaudio will choose automatically |
*/

class PortAudioRecorderDeviceDriver :
Expand Down
20 changes: 10 additions & 10 deletions src/libYARP_dev/src/yarp/dev/AudioPlayerDeviceBase.h
Original file line number Diff line number Diff line change
Expand Up @@ -34,16 +34,16 @@ class AudioDeviceDriverSettings
* \brief `AudioPlayerDeviceBase` : a base class for all audio player devices
*
* Parameters required by this device are:
* | Parameter name | SubParameter | Type | Units | Default Value | Required | Description | Notes |
* |:----------------:|:--------------:|:-------:|:--------------:|:------------------------:|:--------------------------: |:-----------------------------------------------------------------:|:-----:|
* | rate | - | int | Hz | 44100 | No | The frequency of the audio device | - |
* | samples | - | int | samples | 44100 | No | The size of the internal buffer (in samples) | A default value identical to device frequency implies a buffer length of 1s |
* | channels | - | int | - | 2 | No | The number of channels | - |
* | bits | - | int | - | 16 | No | Not yet implemented | - | *
* | hw_gain | - | double | - | 1.0 | No | The device audio gain. Its implementation is device dependent (and it may also be not implemented) | - | *
* | sw_gain | - | double | - | 1.0 | No | A SW gain for audio waveform amplification | - | *
* | render_mode_append | - | bool | - | true | No | A new sound is appended to the playback buffer and reproduced accordingly | - | *
* | render_mode_immediate | - | bool | - | false | No | Every new sound is immediately reproduced, stopping the current playback | - | *
* | Parameter name | SubParameter | Type | Units | Default Value | Required | Description | Notes |
* |:----------------:|:----------------------:|:-------:|:--------------:|:------------------------:|:--------------------------: |:-----------------------------------------------------------------:|:-----:|
* | AUDIO_BASE | rate | int | Hz | 44100 | No | The frequency of the audio device | - |
* | AUDIO_BASE | samples | int | samples | 44100 | No | The size of the internal buffer (in samples) | A default value identical to device frequency implies a buffer length of 1s |
* | AUDIO_BASE | channels | int | - | 2 | No | The number of channels | - |
* | AUDIO_BASE | bits | int | - | 16 | No | Not yet implemented | - | *
* | AUDIO_BASE | hw_gain | double | - | 1.0 | No | The device audio gain. Its implementation is device dependent (and it may also be not implemented) | - | *
* | AUDIO_BASE | sw_gain | double | - | 1.0 | No | A SW gain for audio waveform amplification | - | *
* | AUDIO_BASE | render_mode_append | bool | - | true | No | A new sound is appended to the playback buffer and reproduced accordingly | - | *
* | AUDIO_BASE | render_mode_immediate | bool | - | false | No | Every new sound is immediately reproduced, stopping the current playback | - | *
*/

class YARP_dev_API AudioPlayerDeviceBase : public yarp::dev::IAudioRender
Expand Down
Loading

0 comments on commit a72bc5a

Please # to comment.