Music loop suggestion

Started by Mats Berglinn, Thu 15/04/2004 20:49:06

Previous topic - Next topic

Mats Berglinn

I know that you can make the music loop in rooms but it's not that CD repeat thing where the music plays from beginning to end and then start over again. It's about looping the music so that it begins when you enter a room but the music seems to play forever as long as you are in that particular room. For example: If you play a company-made game like Grim Fandango and listen to the music in a room, notice that the music does begin but it keeps on playing without any stops and replay. In AGS-games and in the CD-ROM version of Secret of Monkey Island, the music does start, go on, then end and the music starts again.

I think that the music will be appreciated in a better way if the music just keeps on going and going and going and going instead of that play, stop, replay, stop, replay thing.

Doesn't that sound like a good idea?  


Rui 'Trovatore' Pires

#1
And while we're at it - what are the chances of AGS having a sound system similar to iMUSE? Not that it's actually necessary since we can do with cross-fading, just curious.

EDIT - Nevermind, it can probably be done with GetMIDIPosition and a lot of scripting, it's probably possible.
Reach for the moon. Even if you miss, you'll land among the stars.

Kneel. Now.

Never throw chicken at a Leprechaun.

strazer

#2
QuoteDoesn't that sound like a good idea?

I don't know what you're trying to suggest.
If you're talking about digital music, it's up to you to format the music correctly, then you could try

SetMusicRepeat(0); // turn off music looping
PlayMusic(1); // play intro of music track
SetMusicRepeat(1); // turn on music looping
PlayMusicQueued(2); // play looping part of music track

Doesn't work with crossfading enabled, of course.

The transition between the two parts wasn't perfectly smooth in my tests, but I guess that's a matter of finding the right position within the music track (silence preferably).

EDIT: Thanks for the correction CJ, I actually used PlayMusicQueued in my tests.

Bryan

I'm pretty sure the looping you propose is possible.  Something like this code in the room repeatedly execute
Code: ags

if (GetMIDIPosition() == LAST_BEAT_OF_SECTION) {
     SeekMIDIPosition(FIRST_BEAT_OF_SECTION);
}


Or similiarly Get/SeekMP3PosMillis
this space intentionally left blank

Pumaman

If you have a lead-in intro to the tune, and then you want the rest of it to repeat, you can split it in two and use strazer's suggestion, slightly modified:

SetMusicRepeat(0); // turn off music looping
PlayMusic(1); // play intro of music track
SetMusicRepeat(1); // turn on music looping
PlayMusicQueued(2); // play looping part of music track

Adamski

An iMUSE like system is possible to do most definatly with digital music because I've got something similar scripted for my upcoming game. It's just a little tricky to work out streamlined code to do exactly what you want, especially with looping different parts of the track (I might need to bug you at some point CJ to add or edit an existing function for me regarding this :P)

Pumaman

Hehe :P

Also, I forgot to say but scripting it yourself is easier now with the new repeatedly_execute_always since you can always adjust the volume and your script isn't interrupted by blocking cutscenes.

modgeulator

#7
Did anyone notice the music in Razors in the Night? I tried to make the music as interactive as possible with AGS. I was fairly proud of it on a technical level, even if no-one actually seemed to pay any attention or like it.

The usefull code bits:

Instantly switch to another track at the same position:
    iPos=GetMIDIPosition();
    StopMusic();
    PlayMusicQueued(24);
    SeekMIDIPosition(iPos);

Looping music with an intro. Need two tracks, one with the intro, one with the main loop. This can also easily be adapted to create endings and transitions. This is used in Razors for the little drum fill intro that plays whenever the street music starts.
      StopMusic();
      SetMusicRepeat(0);
      PlayMusic(50);
      SetMusicRepeat(1);
      PlayMusicQueued(51);

Beyond that it's just using a lot of "if (GetCurrentMusic==X)" type code to make things smarter. I'll post the full source code if anyone's interested.

EDIT: About iMuse, from what I understand it isn't just about music playback - it's a complete sequencer / audio program, something a bit like Microsoft's DirectMusic. To get truly interactive music in AGS games, maybe a DirectMusic plug-in would be the best way to go.

..

Could you not just make the midi so it has an ending that leads into the beggining?

SMF spam blocked by CleanTalk