Music and Sound Effects Using SDL_mixer
Category: SDL Adventure Game
SDL_mixer is a simple multi-channel audio mixer that I am using to play sound effects and music in the game.
How to Install SDL_mixer
I’ve taken an approach similar to the one used for installing SDL_image:
- Download the library from GitHub. I downloaded and installed SDL_mixer 2.8.0.
 - Add the 
SDL2_mixer.frameworkto the project (under the “General” tab). - Change imports to 
#import <SDL2_mixer/SDL_mixer.h>. 
Setup and Usage
I followed the Sound Effects and Music Lazy Foo’ Productions tutorial to set up and test the library.
Basic steps:
- Initialize the library with a call to 
Mix_OpenAudio. - Load an audio file as a chunk or as music with a call to 
Mix_LoadWAVorMix_LoadMUS, respectively. - Play a chunk or music by calling 
Mix_PlayChannelorMix_PlayingMusic, respectively.