Looping music

Started by CodeJunkie, Sun 08/08/2004 21:02:31

Previous topic - Next topic

CodeJunkie

I have a MIDI file that I want to loop in my game, however it won't loop.  I've tried using  SetMusicRepeat(1); in various places - the game_start function in the global script, on entry of the menu 'room', the first time the first playable room is loaded.  The MIDI I want to loop begins in the first playable room, but I've tried setting that as an adjacent room.  I did once get it to repeat in the adjacent room, however after some more experimenting I tried to recreate this and couldn't get it working again.
I've noticed that some script functions seem to take 'time' or something.  In another circumstance I found that SetWalkableArea wouldn't toggle a walkable area when it was in the same script as the action, or even in the same conditional block.
I've also tried making a repeating if loop in the repeatedly_execute function.  I'm not sure if that should work, but it didn't, and it might've crashed the game, I can't remember.
When I put the SetMusicRepeat(1) in the game_start function it makes that game crash after a few seconds of wandering, and also putting PlayMusic in a room script.  By 'crashing' I mean that the game closes and a pop-up box says that the game didn't shut down properly.  I've tested several times and each time it crashes.  Maybe it's coincidence, but I don't understand why it does that.
I noticed that in the help manual that the value of 1 on SetMusicRepeat is also default, however even without this line in the script there is still no repitition.
Thanks,
-Sim

Radiant

The common method is, SetMusicRepeat (1) then PlayMusic (42).
I tend to put it in enter_room (before fadein), or possibly in game_start.
Some commands only are scheduled by the script, and are executed either when you Wait(1) or when the script finishes (the latter category mostly includes NewRoom and CallRoomScript)

Putting this in rep_ex(_al) also works:
if (IsMusicPlaying () == 0) PlayMusic (42)

My guess is that your midi file is invalid? Or maybe the crash is caused by something else, or your directsound is setup improperly.

CodeJunkie

Nothing worked for me, I tried all sorts of combinations and the ones you suggested.  Then I tried another piece of music and it looped fine  :-\
The piece I was going to use wouldn't even open in Evolution Audio Lite (the music program I originally created in).  I found out that that was because another program I used to change the tempo afterwards made it completely unreadable.  Luckily I had some backups with an old copy of the tune though.
So I've found out what's wrong.  And remember - don't use MIDIStudio unless you're prepared to have a corrupt MIDI.
Thanks though Radiant :)

SMF spam blocked by CleanTalk