This patch adds audio recording support to SDL 1.2, including full duplex (simultaneous playback and record). It also adds the ability to save recorded audio to a WAV file.
04-18-2002: SDL-1.2-record.diff
To apply the patch, download the SDL library source code, go into the top-level of the source directory (such as SDL-1.2.4) and type:patch -p1 < /path/to/the/downloaded/patch/SDL-1.2-record.diffwhere /path/to/the/downloaded/patch/ is the path to the downloaded patch.Before you pass your audio spec to SDL_OpenAudio(), you should abuse the bits in the format field as follows:
Set AUDIO_INPUT (now defined in SDL_audio.h) to enable recording. Set AUDIO_OUTPUT (also defined in SDL_audio.h) to enable playback. If you set neither bit, which is what all current SDL programs do, then only playback is enabled. Examples:
spec.format |= AUDIO_INPUT; /* enables recording */ spec.format |= AUDIO_OUTPUT; /* enables playback */Next you just set your single audio callback as in a normal SDL program. SDL puts any recorded data in the stream buffer for your callback to use. And then any data you want to play should be stored in that same stream buffer by the time the callback returns.Thanks to David Olofson for the idea of the new backwards-compatible API.
I welcome all comments, ideas, criticism, questions, etc.Dan Helfman <witten@torsion.org>