Using Sdl_Mixer


Kavb

Still Fresh
Joined
Sep 12, 2011
Messages
21
Location
Somewhere beyond the vast nothingness of space and
I'm trying to get sound working in my project using SDL_Mixer.

I load the audio file using Mix_LoadMUS and it works fine on my computer but doesn't work on my Caanoo. I tried ogg, wav, and mp3 and none of them gave me any sound on my Caanoo.

Any help would be appreciated. Thanks!
 
Kavb said:
I'm trying to get sound working in my project using SDL_Mixer.

I load the audio file using Mix_LoadMUS and it works fine on my computer but doesn't work on my Caanoo. I tried ogg, wav, and mp3 and none of them gave me any sound on my Caanoo.

Any help would be appreciated. Thanks!

My experience with the music api was that it was buggy. My final solution was just to use the normal sample chunk api for music and sound effects.
 
Last edited by a moderator:
From my game i use this to load and it work:
Code:
void SystemMusic (char *name) {
	Mix_HaltMusic ();
	Mix_FreeMusic (music);

	sprintf (file, "sound/music/%s", name);

	music = Mix_LoadMUS (file);
	if (music == NULL)
		fprintf (stderr, "SystemMusic failed: Cannot open file\n");
	else if (sys_sound == 1)
		Mix_PlayMusic (music, -1);
}

void SystemSound (char *name, int wait) {
	Mix_HaltChannel (-1);
	Mix_FreeChunk (sound);

	sprintf (file, "sound/%s", name);

	sound = Mix_LoadWAV (file);
	if (sound == NULL)
		fprintf (stderr, "SystemSound failed: Cannot open file\n");
	else if (sys_sound == 1) {
		channel = Mix_PlayChannel (-1, sound, 0);
		Mix_Playing (channel);

		SDL_Delay (wait);
	}
}
 
I'm using SDL_mixer in my open console projects and dont have a problem with at least .ogg files. Are you initializing the device correctly?

Code:
Mix_OpenAudio( 44100, AUDIO_S16, 2, 1024 );

and then i just use
Code:
Mix_Music* music = Mix_LoadMUS( pathToFile );
Mix_PlayMusic(music,0);

to get it going
 
Back
Top