Noob Question regarding Audio in SDL

Hi guys.

I’ve been farting about with C++ for some time now, I have a fair understanding.
I’ve tried QT, JUCE etc. all tied up in licencing that I don’t understand. I’m using latest VS now.

I would like to build an Audio Application, that records audio from an Interface, and plays it back, I don’t want to say ‘DAW’, but a very very limited ‘DAW’ might be appropriate…
Is it possible in SDL? I’ve searched obviously, and watched one or two videos eek! There doesn’t seem to be any good books or Tuts on the Subject of Audio in SDL. Could anyone point me in the right direction if so? Cheers.

Certainly, it’s even possible in ‘core’ SDL 2.0, i.e. without SDL_mixer. To record audio you first need to find out what capture devices are available, which you can do with SDL_GetNumAudioDevices() and SDL_GetAudioDeviceName(). Having selected your capture source you open it with SDL_OpenAudioDevice() and unpause it with SDL_PauseAudioDevice(). The actual audio capture (to memory, and typically then saved to file) is done with SDL_DequeueAudio().

Excellent. I have barebones SDL setup in VS. I’ll keep going so.

Hi, sorry to be a pain. Just looking at the Mixer API - “It supports any number of simultaneously playing channels of 16 bit stereo audio”.

Can we record in 24 bit Mono in SDL? I’ve already seen that it handles a 48K SampleRate which is great!

The supported audio formats are listed here, 32-bit integer samples are included (e.g. AUDIO_S32LSB) but not 24-bits. However it tells you how to construct the corresponding SDL_AudioFormat value so it may possibly work if the hardware supports it. Trying it would be the only way to be sure.

1 Like