I'm playing music by calling a function called playMusicContinuous, which is supposed to check the level of the volume slider (MusicVol). Except it doesn't work. When I lower the slider to 0, the music cuts out, but when I enter the next room, it plays at normal volume.
In the GlobalScript I have:
function playMusicContinuous (AudioClip* clip){
channelMusic = clip.PlayFrom(musicPos[cN.Room], eAudioPriorityNormal, eRepeat);
channelMusic.Volume = MusicVol.Value;
}
In the room script I have:
// script for Room: Player enters screen (after fadein)
playMusicContinuous (aMusic1ogg);
The volume is not set correctly. This doesn't work either:
// script for Room: Player enters screen (after fadein)
playMusicContinuous (aMusic1ogg);
Wait(1);
channelMusic.Volume = MusicVol.Value;
But this DOES work after playing for a few seconds:
// script for Room: Player enters screen (after fadein)
playMusicContinuous (aMusic1ogg);
Wait(150);
channelMusic.Volume = MusicVol.Value;
Does that make sense to anyone?
The obvious questions are what MusicVol.Value is, where its value is set, and if you've checked that it has the value you assume when you use it to set the channelMusic volume.
Yes, MusicVol.Value is 0 throughout.
If I do this:
playMusicContinuous (aMusic1ogg);
channelMusic.Volume = MusicVol.Value;
Display (String.Format ("MusicVol: %d", MusicVol.Value));
channelMusic.Volume = MusicVol.Value;
It mutes the music only after displaying "MusicVol: 0". Just like before, setting the volume only works when there's some kind of delay.
EDIT: I have given up on making sense of this, and am using Game.SetAudioTypeVolume(eAudioTypeMusic, MusicVol.Value, eVolExistingAndFuture) instead. It would be very helpful in the help document if SetMusicVolume redirected to this function instead of AudioChannel.Volume.
Yeah, sorry, I have no clue either.
Are you accidentally cross-fading with yourself, and 150 ticks is enough to clear the cross-fade duration?
That is probably exactly what I'm doing. Crossfade is on. Good thinking!
But it's not very intuitive. It's far from obvious that you can't set a channel's volume if it's currently fading.
Quote from: Ali on Wed 20/06/2018 23:00:25
But it's not very intuitive. It's far from obvious that you can't set a channel's volume if it's currently fading.
This was mentioned as an issue in another thread not long ago. Crossfade overrides volume, iirc forcing it to go from 0 to max.