Sound Crashing


zacaj

void main()
Joined
Apr 3, 2007
Messages
362
Age
29
Location
NY
Website
zacaj.com
Im using the version of SDL_Mixer that came with the HW accellerated SDL, and randomly, the sound disappears, and its also very quiet, even when I have the volume up the SDL_Mixer's Max, 128. Mix_GetError() doesnt return anything.
Im loading my music file like this
CODE
music[0] = Mix_LoadMUS("music1.ogg");

and initiallizing SDL_Mixer like this:CODE
Mix_OpenAudio(MIX_DEFAULT_FREQUENCY, AUDIO_S16, MIX_DEFAULT_CHANNELS, 128);

Ive also tried
CODE
Mix_OpenAudio(MIX_DEFAULT_FREQUENCY, AUDIO_S16, MIX_DEFAULT_CHANNELS, 256);

I initialize SDL like this:CODE

SDL_Init( SDL_INIT_JOYSTICK | SDL_INIT_VIDEO | SDL_INIT_AUDIO | SDL_INIT_TIMER);
SDL_WM_SetCaption( "Bloxz", 0 );
screen=SDL_SetVideoMode(320,240,16,SDL_HWSURFACE | SDL_DOUBLEBUF);
Enable940();
joy=SDL_JoystickOpen(0);
TTF_Init();
font = TTF_OpenFont("font.ttf", 12);
SDL_ShowCursor(SDL_DISABLE);

And I play music like this: CODE
Mix_HaltMusic();
Mix_PlayMusic(music[rand()%musnum], -1);

I play my single sound effect like this:CODE
Mix_HaltChannel(channel);
channel=Mix_PlayChannel(-1,bomb,0);

Also, the screen sometimes flickers when I play the sound effect.
What am I doing wrong?
 
zacaj said:
Im using the version of SDL_Mixer that came with the HW accellerated SDL, and randomly, the sound disappears, and its also very quiet, even when I have the volume up the SDL_Mixer's Max, 128. Mix_GetError() doesnt return anything.
Im loading my music file like this

Also, the screen sometimes flickers when I play the sound effect.
What am I doing wrong?
That sounds like a hardware problem, as if maybe you had a set of NiMH batteries that were wearing out. Do you have an AC adapter to try out or have you already done so?

You might also try adjusting the volume using /dev/mixer, which is more reliable in my opinion:
http://www.gp32x.de/board/index.php?showtopic=40529

Also: what's Enable940()?
 
Last edited by a moderator:
Ill try the AC Adapter, and /dev/mixer
Enable940 is part of SDL2X, which I used Enable940 from, although Ive forgotten why..
 
Removing Enable940 and using an AC Adapter stopped most of the sound crashing, but even using /dev/mixer, I still cant get it to be much louder
 
Somewhere after initializing sound in the program you want to call this function:

Mix_Volume(-1, MIX_MAX_VOLUME);

where MIX_MAX_VOLUME should actually probably be changed later to something more reasonable, something maybe halfway between 0-128. Then, to adjust the volume you actually use the routines I linked to that adjust the master mixer, /dev/mixer between 0-100.

-1 means adjust volume on all channels.

You can also try calling Mix_VolumeMusic(VOLUME);

Where VOLUME is between 0-128
 
Ive found it works fine if I dont use gmenu2X at all... Does anyone know why?
 
zacaj said:
Ive found it works fine if I dont use gmenu2X at all... Does anyone know why?
Gmenu2x can control volume, did you set the volume to something other than -1 for the shortcut file?
 
Last edited by a moderator:
No, however its almost full volume if I set it to 100, although the sound has started crashing less frequently again
 
Back
Top