You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
If a channel is done playing before fade_length is reached, its volume is never restored to fade_volume_reset. This messes up the volume for the next chunk to be played on the same channel.
Here, the volume is restored upon reaching fade_length. But here, the channel is done playing, its fading is set to MIX_NO_FADING and the volume is never restored. The problem is, in the next call to Mix_PlayChannel() on the same channel, the volume is stuck at whatever value was at the end of previous playback.
I believe there would be the same behaviour for expired channels.
Is this a bug? And what's the best way to deal with this problem when Mix_MasterVolume isn't available and the global volume is controlled by Mix_HaltChannel(-1); Mix_Volume(-1, volume)?
Potentional workaround 1
auto ms_to_fade = min(fade_length, chunk_ticks_left);
Mix_FadeOutChannel(channel, ms_to_fade);
In this case, the condition for restoring the volume will be fulfilled, but I don't know how to get or calculate chunk_ticks_left, as even SDL_Mixer doesn't know or expose how many ticks are left before chunk is done playing.
Potentional workaround 2
if ( Mix_Playing(channel) == true )
{
auto volume = Mix_Volume(channel, -1);
Mix_FadeOutChannel(channel, ms_to_fade);
}
// elsewhere
if ( Mix_Playing(channel) == false )
{
Mix_Volume(channel, volume);
Mix_PlayChannel(channel, chunk, 0);
}
This is only possible with dedicated channels, and it's a bit more error-prone, as the channel volume must be properly initialized before first playback.
The text was updated successfully, but these errors were encountered:
If a channel is done playing before
fade_length
is reached, its volume is never restored tofade_volume_reset
. This messes up the volume for the next chunk to be played on the same channel.Here, the volume is restored upon reaching
fade_length
. But here, the channel is done playing, itsfading
is set toMIX_NO_FADING
and the volume is never restored. The problem is, in the next call to Mix_PlayChannel() on the same channel, the volume is stuck at whatever value was at the end of previous playback.I believe there would be the same behaviour for expired channels.
Is this a bug? And what's the best way to deal with this problem when
Mix_MasterVolume
isn't available and the global volume is controlled byMix_HaltChannel(-1); Mix_Volume(-1, volume)
?Potentional workaround 1
In this case, the condition for restoring the volume will be fulfilled, but I don't know how to get or calculate
chunk_ticks_left
, as even SDL_Mixer doesn't know or expose how many ticks are left before chunk is done playing.Potentional workaround 2
This is only possible with dedicated channels, and it's a bit more error-prone, as the channel
volume
must be properly initialized before first playback.The text was updated successfully, but these errors were encountered: