SDL_Mixer can't switch MIDI files

I’m working on a game engine that needs to be able to support background music of all sorts of different formats, including MIDI. That’s one of the things that got me interested in SDL: it supports just about anything and everything. But I can’t seem to switch BGM from one MIDI file to another.

I’m coding this in Delphi, under Win32, using the JEDI-SDL headers. Here’s the SDL commands that get executed when I try to switch BGMs:

Mix_HookMusicFinished(nil);
Mix_FadeOutMusic(1500);
SDL_Delay(1500);
Mix_HaltMusic;
Mix_VolumeMusic(128);
Mix_FreeMusic(currentSong);
Mix_LoadMUS(newFileName); //verified: loads successfully
if ( Mix_PlayingMusic = 0 ) then //verified: returns 0
(Mix_PlayMusic(newSong, 1));
Mix_HookMusicFinished( @FMusicFinishedEvent );

If I step through this one step at a time in Delphi’s debugger, sometimes it plays normally. But when trying to do it in real time, I hear silence. After the correct amount of time for the song to play, the callback function set up in the last line gets called, but… no sound ever comes out.

Trying to switch back to the song that was playing before works just fine. So does trying to play some different format (MP3, for example) for the second song. But trying to go from one MIDI to another doesn’t work. Any help?

(BTW, to whoever fixed the SDL_Mixer bug where MIDI would only come out the left speaker and not the right: Thanks! Would you mind taking a look at this other one?)