Crossfading limitations

Started by mitlark, Thu 27/02/2014 04:53:26

Previous topic - Next topic

mitlark

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
Code: ags
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.
SPIN SPIN! SPIN SPIN!

Dave Gilbert

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.

SMF spam blocked by CleanTalk