-
Notifications
You must be signed in to change notification settings - Fork 14
How To
doe300 edited this page Mar 21, 2016
·
3 revisions
Any component which deals with audio-data in some way (e.g. converting them, amplifying the volume, storing them in a file) is added as an audio-processor. To add a new AudioProcessor, following steps are required:
- Create a class publicly extending AudioProcessor
- Implement the functionality into this class
- Use configure() to initialize the component and set all user-defined and settings-dependent values
- Use processInputData() to process audio-input (coming from the microphone, being sent to the remote device)
- Use porcessOutputData() to process audio-output (received from the remote device, being played out)
- Don't forget to cleanUp() all the allocated resources!
- Add the newly created AudioProcessor to AudioProcessorFactory
- This is required if the user (or any other component) should be able to add the processor on demand
- Create a new unique name and add it to the list for getAudioProcessorNames()
- Add the constructor-call to getAudioProcessor() which will create a new processor-instance
- Make sure to surround all accesses to your processor with HEADER_GUARDS or make sure, the processor is available in any distribution to prevent compilation errors on different systems
- You're done!
Additional options:
- If the processor required additional configuration, register new Parameters (or re-use appropriate existing) and get their values in configure() (See GainControl as example)
- For codecs which should be able to be used with SIP, add the supported audio-formats to SupportedFormats, they are automatically mapped to the correct audio-processor, if their names match
- If the processor uses some external library, add it to the CMakeFiles. It is recommended to make all external libraries (and therefore their wrappers) optional, if possible
A library used to communicate with the audio-devices (microphone, speaker) is called audio-library or audio-handler in scope of the OHMComm project. Although the bundled audio-library RtAudio and the provided Portaudio-wrapper should be sufficient for a wide range of platforms, a custom audio-library could be required for porting to a not yet supported platform or directly accessing a platform-dependent audio-driver. To add a new AudioHandler, follow these steps:
- Create a class which publicly extends AudioHandler
- Implement the functionality into this class
- Use prepare() to initialize the underlying library and query the support for all registered audio-processors (See RtAudioWrapper for details)
- Implement start(), resume(), stop() and reset() to control the playback
- Overwrite getAudioDevices() to provide a library-independent list of all supported audio-devices and their capabilities
- Add the new AudioHandler to AudioHandlerFactory
- This is required for the audio-processor to be usable
- Create a unique name for the audio-handler and add it to the list for getAudioHandlerNames()
- Add the constructor-call to getAudioHandler(), which will create the selected audio-handler
- Make sure to surround all accesses to your audio-library with HEADER_GUARDS or make sure, the library is available in any distribution to prevent compilation errors on different systems
- You're done!