Sign in to follow this  
aslangsfma

load sounds with SDL_mixer

Recommended Posts


#define audio_rate 22050
#define audio_format AUDIO_S16SYS
#define audio_channels 2
#define audio_buffers 4096

void musicFinished()
{
Mix_HaltMusic();
Mix_CloseAudio();
}

void play_music(int k)
{
if(Mix_OpenAudio(audio_rate, audio_format, audio_channels, audio_buffers) != 0)
{
printf("Unable to initialize audio: %s\n", Mix_GetError());
return;
}
if(Mix_PlayMusic(music, 0) == -1)
{
printf("Unable to play file: %s\n", Mix_GetError());
return;
}
}
int load_musics(char name[])
{
music = Mix_LoadMUS(name);
if(music == NULL)
{
printf("Unable to load file: %s\n", Mix_GetError());
rv=1;
}
else printf("Music:%s loaded.\n",name);
Mix_HookMusicFinished(musicFinished);
}


This is all of my code for load and play I think audio format is wrong.


[Edited by - aslangsfma on January 20, 2009 10:50:04 AM]

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this