Using SDL_mixer to play ogg sound (not music) effects

Member
Posts: 20
Joined: 2006.06
Post: #1
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?
Quote this message in a reply
Sage
Posts: 1,403
Joined: 2005.07
Post: #2
You probably want to use libvorbisfile to load the ogg file and turn it into sound buffer data which you then send directly to SDL_mixer, get this libs from here http://www.xiph.org/downloads/ you need ogg and vorbis.
There are some good tutorials (mostly targeted at OpenAL although the actual ogg loading part would be the same regardless) around and if you want I can paste some code i've written that streams ogg's using OpenAL if you think that would be useful.
I would also think about switching from SDL_mixer to OpenAL, it gives you full 3D sound 'for free' and is a lot better in terms of sound quality and API usability.

Sir, e^iπ + 1 = 0, hence God exists; reply!
Quote this message in a reply
Member
Posts: 111
Joined: 2002.06
Post: #3
I can play an ogg vorbis file as a sound effect. Calling Mix_LoadWav() is all you should have to do. Email me, and I can send you my code that plays an ogg vorbis sound effect.

Mark Szymczyk
http://www.meandmark.com
Quote this message in a reply
Member
Posts: 20
Joined: 2006.06
Post: #4
Ok, it must be the file that I have (a music ogg file). Your code works for me, Mark, but when I plug my filename into your application I get the same error of "Unrecognized sound file type." It is interesting to me that I can load it as music but not as a sound chunk. Is there a reason for this?

Oh, and I do want to at least try OpenAL in the long term but this project is pretty simple and is more about my getting comfortable with the release side of development on the Mac. Thank you for the information though, either way I will be integrating that into my work.
Quote this message in a reply
Post Reply 

Possibly Related Threads...
Thread: Author Replies: Views: Last Post
  Music Composition, Sound Design and Implementation for your games MyMiniGemini 0 53 Yesterday 03:13 PM
Last Post: MyMiniGemini
  Background music and Sound FX on the Mac ipeku 9 10,108 Sep 26, 2011 06:50 AM
Last Post: ipeku
  LoFi/8-bit Sound and Music metacollin 11 7,035 May 20, 2009 10:52 AM
Last Post: Gamecues
  SDl_mixer and image bronxbomber92 3 3,535 Dec 15, 2006 12:27 PM
Last Post: bronxbomber92
  Installing SDL_image & SDL_mixer bronxbomber92 8 5,735 Oct 14, 2006 09:39 PM
Last Post: szymczyk