# Problems loading ogg and wav music

**URL:** <https://discourse.libsdl.org/t/problems-loading-ogg-and-wav-music/15037>\
**Category:** SDL Development\
**Created:** [December 23, 2007, 4:49am UTC](https://discourse.libsdl.org/t/problems-loading-ogg-and-wav-music/15037 "2007-12-23T04:49:33Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![James\_Barrett](https://discourse.libsdl.org/letter_avatar_proxy/v4/letter/j/5f9b8f/32.png) [@James\_Barrett](https://discourse.libsdl.org/u/James_Barrett)\
**Post date:** [December 23, 2007, 4:49am UTC](https://discourse.libsdl.org/t/problems-loading-ogg-and-wav-music/15037/1 "2007-12-23T04:49:33Z")

</div>

Hi, I am trying to open an ogg file with Mix\_FadeInMusic(). I could not  
find an entry at [http://www.libsdl.org/cgi/docwiki.cgi/SDL\_5fmixer](http://www.libsdl.org/cgi/docwiki.cgi/SDL_5fmixer) for  
this function, so I looked in the SDL\_mixer.h file. I see Mix\_MusicType  
enum with a MUS\_OGG type so I assume that SDL\_mixer does support ogg  
music files. But the program crashes as soon as the call to  
Mix\_FadeInMusic() is made, and nothing after it. It never even gets to  
the next line that prints the Mix\_GetError() to stderr. So I’m not sure  
what I did wrong. No error is produced when I load the file with  
Mix\_LoadMUS() so I assume it is reading the file ok.

Then another problem occured. I exported the ogg file (with audacity)  
as a wav file, and now Mix\_LoadMUS() can’t load the file. Output from  
Mix\_GetError() is “Unable to load WAV file”.

I am running Debian Linux (Etch) with stable deb packages fro SDL and  
SDL\_mixer.  
SDL 1.2.11-8  
SDL\_mixer 1.2.6-1.1+b2

I am able to load and play ogg sound effects with Mix\_LoadWAV and  
Mix\_PlayChannel()

Jim

---

<div class="post-metadata">

**Author:** ![James\_Barrett](https://discourse.libsdl.org/letter_avatar_proxy/v4/letter/j/5f9b8f/32.png) [@James\_Barrett](https://discourse.libsdl.org/u/James_Barrett)\
**Post date:** [December 23, 2007, 8:16am UTC](https://discourse.libsdl.org/t/problems-loading-ogg-and-wav-music/15037/2 "2007-12-23T08:16:33Z")

</div>

Update: I downloaded souce, built and installed SDL\_mixer v1.2.8. I  
don’t know if there are conflicts with this version and the version of  
SDL I have installed.

I read in SDL\_mixer.h that this method /Mix\_LoadMUS\_RW() / loads “Ogg  
and MikMod specific currently” So I tried loading the ogg music file  
with these two lines. I do not know if I have this correct:  
SDL\_RWops\* rw = SDL\_RWFromFile(p.resourceName.c\_str(), “rb”);  
m = Mix\_LoadMUS\_RW( rw );

I don’t get an error (m is not null) so I assume that the file is being  
load ok.

Both Mix\_FadeInMusic() and Mix\_PlayMusic() crash without returning.

Then, when attempting to load a wav music file with the above two lines  
of code, Mix\_GetError() returns “Module format not recognized”

I don’t know what that means. I can’t find any documentation on it.

Jim

James Barrett wrote:\> Hi, I am trying to open an ogg file with Mix\_FadeInMusic(). I could not

> find an entry at [http://www.libsdl.org/cgi/docwiki.cgi/SDL\_5fmixer](http://www.libsdl.org/cgi/docwiki.cgi/SDL_5fmixer) for  
> this function, so I looked in the SDL\_mixer.h file. I see Mix\_MusicType  
> enum with a MUS\_OGG type so I assume that SDL\_mixer does support ogg  
> music files. But the program crashes as soon as the call to  
> Mix\_FadeInMusic() is made, and nothing after it. It never even gets to  
> the next line that prints the Mix\_GetError() to stderr. So I’m not sure  
> what I did wrong. No error is produced when I load the file with  
> Mix\_LoadMUS() so I assume it is reading the file ok.
> 
> Then another problem occured. I exported the ogg file (with audacity)  
> as a wav file, and now Mix\_LoadMUS() can’t load the file. Output from  
> Mix\_GetError() is “Unable to load WAV file”.
> 
> I am running Debian Linux (Etch) with stable deb packages fro SDL and  
> SDL\_mixer.  
> SDL 1.2.11-8  
> SDL\_mixer 1.2.6-1.1+b2
> 
> I am able to load and play ogg sound effects with Mix\_LoadWAV and  
> Mix\_PlayChannel()
> 
> Jim

–  
I am RETRO Sci Fi  
Geeky Tech Guy  
[http://www.geekytechguy.net](http://www.geekytechguy.net)  
Ham it up! kb1odg

---

<div class="post-metadata">

**Author:** ![Solra\_Bizna](https://discourse.libsdl.org/letter_avatar_proxy/v4/letter/s/e19adc/32.png) [@Solra\_Bizna](https://discourse.libsdl.org/u/Solra_Bizna)\
**Post date:** [December 23, 2007, 11:52pm UTC](https://discourse.libsdl.org/t/problems-loading-ogg-and-wav-music/15037/3 "2007-12-23T23:52:30Z")

</div>

Mix\_LoadMUS\_RW can only load music in either Ogg format or a  
MikMod-compatible format. The other helper libraries it uses are only  
capable of loading from a given filename, apparently.  
At a guess, it tries loading it as an Ogg, and if that fails passes it  
to MikMod to try as a Module (returning the error MikMod gave it on  
failure).  
-:sigma.SBOn 12/23/07, James Barrett wrote:

> Then, when attempting to load a wav music file with the above two lines  
> of code, Mix\_GetError() returns “Module format not recognized”

---

<div class="post-metadata">

**Author:** ![James\_Barrett](https://discourse.libsdl.org/letter_avatar_proxy/v4/letter/j/5f9b8f/32.png) [@James\_Barrett](https://discourse.libsdl.org/u/James_Barrett)\
**Post date:** [December 24, 2007, 12:35am UTC](https://discourse.libsdl.org/t/problems-loading-ogg-and-wav-music/15037/4 "2007-12-24T00:35:27Z")

</div>

Solra Bizna wrote:\> On 12/23/07, James Barrett \<@James\_Barrett\> wrote:

> > Then, when attempting to load a wav music file with the above two lines  
> > of code, Mix\_GetError() returns “Module format not recognized”
> 
> Mix\_LoadMUS\_RW can only load music in either Ogg format or a  
> MikMod-compatible format. The other helper libraries it uses are only  
> capable of loading from a given filename, apparently.  
> At a guess, it tries loading it as an Ogg, and if that fails passes it  
> to MikMod to try as a Module (returning the error MikMod gave it on  
> failure).  
> -:sigma.SB  
> Loading an ogg file the regular way with Mix\_LoadMUS(), and trying to  
> play either with Mix\_FadeInMusic() or Mix\_PlayMusic() causes my program  
> to crash. It never return from Mix\_FadeInMusic() or Mix\_PlayMusic(). I  
> don’t know what MikMod is, but I would assume based on the comments I  
> read in SDL\_mixer.h that these functions would open and play any  
> supported file format. I only tried it the other way when all else  
> failed. Are you able to get ogg music files to play using either  
> Mix\_FadeInMusic() or Mix\_PlayMusic()?

Thanks,

Jim

---

<div class="post-metadata">

**Author:** ![Solra\_Bizna](https://discourse.libsdl.org/letter_avatar_proxy/v4/letter/s/e19adc/32.png) [@Solra\_Bizna](https://discourse.libsdl.org/u/Solra_Bizna)\
**Post date:** [December 24, 2007, 12:46am UTC](https://discourse.libsdl.org/t/problems-loading-ogg-and-wav-music/15037/5 "2007-12-24T00:46:54Z")

</div>

It’s been a while since I’ve used SDL\_Mixer, but when I did I used  
both Ogg files and (if I remember correctly) a FastTracker module  
without problems.  
Can you get a backtrace from the crash? Without a backtrace, debugging  
this will probably be impossible. It’d also be helpful to know what  
platform you’re on and what compiler you’re using.  
As for MikMod, it is specifically a library for loading tracker  
modules. It itself can’t load formats like MP3 or Ogg (or WAV). For  
more information, see the Wikipedia article on the subject:

> **[MOD (file format)](https://en.wikipedia.org/wiki/MOD_(file_format))**
>
> MOD is a computer file format used primarily to represent music, and was the first module file format. MOD files use the “.MOD” file extension, except on the Amiga which doesn't rely on filename extensions; instead, it reads a file's header to determine filetype. A MOD file contains a set of instruments in the form of samples, a number of patterns indicating how and when the samples are to be played, and a list of what patterns to play in what order.
> The first version of the format was created b...

-:sigma.SBOn 12/23/07, James Barrett wrote:

> Loading an ogg file the regular way with Mix\_LoadMUS(), and trying to  
> play either with Mix\_FadeInMusic() or Mix\_PlayMusic() causes my program  
> to crash. It never return from Mix\_FadeInMusic() or Mix\_PlayMusic(). I  
> don’t know what MikMod is, but I would assume based on the comments I  
> read in SDL\_mixer.h that these functions would open and play any  
> supported file format. I only tried it the other way when all else  
> failed. Are you able to get ogg music files to play using either  
> Mix\_FadeInMusic() or Mix\_PlayMusic()?

---

<div class="post-metadata">

**Author:** ![James\_Barrett](https://discourse.libsdl.org/letter_avatar_proxy/v4/letter/j/5f9b8f/32.png) [@James\_Barrett](https://discourse.libsdl.org/u/James_Barrett)\
**Post date:** [December 24, 2007, 1:23am UTC](https://discourse.libsdl.org/t/problems-loading-ogg-and-wav-music/15037/6 "2007-12-24T01:23:54Z")

</div>

Solra Bizna wrote:\> On 12/23/07, James Barrett \<@James\_Barrett\> wrote:

> It’s been a while since I’ve used SDL\_Mixer, but when I did I used  
> both Ogg files and (if I remember correctly) a FastTracker module  
> without problems.  
> Can you get a backtrace from the crash? Without a backtrace, debugging  
> this will probably be impossible. It’d also be helpful to know what  
> platform you’re on and what compiler you’re using.  
> As for MikMod, it is specifically a library for loading tracker  
> modules. It itself can’t load formats like MP3 or Ogg (or WAV). For  
> more information, see the Wikipedia article on the subject:  
> [MOD (file format) - Wikipedia](http://en.wikipedia.org/wiki/MOD_(file_format))  
> -:sigma.SB

The strange thing is that ogg sound effects play perfectly. It’s just  
the playing as music that causes the crash. Maybe there is something  
different in the internal structure of an ogg music file?

I am running Debian Linux (Etch) with stable deb packages fro SDL and  
SDL\_mixer.  
SDL 1.2.11-8  
SDL\_mixer 1.2.6-1.1+b2

and GNU compiler:  
GNU Make 3.81  
gcc (GCC) 4.1.2 20061115 (prerelease) (Debian 4.1.1-21)

Of course today I tried to fix the problem by compiling and installing newer versions of SDL\_mixer and libvorbis. No change at all after installing those.

jim

---

<div class="post-metadata">

**Author:** ![James\_Barrett](https://discourse.libsdl.org/letter_avatar_proxy/v4/letter/j/5f9b8f/32.png) [@James\_Barrett](https://discourse.libsdl.org/u/James_Barrett)\
**Post date:** [December 24, 2007, 1:28am UTC](https://discourse.libsdl.org/t/problems-loading-ogg-and-wav-music/15037/7 "2007-12-24T01:28:36Z")

</div>

Solra Bizna wrote:

> It’s been a while since I’ve used SDL\_Mixer, but when I did I used  
> both Ogg files and (if I remember correctly) a FastTracker module  
> without problems.  
> Can you get a backtrace from the crash? Without a backtrace, debugging  
> this will probably be impossible. It’d also be helpful to know what  
> platform you’re on and what compiler you’re using.  
> As for MikMod, it is specifically a library for loading tracker  
> modules. It itself can’t load formats like MP3 or Ogg (or WAV). For  
> more information, see the Wikipedia article on the subject:  
> [MOD (file format) - Wikipedia](http://en.wikipedia.org/wiki/MOD_(file_format))  
> -:sigma.SB
> 
> * * *

When I run my program from the command line I see another message after  
the program crashes. It says:  
Floating point exception

---

<div class="post-metadata">

**Author:** ![James\_Barrett](https://discourse.libsdl.org/letter_avatar_proxy/v4/letter/j/5f9b8f/32.png) [@James\_Barrett](https://discourse.libsdl.org/u/James_Barrett)\
**Post date:** [December 24, 2007, 1:47am UTC](https://discourse.libsdl.org/t/problems-loading-ogg-and-wav-music/15037/8 "2007-12-24T01:47:32Z")

</div>

I tried loading my ogg music file along with my other sound effects.  
The program no longer crashes, but the music does not play. Sound  
effects play just fine. Is there some reason why SDL\_mixer will play  
one ogg file and not another? Am I doing something wrong or is there  
a bug in SDL\_mixer?

James Barrett wrote:\> Update: I downloaded souce, built and installed SDL\_mixer v1.2.8. I

> don’t know if there are conflicts with this version and the version of  
> SDL I have installed.
> 
> I read in SDL\_mixer.h that this method /Mix\_LoadMUS\_RW() / loads “Ogg  
> and MikMod specific currently” So I tried loading the ogg music file  
> with these two lines. I do not know if I have this correct:  
> SDL\_RWops\* rw = SDL\_RWFromFile(p.resourceName.c\_str(), “rb”);  
> m = Mix\_LoadMUS\_RW( rw );
> 
> I don’t get an error (m is not null) so I assume that the file is being  
> load ok.
> 
> Both Mix\_FadeInMusic() and Mix\_PlayMusic() crash without returning.
> 
> Then, when attempting to load a wav music file with the above two lines  
> of code, Mix\_GetError() returns “Module format not recognized”
> 
> I don’t know what that means. I can’t find any documentation on it.
> 
> Jim
> 
> James Barrett wrote:
> 
> > Hi, I am trying to open an ogg file with Mix\_FadeInMusic(). I could not  
> > find an entry at [http://www.libsdl.org/cgi/docwiki.cgi/SDL\_5fmixer](http://www.libsdl.org/cgi/docwiki.cgi/SDL_5fmixer) for  
> > this function, so I looked in the SDL\_mixer.h file. I see Mix\_MusicType  
> > enum with a MUS\_OGG type so I assume that SDL\_mixer does support ogg  
> > music files. But the program crashes as soon as the call to  
> > Mix\_FadeInMusic() is made, and nothing after it. It never even gets to  
> > the next line that prints the Mix\_GetError() to stderr. So I’m not sure  
> > what I did wrong. No error is produced when I load the file with  
> > Mix\_LoadMUS() so I assume it is reading the file ok.
> > 
> > Then another problem occured. I exported the ogg file (with audacity)  
> > as a wav file, and now Mix\_LoadMUS() can’t load the file. Output from  
> > Mix\_GetError() is “Unable to load WAV file”.
> > 
> > I am running Debian Linux (Etch) with stable deb packages fro SDL and  
> > SDL\_mixer.  
> > SDL 1.2.11-8  
> > SDL\_mixer 1.2.6-1.1+b2
> > 
> > I am able to load and play ogg sound effects with Mix\_LoadWAV and  
> > Mix\_PlayChannel()
> > 
> > Jim

---

<div class="post-metadata">

**Author:** ![Solra\_Bizna](https://discourse.libsdl.org/letter_avatar_proxy/v4/letter/s/e19adc/32.png) [@Solra\_Bizna](https://discourse.libsdl.org/u/Solra_Bizna)\
**Post date:** [December 24, 2007, 9:06am UTC](https://discourse.libsdl.org/t/problems-loading-ogg-and-wav-music/15037/9 "2007-12-24T09:06:53Z")

</div>

What’s your CPU architecture?  
Also, if you have GDB installed, you can get a backtrace that way.  
On the command line, run “gdb path/to/your/program” and issue it the  
"run" command. When (if?) it crashes, you can use the "backtrace"  
command to get a backtrace. I don’t know where it is on Debian, but  
there’s probably a “gdb” package in the apt-get repository if you  
don’t have it.  
-:sigma.SB
