SDL_Mixer help

I am a little puzzled with a program I am working on. As the title implies,
I am using SDL. My problem is with playing music files. I have animation,
sounds, input, and collision detection all working fine. The sounds are also
using SDL_Mixer.

What happens is the music file loads fine (I have tried midi, mp3, ogg, and
wav) but only plays the first second and then repeats indefinitely. If I put
a call to SDL_Delay(xxxx) in there the music plays for the duration of the
delay without a problem.

There is way too much code to post but the initialization for the music is
straight out of the documentation. I don’t think the problem is with the
mixer library since it works when I have the delay in there. Any ideas what
else it could be?

Oh, and putting the call to Mix_PlayMusic() in different locations of the
program, ie. in the game loop, in the message pump, all have the same
result. Thanks for any help._________________________________________________________________
Get today’s hot entertainment gossip http://movies.msn.com/movies/hotgossip

Just a guess, but it seems your main program is eating all the CPU and
your audio mixer subsystem can’t get a moment to update the buffer. Try
adding SDL_Delay(10) to each iteration of your main loop and see if that
gives it the time it needs.On Mon, Sep 25, 2006 at 04:46:52PM -0400, Steven Bradley wrote:

I am a little puzzled with a program I am working on. As the title implies,
I am using SDL. My problem is with playing music files. I have animation,
sounds, input, and collision detection all working fine. The sounds are also
using SDL_Mixer.

What happens is the music file loads fine (I have tried midi, mp3, ogg, and
wav) but only plays the first second and then repeats indefinitely. If I put
a call to SDL_Delay(xxxx) in there the music plays for the duration of the
delay without a problem.


Steaphan Greene
Lecturer, Computer Science, Binghamton University
GPG public key: http://www.cs.binghamton.edu/~sgreene/gpg.key.txt
-------------- next part --------------
A non-text attachment was scrubbed…
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: Digital signature
URL: http://lists.libsdl.org/pipermail/sdl-libsdl.org/attachments/20060925/928ebda5/attachment.pgp

I have a small game I’ve been working on and when I load and play the music,
a midi file, only the left speaker plays. I also have sound fx going and it
is working fine in both speakers. I haven’t set any panning for the music
and have used exactly what it in the mixer doc examples. Any ideas what it
could be or anyone know of a similar problem?

Mix_AllocateChannels(32);
Mix_Volume(-1,MIX_MAX_VOLUME/2);
tempsound = Mix_LoadWAV_RW(SDL_RWFromFile(“data\temp.wav”, “rb”), 1);
if(!tempsound)
{
printf(“Mix_LoadWAV_RW: %s\n”, Mix_GetError());
}

music = Mix_LoadMUS(“data\1.mid”);
if(!music)
{
printf(“cant load: %s\n”, Mix_GetError());
// this might be a critical error…
}

and

if(Mix_PlayMusic(music, -1)==-1)
{
// printf(“Mix_PlayMusic: %s\n”, Mix_GetError());
// well, there’s no music, but most games don’t break without music…
}_________________________________________________________________
Get today’s hot entertainment gossip http://movies.msn.com/movies/hotgossip

Hello Steven,

Wednesday, October 4, 2006, 11:56:20 PM, you wrote:

I have a small game I’ve been working on and when I load and play the music,
a midi file, only the left speaker plays. I also have sound fx going and it
is working fine in both speakers. I haven’t set any panning for the music
and have used exactly what it in the mixer doc examples. Any ideas what it
could be or anyone know of a similar problem?

What platform?

If it is Windows, check your Volume Control settings as I think
SDL_mixer plays MIDI using the Windows MIDI system.

Why MIDI anyway? It’ll sound different on everyones machine. Get a
good softsynth and render it to a Vorbis file.–
Best regards,
Peter mailto:@Peter_Mulholland

Thanks for the response. I converted my file to OGG and it worked. I don’t
understand what was going on though. Oh, yes I’m using Windows. I could play
the midi file stand alone and it worked fine. It was only in the program
that it played only the left speaker. Checking the audio controls showed
that it was modifying the settings but I don’t know why.

Anyway, thanks. I guess I’ll be using OGG from now on._________________________________________________________________
Express yourself - download free Windows Live Messenger themes!
http://clk.atdmt.com/MSN/go/msnnkwme0020000001msn/direct/01/?href=http://imagine-msn.com/themes/vibe/default.aspx?locale=en-us&source=hmtagline