Best practice for C++ audio capture API under Linux?

braddock picture braddock · May 26, 2010 · Viewed 10.3k times · Source

I need to create a C++ application with a simple audio recording from microphone functionality.

I can't say that there aren't enough audio APIs to do this! Pulse, ALSA, /dev/dsp, OpenAL, etc. My question is what is the current "Best practice" API?

Pulse seems supported by most modern distros, but seems almost devoid of documentation. Will OpenAL be supported across different distros, or is it too obscure? Have I missed any?
Is there not a simple answer?

Answer

Spudd86 picture Spudd86 · May 26, 2010

Lennart Pottering has a guide here:

http://0pointer.de/blog/projects/guide-to-sound-apis

basically use the 'safe' subset of alsa then all the other important ones should work too.

Barring that OpenAL works on Linux

EDIT: Also pulseaudio has reasonably good doxygen generated documentation here and some other stuff here and some of the utilities are good examples, you can see them in gitweb here

Also I've written some code that uses pulse for audio input you can look at it here, however I'm not sure I handle everything totally correctly, and I know I'm missing code to handle certain situations... but that should get you started should you go with pulse.