Jump to content
  • Advertisement
Sign in to follow this  
aslangsfma

load sounds with SDL_mixer

This topic is 3532 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I am using SDL and OpenGL and I want to use my ogg files with SDL_mixer. I can load sounds and play them but they are slower than normal.If you can help me I will be very thankful.

Share this post


Link to post
Share on other sites
Advertisement

#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
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!