Sdl_mixer -mikmod Related Question


joyrider

Member
Joined
Mar 29, 2006
Messages
589
Age
41
Website
www.willemssoft.Be
I'm using mod files as my music files and for some strange reason i have to set the volume of the music everytime after the mod file starts playing (mix_playmusic). when i use ogg files i just can call the setvolume function once and it stays the exact same volume but with mods it doesn't it keeps reverting back to max volume when the music starts playing again / loops. even when calling mix_playmusic(musix,-1) it will play it once at the set volume and then revert back. Pretty weird ...

anyway i found a way around it by using the mix_hookmusicfinished and a callback function for it where i start the music again and also set the volume (so i'm using mix_playmusic(musix,0) to play it once).
anyway this seems to work like a charm however am i bit concerned

when looking up the mix_hookmusicfinished function on google i found numerous pages where they said that it's a bad idea to call sdl_mixer functions from within a callback function see here :http://jonatkins.org/SDL_mixer/SDL_mixer_63.html or here : http://jcatki.no-ip.org/SDL_mixer/SDL_mixer.html#SEC5
(just what i'm doing now to fix the issue).

does anyone have a clue why this is a bad idea ? cause it does seem to work without any problems as far as i can tell. and it's the only way i can think of to fix that volume problem when looping the music.

found a way around it could have used just a boolean flag and restarted the music somewhere else outside the callback.

however i think it still isn't normal that u have to call the volume function each time the music starts playing again and that it will only play it at the specified volume during the first loop when calling mix_playmusic(music,-1) (-1 for looping)

when using ogg's this problem doesn't even exist
 

Parkydr

Developing for the GP2X since 2006
Joined
Dec 3, 2005
Messages
1,357
Website
www.parkydr.ezeedsl.co.uk
I've had this problem with freedroid for along time but have never got to the bottom of it. I'll try it - I don't care if it is a bad idea if it works.
 

joyrider

Member
Joined
Mar 29, 2006
Messages
589
Age
41
Website
www.willemssoft.Be
I've decided to try converting the mods to oggs - the files are a hell of a lot bigger though :(

yeah it's the last time i'm using mods as well to much of an hassle for simple things, i've got it working now doh but it's an ugly way to get it working which i don't like.

plus there's a big performance hit when using mod's sometimes the music start to stutter or can't follow. if i had noticed this in the beginning i'd never used mod's oh well guess people have to live with it it's either somewhat crappy mod playback with some weird issues or big file sizes.

Thing i'm goana do next time is include 1 ogg music file and make it so that people can put more ogg's in the music directory themselves
 
Last edited by a moderator:
Top