Sdl_mixer Volume Going To Top Volume By Itself


Alex.

Retired
Joined
Aug 24, 2005
Messages
4,616
I have the following function being called at every game loop, to set the sound volume of the SDL mixer music:

Code:
#define VOLUME_STEP 2

void adjustVolume(void)
{
	int volume = status.volume;

	SDL_JoystickUpdate();

	buttons.volup = SDL_JoystickGetButton(joystick, GP2X_BUTTON_VOLUP);
	buttons.voldown = SDL_JoystickGetButton(joystick, GP2X_BUTTON_VOLDOWN);

	if(buttons.volup) {
		status.volume += VOLUME_STEP;
		if(status.volume > MIX_MAX_VOLUME) status.volume = MIX_MAX_VOLUME;
	}
	if(buttons.voldown) {
		status.volume -= VOLUME_STEP;
		if(status.volume < 0) status.volume = 0;
	}

	if(status.volume != volume) Mix_VolumeMusic(status.volume);
}

The volume control works flawlessly, I even have a printout of it on the screen, and it ranges from 0 to 128. However, after 1 or 2 minutes of game play, the music volume goes all the way to the top, by itself - the variable holding the volume didn't change, as it still displays the same number on the screen that it displayed before going up. When I press the volup or voldown buttons, the music volume changes back to its respective size.

I'm really confused, as this happens even if I don't press any keys at all :(

- Alex
 
Yes, I'm using mod files... there's always some little quirk I have no control over, isn't there. I'm so tired and stressed out, this is the last thing I want to deal with.

Any ideas on how to convert .it modules files to OGG on windows XP? All I see is dodgy commercial software. Also, how big is the toll on performance when using OGG instead of IT with SDL_mixer?

Thanks a lot Parkydr!

- Alex
 
I used XMMS on Linux, but mp3s work as well, hopefully you'll have more luck finding an it to mp3 converter.

I didn't notice a performance hit, but the ogg files are a lot bigger.
 
I used Modplug Tracker to convert them to MP3, then Audacity to convert the MP3s to OGG. OGGs end up 7 times bigger than the tracker files, while MP3s are only 4.5 bigger. I tested the OGGs and they work flawlessly without any performance hit, and I'll go ahead and test the MP3s as well :)

- Alex
 
Back
Top