Adventure Game Studio

AGS Support => Advanced Technical Forum => Topic started by: mitlark on Thu 27/02/2014 04:53:26

Title: Crossfading limitations
Post by: mitlark on Thu 27/02/2014 04:53:26
Hello! This is not a ground breaking issue, but more of an inquirity with a thing that I've observed.

Thing is like this. I wanted to control separately volume for SFX (normal sounds), ambient sounds and music. So I did this little audio playing helper
int playAudio(AudioClip *audio, int repeat){
int vol=100;
AudioChannel *channel;
if (audio.Type == eAudioTypeAmbientSound) vol = AmbientVolume;
else if (audio.Type == eAudioTypeMusic) vol = MusicVolume;
else if (audio.Type == eAudioTypeSound) vol = SFXVolume;
channel = audio.Play(eAudioPriorityNormal, repeat);
channel.Volume = vol;
}
It adjusts volume to the resulting channel depending on the audio type. That works fine.

But crossfading screws it up completely. Let's say, music crossfades, it automatically resets volume and crossfades from 0 to 100, so changing volume before playing the audio file is pretty much worthless.

Question is, is there a workaround for this? Ideas?
There is the option to define an auxiliary Audio Type named "crossfading music" and do the crossfade manually when needed, but I assume it should be more costy for the engine. And nasty (?).

Anyway, I'm not in a hurry, by now crossfade is off, but I really like the effect. So for that, I just ask in case someone here knows something I don't. Because "communityKnowledge > me".

Thanks for reading.
Title: Re: Crossfading limitations
Post by: Dave Gilbert on Thu 06/03/2014 16:40:55
The best way to get around this is to create TWO audio channels, and then crossfade between them. It can get a bit over complicated, but that's the way I did it.