Problems loading ogg and wav music

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 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

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 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


Ham it up! kb1odg

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”

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

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:


-: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()?

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:
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

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:
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

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 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

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