Page 1 of 2

Bug report: Predictive loading / MIDI

Posted: Mon Oct 04, 2004 4:24 am
by Alessio
Started some more serious scripting on the weekend and came up with the following issues (either bugs or then the "stupid user syndrome"...):

Predictive image loading might have a (very minor) problem: If a script has statement $ renpy.quit() and less than 10 command lines follow, the game breaks off saying it can't predict the loading. If you attach 10+ dummy lines to the script, it works.

Every time a new midi file starts playing, the MS Windows soundcard mixer is initialized (panning full left/full volume). Not on the midi channels themselves, but really at OS level. Is there maybe some pygame function initializing this by default? I'd rather let the players keep their mixer settings of course, but if that's not possible, at least the panning should be dead center. No idea if it's a general problem or only in Win2000.

Posted: Mon Oct 04, 2004 2:34 pm
by PyTom
I have been unable to reproduce either problem using trival variants of the test game that I've been using. If you could email me over a game directory that demonstrates the problem, it would help me to go in and make a fix.

Also, the traceback.txt could also help.


Posted: Tue Oct 05, 2004 1:49 am
by Alessio
OK, I'll do that. I'm on a tight working schedule during the week, but I'll make an example and post it here as soon as I manage. Cheers!

Posted: Mon Oct 18, 2004 9:48 am
by PyTom
Okay, thanks to Alessio, I've tracked down the bug in predictive image loading. It only manifests when config.debug is True, but it will affect every script where that is the case. I'm somewhat embarassed that my testing didn't catch this one.

I have a fix, which will go into the next version of Ren'Py when I get around to releasing it. In the meantime, the bug can be worked around by making:

Code: Select all

The last line of every script file. (Or just don't set config.debug to True.)

Posted: Tue Oct 19, 2004 1:33 am
by Alessio
That was quick! Cheers! (No need to be embarrassed -- haven't caught any other bug yet, that's impressive.)

Posted: Thu Dec 09, 2004 11:59 pm
by Tage
Unfortunately, I have the same MIDI problem. =| Also, unfortunately, there really isn't much one can report on a problem like this. I am running "Windows XP Professional: SP2" with an "ESS Solo-1 PCI AudioDrive" sound card.

What I have figured out is...

If I set MIDI playback in my sound card's properties to be handled by the sound card's driver, the problem does not come up. The problem arises when I set "Microsoft GS Wavetable SW Synth" to handle the the MIDI playback.

Also, after music starts playing and the problem arises, I have set it back to center in speakers, but when it repeated because I had it on a loop, it set it back to left speaker...

Whether those are helpful or not... beats me, lol.

Posted: Thu Dec 30, 2004 5:44 am
by Naraku
I am guessing that might be an OS problem.
Said problem does not show up on Windows ME.

Posted: Fri Dec 31, 2004 4:06 am
by Alessio
I'm running Win2000 SP4 on a Dell Latitude, which has a built-in Microsoft/Roland Sound Canvas Wavetable Synth. That's the only available option in MIDI playback in my sound card's properties, no way to switch it.

Just odd that no other program using MIDI runs into this problem. I don't think it's a RenPy issue, it's probably more Python-related.

Posted: Sat Jan 01, 2005 12:28 pm
by Naraku
Sounds like you got a bad deal.
You might want to invest in a Soundblaster sound card
be carefull though putting it in, only handle the card by
its edges and make sure the computer is unpluged
when you work on it, dont forget to make sure you
have no static electricity, one spark can ruin a computer.
Gently install the card with a front to back rocking motion
never force the card, if it doesn't fit it doesn't go in that
slot, and lastly dont forget to remove the old sound card
if there is one. Some mainboards like the one I am useing
have built in sound, in which case the computer should
automaticly disable the built in sound when the new
sound card is detected.

Posted: Sat Jan 01, 2005 12:39 pm
by Alessio
Thanks Naraku - but actually I have a full-fledged MIDI studio at home with a dedicated PC, so on-board MIDI is not an issue really. :-) The MIDI problems I described occur on my laptop.

I'm not worried about myself. What I am worried about is that people who play my game may run into the same problem, and that is definitely a big minus in the gaming experience (full volume panned hard left is not fun with headphones, I can assure you...).

So it seems we should avoid MIDI sound, since it may be problematic on some systems. Pity, MIDI files are really small and flexible, really good for long background music.

Posted: Sat Jan 01, 2005 4:49 pm
by PyTom
If I can get some volunteers who have the bug and are willing to run some test scripts to help me fix it, I'll try having another go at squashing this bug.

Until then, the current OfficialBestPractice (tm) is to use mp3 music where possible. Of course, it would be nice if I did this in the demo.

Posted: Sat Jan 01, 2005 5:07 pm
by PyTom
Okay, the first experiment for fixing the midi bug is to upgrade SDL_mixer, and hope that that fixes it. Your mission, should you choose to accept it:

1) Confirm you still have the midi playing bug.

2) Download the new version of SDL_mixer from: ...

3) Unzip that file, to reveal SDL_mixer.dll

4) Copy that file into the lib directory of Ren'Py 4.4. You may want to make a backup copy of the SDL_mixer.dll that's already in that directory.

5) Play the demo, with music. Did the problem go away? I'm guessing this can't hurt, much.

If you could report the results, I'd appreciate it.

Posted: Sat Jan 01, 2005 11:25 pm
by Tage
It ALMOST completely fixed the problem. The sound no longer pans to the left speaker, BUT the sound still blasts to full MIDI volume. And again, it only happens when MIDIs are being handled by the Microsoft GS Wavetable SW Synth...but that probably won't help since it's obviously outside of your hands to fix...At least it doesn't pan to the left anymore, blasting to full MIDI volume is a lot easier to bare with.

Posted: Sun Jan 02, 2005 12:06 am
by PyTom
Well, fixing the panning problem is nice. Now to see if I can figure out where the volume is being set by SDL_mixer, and if there's a way I can avoid/control that.

Posted: Sun Jan 02, 2005 2:54 am
by PyTom
Hm... I've tracked the bug down to a bug in SDL_mixer, which is kinda caused by the way sound works on windows. The problem comes in when SDL_mixer tries to set a volume for a midi file. It's setting the windows mixer directly (to the default of full blast), rather than scaling it to the user's settings.

It's somewhat annoying, since I don't have good access to the user's old midi volume. But hey, since when was life easy?

The good news is I can now reproduce the bug on my (virtual) windows box.