PCM plugin converters

Updated: April 19, 2023

In some cases, an application has data in one format, and the PCM device is capable of accepting data only in another format. Clearly this won't work unless something is done. The application — like some MPG decoders — could reformat its data “on the fly” to a format that the device accepts. Alternatively, the application can ask QSA to do the conversion for it.

Plugin converters and PCM plugin API functions

The format conversion is accomplished by invoking a series of plugin converters, each capable of doing a very specific job. For example, the rate converter converts a stream from one sampling frequency to another. There are plugin converters for bit conversions (8-to-16-bit, etc.), endian conversion (little endian to big endian and vice versa), voice conversions (stereo to mono, etc.) and so on.

To minimize CPU usage, the minimum number of converters is invoked to translate the input format to the output format. An application signals its willingness to use the plugin converter interface by using the PCM plugin API functions. These API functions all have plugin in their names. For more information, see the Audio Library chapter.

The ability to convert audio to match hardware capabilities (for example, voice conversion, rate conversion, type conversion, etc.) is enabled by default. This impacts the functions snd_pcm_channel_params(), snd_pcm_channel_setup(), and snd_pcm_channel_status(). These behave as snd_pcm_plugin_params(), snd_pcm_plugin_setup(), and snd_pcm_plugin_status(), unless you've disabled the conversion by calling:

snd_pcm_plugin_set_disable(handle, PLUGIN_CONVERSION);
Note: Don't mix the plugin API functions with the nonplugin functions.

Polyphase SRC plugin converter

Because the polyphase SRC plugin converter provides the best quality rate conversion with the least amount of CPU usage, QSA always tries to use it as the source filter method, regardless of the filter set using snd_pcm_plugin_set_src_method().

It supports the following sample rate conversions:
  • 8000 to 12000, 16000, 24000, 32000, or 48000
  • 11025 to 8000, 12000, 22050, 24000, or 44100
  • 12000 to 8000, 11050, 24000, or 48000
  • 16000 to 8000, 32000, 24000, 48000, or 96000
  • 22050 to 8000, 11025, 16000, 24000, 44100, 48000, or 88200
  • 24000 to 8000, 12000, 16000, 22050, 48000, or 96000
  • 32000 to 8000,16000, 48000, 96000, or 192000
  • 44100 to 11020, 16000, 22050, 32000, 48000, 88200, 96000, or 1764000
  • 48000 to 8000, 12000, 16000, 24000, 32000, 44100, 96000, or 192000
  • 88200 to 22050, 32000, 44100, 96000, 192000, or 176400
  • 96000 to 16000, 24000, 32000, 88200, or 192000
  • 176400 to 44100, 88200, or 19200
  • 192000 to 32000, 48000, 96000, or 176400

If the client requests a conversion that is not supported, QSA uses one of the other supported SRC methods (set using snd_pcm_plugin_set_src_method()), which support any sample rate conversion but may produce lower-quality conversions or use more CPU resources.

QSA also uses one of the other SRC methods if asynchronous SRC is enabled (set using snd_pcm_plugin_set_src_mode()).