[Solved] Cross-fade Music or Sounds

Started by Stew, Mon 10/02/2014 11:20:18

Previous topic - Next topic

Stew

Hi everyone,
I'm trying to realize a music cross-fade.
I have two music tracks: aMusic01 and aMusic02.

I tried to do it in the following way:

1) Start the first track:

AudioChannel* CHAN = aMusic01.Play(eAudioPriorityNormal, eRepeat);
CHAN.Volume = 100;

2) Some scripts (not important)

3) Cross-fade between aMusic01 and aMusic02:

AudioChannel* CHAN2 = aMusic02.Play(eAudioPriorityNormal, eRepeat);
CHAN2.Volume = 0;
        int VOLUME1 = CHAN.Volume;
        int VOLUME2 = CHAN2.Volume;
        while (VOLUME1 > 0)
         {
         VOLUME1 = VOLUME1 - 5;
         VOLUME2 = VOLUME2 + 5;
         CHAN.Volume = VOLUME1;
         CHAN2.Volume = VOLUME2;
         Wait(1);
         }

The problem is:
This script doesn't work if aMusic01 and aMusic02 are inside the AGS "MUSIC" folder.
It works only if the tracks are in the AGS "SOUNDS" folder.
Why?
If this works only with the "sounds" folder, why don't use only sounds folder? Why is there the Music folder?
What exactly is the difference between those two folders?

Thank you.

geork

Hello Stew!

It's probably because the Max Channels property for the Music audio type is set to 1. Therefore, you can only have one music track playing at any one time.

On the right-hand pane, go to Audio->Types->Music, and in the properties pane change the 'Max Channels' value.

Hope that helps!

Stew

Yesss!
It was so easy!
I was thinking about a Scripting mistake!

Thank you geork!
It works perfectly!

Adeel

In my opinion, an easier way to cross-fade your tracks is to use editor's built-in feature. That way, you may simply just assign a new track to your audio channel and it'll automatically cross-fade the way you've set it up. However, to acquire more control on cross-fading, scripting is the only way to go:

Spoiler

Feel free to disregard this post, if you already know this. :)

Stew

Oh!
I discovered now that function!!!
Thanks Adeel.

Rik Vargard

So yeah I'm sorry to dust off this one, but this is the closest I got in my investigation on how to crossfade music.
Because of the music channels thing in the previous posts.

Right now, my script goes as this :

Code: ags

start_chan2 = aIntro1.Play();
// Blah blah blah scripting and then :

start_chan = aIntro03.Play();
start_chan.Volume = 0;
while(start_chan2.Volume > 0){
start_chan2.Volume -=1;
start_chan.Volume +=1;
Wait(1);
         }


So this is a test mainly based on the posts above.

Now: In the posts above, there's that one where geork talks about audio channels that makes me understand that it is possible to have two audio channels to "play at the same time".
But if I right-click on Music > properties in the right menu, and even if I go to the global properties, I can't find how to have that "more than one audio channel"

So, is there another way now to do that in version 3.5.0 ?

Thx!

Cassiebsg

In Explore Project->Audio->Types->Music

Now on the Property panes you can define the MaxChannels and Crossfade tracks.

(you can also see it in Adeel's image posted right above yours.)
Hope it helps.  ;)
There are those who believe that life here began out there...

Rik Vargard

Aaaahhh it's in "types" !

So I guess this Was solved, I just didn't get it.

Sorry for that and thank you very much for your reply! :)

SMF spam blocked by CleanTalk