Can't stop MIDIs looping...

Started by Rambutaan, Wed 04/02/2004 01:41:56

Previous topic - Next topic

Rambutaan

Hi all,

sorry to ask such a stupid question, but I've spent the whole day trying to fix the problem. It's most likely something I have (or haven't) done so I need any suggestions from anyone where I've gone wrong!

Problem: MIDI keeps looping and crashed game in one case

Attempted:

- Replacing custom MIDIs with MIDIs that came with demo. Still does same thing.

- Tried putting SetMusicRepeat(0); in the game_start function and it still repeats.

- Looked on forums, manual, tutorials and knowledge base and problem isn't reported.

I know that it shouldn't be doing this since I've tried the demo and the BlueGUI demo and BOTH have a MIDI playing from the intro room screen that continues on and finishes once it has been played once.

Maybe someone can suggest what I'm doing wrong? Thanks in advance,

Mark G

Jy

If all you say is true...
some MIDIs can't be stopped because when they were made they were made to loop.

Ishmael

#2
I have noticed that sometimes some commands in the game_start function are skipped... Try putting the SetMusicRepeat(0); line into the first room "Player enterts screen for the first time" interaction...

Or, this could have something to do with your MIDI card settings...
I used to make games but then I took an IRC in the knee.

<Calin> Ishmael looks awesome all the time
\( Ö)/ ¬(Ö ) | Ja minähän en keskellä kirkasta päivää lähden minnekään juoksentelemaan ilman housuja.

Rambutaan

#3
Thanks for the input fellas, but

(a) I doubt that it is because the MIDI is one that loops since the custom MIDIs I created myself and when I play it through WinAmp, it doesn't loop. Also, I then used MIDIs from Chris Jones's demo and the BlueGUI demo and both of those MIDIs do not loop during the game.

(b) Entering the SetMusicRepeat(0); command in each room I guess is a solution, but that would get rather tedious! Maybe there's something wrong with my MIDI card settings but does that explain why when I play some AGS demos and games, the MIDIs don't repeat and with mine they do?

==============================================================
[EDIT]: Okay, my apologies. I went back and tried those demos and seems thata I've been telling fibs about the two demos I was playing around with :). Demo Quest II DOES actually repeat the MIDI if you stay on the Main Menu screen and the BlueGUI demo actually has one minute of silence on the MIDI track at the end so that's why I thought that it wasn't repeating :P.

As you suggested, TK, I tried putting SetMusicRepeat(0); in the first room but it still doesn't work. Note that I have 4 intro screens (intro.crm, room2.crm, room3.crm, room4.crm) and they go in that order, with room4 being the main menu. Would having the play music0.*** by default have anything to do with it perhaps?

Regardless, there must be SOME way to stop the looping, or is this just a common trait with all AGS games (with the only stop-gap solution being to add a few minutes of silence on the end of a MIDI)?

Ishmael

You migth try ranaming the music to music1, and playing it through the "Play music on room load:" option in the room settings, and trying to work with the SetMusicRepeat(0); then...

Hmm.... Hmmmm....

Is there a SetMIDIRepeat command???
I used to make games but then I took an IRC in the knee.

<Calin> Ishmael looks awesome all the time
\( Ö)/ ¬(Ö ) | Ja minähän en keskellä kirkasta päivää lähden minnekään juoksentelemaan ilman housuja.

Rambutaan

I renamed the MIDI to Music1.mid and set intro.crm to load music 1 when loaded but still when it gets to the main menu it repeats the MIDI.

BTW TK, I was wondering --
When you've developed games, have you ever had this problem or do you just let the MIDIs repeat? Just curious.

Oh and there's no SetMIDIRepeat command as far as I can tell :(.

Scummbuddy

Most gamers will make the Midis to be able to repeat. It'd be hard to guess exactly how long someone would be in a room.
- Oh great, I'm stuck in colonial times, tentacles are taking over the world, and now the toilets backing up.
- No, I mean it's really STUCK. Like adventure-game stuck.
-Hoagie from DOTT

Rambutaan

#7
In other words, I just have to live with it? :P

I guess it shouldn't be that much of a problem :).

Oh and love the quote... DOTT was a classic :)
===================================

Oh also word of advice to people using KBPiano to make MIDIs -- DON'T.

The MIDIs sounded shocking when they played the second time round in AGS. Anvil does fine (should've downloaded it earlier :/ )

Ishmael

I've always let'd 'em loop... I once tried to get it not to loop, but I have dropped the game since, and don't remember anymore what I had done.. I may have it on my old AGS forlder still...

But, thinking of it, if you use the music1.mid file for the music, could you do something like:

if (GetMIDIPosition() == x) { // where x is around the end of the midi file, put pauses in there so you can get to it.. I don't remember if GetMIDIPosition takes a parameter, check the manual if this don't compile
StopMusic(); // or whatever the command is...
}

(I'm still not on my own computer...)

I was just wondering if this could do it... I used a similiar code to get a midi with a start and an end to loop properly... and it worked fine, I just used SetMIDIPosition instead of StopMusic to loop back to the right spot, from just before the end of the midi.
I used to make games but then I took an IRC in the knee.

<Calin> Ishmael looks awesome all the time
\( Ö)/ ¬(Ö ) | Ja minähän en keskellä kirkasta päivää lähden minnekään juoksentelemaan ilman housuja.

Rambutaan

I'm not too fussed about it anymore, but thanks for your input anyway :). I'll try those suggestions out in case my MIDIs DO get too repetitive :P.

modgeulator

Have you tried a PlayMusicQueued() instead of a PlayMusic()? Never know, it might just work.

Ishmael

#11
I think I found the cause for your problem with the repeating...

From the manual:



SetMusicRepeat
SetMusicRepeat (int loopflag)

Tells the system whether to repeat background music tracks. LOOPFLAG is either 1 (repeat, default) or 0 (don't repeat).
This function must be called BEFORE PlayMusic - it sets whether future music tracks will repeat or not.

Example:

SetMusicRepeat(1);

will loop the background music.



So, don't use the "Play music on room load:" thing in the editor, instead do, in the "Player Enters screen (before fadein)" interaction:

SetMusicRepeat(0);
PlayMusic(#);

And, in the "Player leaves screen" interaction, in case you want other midis to repeat,

SetMusicRepeat(1);
I used to make games but then I took an IRC in the knee.

<Calin> Ishmael looks awesome all the time
\( Ö)/ ¬(Ö ) | Ja minähän en keskellä kirkasta päivää lähden minnekään juoksentelemaan ilman housuja.

SMF spam blocked by CleanTalk