[SDL] Audio capture support and new Mac/iOS audio target...

Ryan C. Gordon icculus at icculus.org
Tue Sep 6 06:48:37 PDT 2016

Heads up: SDL now supports audio capture! With the latest in revision control, you can record audio from a microphone. This will go into 2.0.5.

To use: you can enumerate capture devices the same way as you normally would; that previously-unused "iscapture" parameter should be set to 1.

You open audio devices for capture as before, but with iscapture=1. The difference is your callback will fire as usual, but you are expected to read data from it--the audio from your microphone--instead of writing data to be played.

If you hate callbacks, I've added SDL_DequeueAudio(), which works like 2.0.4's SDL_QueueAudio() but pulls data that is collecting from the mic.

This is implemented for darn near everything: Windows, Mac, Linux, iOS, Android, Emscripten.

You can try the Enscripten version in your web browser here:

(This works in Firefox and Chrome on the desktop, Chrome on Android, and not at all on Safari or iOS at the moment. WebKit does not currently offer audio capture support.)

Feedback welcome!

Also worth noting: the Mac/iOS audio code has changed from AudioUnits to AudioQueues. This fixed several problems and was more pleasant to work with.

If you have a Mac or iOS SDL game, please test the new code, even if you don't care about recording audio.


More information about the SDL mailing list