SDL_Mixer - Help

Hi!

I’m searching for good help-file for the SDL_Mixer-library. Does anybody know where to find a tuturial?

For a game-project I need to mix background-music (OGG) with samples. It should be easy with SDL_Mixer, but I don’t know how to write such a code.
This is the first time I try to use this library. Cany anybody help?

Greetings Hauke

I’m afraid I’m not very experienced myself, but I can give you my bumbling
experience in terms of general use of the library (nothing specific to OGG,
I assume their usage is transparent):

Initialise the audio when you start your app:
if ( SDL_InitSubSystem(SDL_INIT_AUDIO) < 0 )
fprintf(stderr, “Problem initialising audio system: %s\n”,
SDL_GetError());
else
{
// Initialize audio variables
audio_rate = 22050;
audio_format = AUDIO_S16;
audio_channels = 2;
audio_buffers = 1024;
if( Mix_OpenAudio(audioSetup.audio_rate, audioSetup.audio_format,
audioSetup.audio_channels, audioSetup.audio_buffers) < 0 )
fprintf(stderr, “Couldn’t open audio: %s\n”, SDL_GetError());
else
{
Mix_AllocateChannels(16);
Mix_QuerySpec(&audioSetup.audio_rate, &audioSetup.audio_format,
&audioSetup.audio_channels);
}
}
signal(SIGINT, exit);
signal(SIGTERM, exit);

Then load your music file into a Mix_Music pointer (I use mods in my apps):
music = Mix_LoadMUS(filename);

Then play it:
Mix_PlayMusic(music, loops); // where loops is the number of times you’d
like the music to be looped (-1 means infinitely)

I don’t really know of a good tutorial, just looking at the SDL_Mixer header
file is a good way to start though.> ----- Original Message -----

From: haukegooshabermann@runbox.com ()
To:
Sent: Friday, September 14, 2001 7:48 PM
Subject: [SDL] SDL_Mixer - Help

Hi!

I’m searching for good help-file for the SDL_Mixer-library. Does anybody
know where to find a tuturial?

For a game-project I need to mix background-music (OGG) with samples. It
should be easy with SDL_Mixer, but I don’t know how to write such a code.
This is the first time I try to use this library. Cany anybody help?

Greetings Hauke


SDL mailing list
SDL at libsdl.org
http://www.libsdl.org/mailman/listinfo/sdl

At 11:48 Uhr +0200 14.09.2001, wrote:

Hi!

I’m searching for good help-file for the SDL_Mixer-library. Does
anybody know where to find a tuturial?

There is none to my knowledge.

For a game-project I need to mix background-music (OGG) with
samples. It should be easy with SDL_Mixer, but I don’t know how to
write such a code.
This is the first time I try to use this library. Cany anybody help?

Look at the source for playmus/playway in the SDL_mixer package. Look
at SDL_mixer.h, it is well documented, and the API is very straight
forward, IMHO. Also you may want to look at some apps that use
SDL_mixer, several are lsited on the SDL homepage.

HTH,

Max–

Max Horn
Software Developer

email: mailto:Max_Horn
phone: (+49) 6151-494890