Skip to main content
GameDev.net gamedev.net
🔒 Locked

Using SDL_mixer to play ogg sound (not music) effects

Started by kordova Sep 1, 2006 at 12:39 PM 8 replies 7.3k views
Original Post
kordova
kordova
I am loading a .ogg file to play as music which works correctly. According to Mix_LoadWAV you can load .ogg files to play as sound as well. I was able to load a .wav file and play it properly, but attempting to load a .ogg file (the same music file, I removed loading it for music) I get "Unrecognized sound file type" Has anyone had any luck loading .oggs for sound effects? Does anyone know what might be incorrect?
Rob Loach
Rob Loach
In a recent version of SDL (1.2.10 I believe), .OGG support broke. This bug was supposedly fixed in the most recent release of SDL (1.2.11).
Rob Loach [Website] [Projects] [
kordova
kordova
That is interesting as I could play .ogg with the music capabilities of SDL_mixer, but not the sound effect (Mixer_Chunk version). Thanks for the tip, I will try upgrading.

Edit: I installed the 1.2.11 SDL XCode framework with no luck.
kordova
kordova
Ok, it must be the file that I have (a music ogg file). Another poster's code (and file) worked for me but when I plug my filename into the application I get the same error of "Unrecognized sound file type." It is interesting to me that I can load it [the song] as music but not as a sound chunk.
orcfan32
orcfan32
Quote:
Original post by Rob Loach
In a recent version of SDL (1.2.10 I believe), .OGG support broke. This bug was supposedly fixed in the most recent release of SDL (1.2.11).


That's strange, when I was using SDL 1.2.10, .OGG's worked just fine. I used this code:
int play_sound(std::string Filename){	Mix_Chunk *sound = Mix_LoadWAV(Filename.c_str());	int SChannel = 0;		if (sound == NULL)	{		Mix_FreeChunk(sound);		return 1;	}	else	{		SChannel = Mix_PlayChannel(-1, sound, 0);		while(Mix_Playing(SChannel) != 0);		{			Mix_FreeChunk(sound);		}		return 0;	}}


Unfortunately, I can't compile it ATM because I don't have a compiler. If anyone else wants to have a go at it, go ahead.
The best thing to do is just choose whatever you think you'd prefer, and go for it. -Promit
kordova
kordova
Yeah,
I tried another ogg and it plays fine. I still cannot determine what determines the playability of an ogg as a sound (rather than the 100% success I've encountered in playing them as music).
Rob Loach
Rob Loach
Quote:
Original post by orcfan32
That's strange, when I was using SDL 1.2.10, .OGG's worked just fine.
Maybe I was thinking MP3 support. There were some issues with something.......

Rob Loach [Website] [Projects] [
kordova
kordova
Quote:
Original post by lonesock
doesn't the ogg file need to be mono to play as a sound?

That is the most likely cause. I'll have to test it when I get the chance. Thanks!
orcfan32
orcfan32
Quote:
Original post by Rob Loach
Quote:
Original post by orcfan32
That's strange, when I was using SDL 1.2.10, .OGG's worked just fine.
Maybe I was thinking MP3 support. There were some issues with something.......


Ah, midi support. That's the first format I tried with SDL_Mixer and it didn't work.
The best thing to do is just choose whatever you think you'd prefer, and go for it. -Promit

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.