Problem with audio channels

Started by Joe, Sun 03/04/2011 19:29:50

Previous topic - Next topic

Joe

I commented this in the AGS 3.2.1 thread

This is the situation.
I have an audio channel called fondo which is cotinuously playing music but at some point in the game I have this:

Code: ags

function room_FirstLoad(){
  AudioChannel *intr= aIntriga.Play();

  while(fondo.Volume>0){
    fondo.Volume-=2;
    Wait(1);
  }
  //Some animations

  while(intr.Volume>0){
    intr.Volume-=2;
    Wait(1);
  }
  while(fondo.Volume<100){
    fondo.Volume+=2;
    Wait(1);
  }
}


My purpose with this was start playing aIntriga, stop playing fondo's music slowly (crossfade). Make some animations with aIntiga as audio and then crossfade again. But those weren't my results...
They were: stop playing fondo's music, started the animations without any audio and when they finished fondo's volume rised up to 100 again.

NOTE: There are no any other audio playin which could be using any other audio channel, I mean the rest of channels should be free... I put a code line to test which channel was intr assigned:

Display("%d %d",fondo.ID, intr.ID);

And as I suspected I obtained the same channel.

I'm very frustrated with this because I don't know if i'm doing something wrong or not...
Copinstar © Oficial Site

monkey0506

#1
CJ said something as he closed the 3.2.1 thread, but you might not have caught it:

Quote from: Pumaman on Sun 03/04/2011 19:05:50Is "fondo" definitely still playing at the time? If it's a music channel (where only 1 simultaneous audioclip is allowed) then the new one would end up on the same channel as the old one.

The maximum number of channels is set in the "Types" portion of the "Audio" branch in the main project tree. I'll upload a screenshot to show you what I mean..

If the "MaxChannels" for your Music audio type is set to 1 (the default) then this is the reason your music is cancelling each other out and playing on the same channel.

Edit: I was able to upload the image:



You can change the MaxChannels from its default, but this is most probably why your code isn't working. If you try to play more AudioClips than a given audio type has channels to support, AGS will automatically stop playing the the track with the lowest priority. Since both of your tracks have the same priority and same type, they are cancelling each other out with only one available channel.

Joe

Oh god! Thanks!! That was the problem.
I feel quit stupid now :P
Copinstar © Oficial Site

monkey0506

No need to feel stupid, it was just something simple that you overlooked. As a matter of fact, the property right above MaxChannels, "Crossfade tracks", might be useful to you. You could even create a new audio type if you want to distinguish it against other music files. Happy to help you get it fixed though.

Joe

Ok thankyou very much for your well documented replies  :)
Copinstar © Oficial Site

SMF spam blocked by CleanTalk