Audio recording code review

So after the semester from hell and having to deal with driver issues, I managed to complete an audio recording tutorial, well the demo at least:
http://lazyfoo.net/tutorials/SDL/34_audio_recording/34_audio_recording.zip

I’ve done some audio programming before, but nothing too crazy. Before I start doing the actual tutorial, I would like to get some feedback to make sure I am doing it right.

1 Like

One minor bug in here: on the “press 1 to play, 2 to record again” screen, if you press 2, it tries to play and record at the same time, each device’s callback updating gBufferBytePosition and the playback callback eventually playing loud random bytes of data, and recording overflowing a buffer.

//Start playback
f( e.key.keysym.sym >= SDLK_1 )

Should be == instead of >=, or the SDLK_2 test should be in an else so both tests don’t succeed, causing recording and playback to start if you press ‘2’.

Other than that: it worked like a boss on this MacBook. I totally dig lazy.ttf, too. :slight_smile:

–ryan.

1 Like