Audio Library

PreviousNext

Setup

Overview

There are some basic things you should take care about when you plan to use audio in your applications. SDL_mixer doesn't provide built-in MP3 support, but you may compile it a special way to get support using the smpeg library.

Another problem comes with EWG, as different versions don't generate the same output. The most common solutions are presented to generate identical output.

MP3 support

To enable MP3 support with SDL_mixer you have to download the following files:

You will find both libraries on http://www.libsdl.org.

It is recommended to compile the SDL_mixer library using Microsoft Visual C++, as those steps were described here. Any other developement environment may work in a similar way.

  1. Open SDL_mixer project in the IDE
  2. Go to the project settings
  3. Add MP3_MUSIC to the defines
  4. Add smpeg.lib to the libraries
  5. Compile the library

You need also a compiled version of the smpeg library to be able to play MP3 files with SDL_mixer and this audio API.

EWG notes

As different versions of EWG generate different outputs, one may have missing files. If you're missing such files, please read on to be able to fix such issues.

One of these missing files may be void_void_anonymous_callback_callback.e which should be generated for the function Mix_HookMusicFinished. It is shown as an example, how you can get the callback file.

  1. Open file SDL_mixer.h in any text editor
  2. Search for the following line:
    extern DECLSPEC void SDLCALL Mix_HookMusicFinished(void (*music_finished)(void));
  3. Delete the void parameter:
    extern DECLSPEC void SDLCALL Mix_HookMusicFinished(void (*music_finished)());
  4. Save the file and rebuild the library

There should now be the generated file void_void_anonymous_callback_callback.e and all the audio stuff should compile as it should.