Adventure Game Studio | Forums

AGS Support => Beginners' Technical Questions => Topic started by: JLM_82 on 10 Jun 2021, 09:55

Title: How to play a music just after the previous song is ended?
Post by: JLM_82 on 10 Jun 2021, 09:55
Hi,

Let's assume there is a room in the game that has so-called intro-music that is played, when the player enters to the room. When the intro-music is ended, the "main" music starts and loops as long as the player is in the room.

Is there a useful way in AGS to implement this kind of functionality? To check, if "previous" music is ended, and just then start the new one, and let it loop, until the player leaves the room?
Title: Re: How to play a music just after the previous song is ended?
Post by: Vincent on 10 Jun 2021, 10:31
It should be something like this:

Code: Adventure Game Studio
  1. aIntroMusic.Play(eAudioPriorityNormal, eOnce);
  2. aMainMusic.PlayQueued(eAudioPriorityNormal, eRepeat);
Title: Re: How to play a music just after the previous song is ended?
Post by: Khris on 11 Jun 2021, 10:45
Correct, however this will only work as expected if there's only one channel available for the sound type. That might be the default for music anyway, just thought I'd point it out.
Title: Re: How to play a music just after the previous song is ended?
Post by: Trumgottist on 21 Jun 2021, 16:16
Correct, however this will only work as expected if there's only one channel available for the sound type. That might be the default for music anyway, just thought I'd point it out.
Does this mean that this sort of thing is not possible to setup if you want more than one music channel? I'm assuming that is a setting that can't be changed while running the game.

I have found the "crossfade tracks" setting in the audio properties. That would possibly solve that problem (since transitions are the main thing I imagine I'd want to use multiple music channels for), but only if it can be toggled by a script, and I haven't found how to do that. Is that possible? I want to crossfade the music in general, but I also want the ability to do a hard cut between scenes.
Title: Re: How to play a music just after the previous song is ended?
Post by: Khris on 25 Jun 2021, 17:39
Take a look at the manual's section for SetGameOption (in Global functions (general section)).

Code: Adventure Game Studio
  1.   SetGameOption(OPT_CROSSFADEMUSIC, 0); // turn off cross fading
  2.   SetGameOption(OPT_CROSSFADEMUSIC, 1); // slow cross fading
  3.                               // or 2, 3
  4.   SetGameOption(OPT_CROSSFADEMUSIC, 4); // fast fading