SDL2 audio examples
Initializing the audio
These are some tutorials/examples on using SDL to play audio. I've tried to provide clear and runnable code examples of what I'm talking about, but they are not necessarily either, and I might not be sure of what I'm talking about. But hopefully some of these are useful.
Initializing the audio
Initialize SDL2's audio subsystem, and see what drivers, devices, and sample formats we have access to.
Playing a sine wave 1
Introduction to the audio callback, and playing a simple sine wave. Also, modifying the sound while it's playing.
Playing a sine wave 2
Playing a precomputed sine wave from memory, looping.
Playing a WAV file
Playing a WAV file, basically "Playing a sine wave 2" but with any sound.
PlaySound function
A basic implementation of a function to add sounds to a list of sounds being played by the audio callback.
Back to SDL2 page
These are some tutorials/examples on using SDL to play audio. I've tried to provide clear and runnable code examples of what I'm talking about, but they are not necessarily either, and I might not be sure of what I'm talking about. But hopefully some of these are useful.
Initializing the audio
Initialize SDL2's audio subsystem, and see what drivers, devices, and sample formats we have access to.
Playing a sine wave 1
Introduction to the audio callback, and playing a simple sine wave. Also, modifying the sound while it's playing.
Playing a sine wave 2
Playing a precomputed sine wave from memory, looping.
Playing a WAV file
Playing a WAV file, basically "Playing a sine wave 2" but with any sound.
PlaySound function
A basic implementation of a function to add sounds to a list of sounds being played by the audio callback.
Back to SDL2 page