missionpinball/mpf-mc

Sound ducking release too abrupt when stopping a sound

qcapen opened this issue · 1 comments

From the mpf-users discussion group:
Greg Sealbygregorysealby@gmail.com
Jan 21, 2021 8:13 AM
to MPF Users
Just playing around with some sounds and ducking. I have a need to play a sound on the SFX track and ducking the music track. The attack value works and the SFX slowly fades in. I play this sound for about 20 seconds and then stop the sound as the mode is over. The Ducking Attenuation does not seem to work for a "stop" sound player command. The music track abruptly starts playing again as soon as the SFX track sound is stopped.

Does ducking only work when the sound file itself finishes? Would seem odd.

This is a bug/design flaw in the audio engine. Currently the ducking calculations are currently performed in the processing for each sound (since the ducking settings are tied directly to a sound). When a sound is stopped, it is no longer in the processing queue and therefore its ducking information simply disappears with it. I had placed several TODO items in the code related to this issue, but had forgotten about addressing it and you are the first person to notice. The ducking processing needs to be redesigned to allow it to continue to process after a sound has finished (whether stopped or simply runs to the end).

What should happen to the ducking when a sound is stopped?

  • Situation 1: Sound is stopped with no fade out. I think it's pretty clear that the ducking release should kick in at this point. Should the ducking release time ever be shortened in this situation? Perhaps have a normal ducking release time and an optional sound stopped ducking release time in the config? I don't want to make this too complicated.
  • Situation 2: Sound is stopped with a fade out that is shorter or equal to the ducking release time. Again, this is just like Situation 1 where the ducking release should begin immediately.
  • Situation 3: Sound is stopped with a fade out time that is longer than the ducking release time. In this situation it is not really clear to me what we should do. I'm leaning towards treating the end of the fade out as the new end of the sound and trigger the ducking release at the specified time (relative to the new ending time)