Adventure Game Studio | Forums

AGS Support => Beginners' Technical Questions => Topic started by: JLM_82 on Thu 10/06/2021 09:55:21

Title: How to play a music just after the previous song is ended?
Post by: JLM_82 on Thu 10/06/2021 09:55:21
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 Thu 10/06/2021 10:31:56
It should be something like this:

Code (ags) Select

aIntroMusic.Play(eAudioPriorityNormal, eOnce);
aMainMusic.PlayQueued(eAudioPriorityNormal, eRepeat);

Title: Re: How to play a music just after the previous song is ended?
Post by: Khris on Fri 11/06/2021 10:45:23
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 Mon 21/06/2021 16:16:02
Quote from: Khris on Fri 11/06/2021 10:45:23
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 Fri 25/06/2021 17:39:11
Take a look at the manual's section for SetGameOption (in Global functions (general section)).

Code (ags) Select
  SetGameOption(OPT_CROSSFADEMUSIC, 0); // turn off cross fading
  SetGameOption(OPT_CROSSFADEMUSIC, 1); // slow cross fading
                              // or 2, 3
  SetGameOption(OPT_CROSSFADEMUSIC, 4); // fast fading