missionpinball / mpf-mc

The Mission Pinball Framework Media Controller. Controls graphics, sounds, DMDs, and LCD displays in MPF.
http://missionpinball.org
MIT License
21 stars 42 forks source link

Sound ducking release too abrupt when stopping a sound #415

Open qcapen opened 3 years ago

qcapen commented 3 years ago

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.

qcapen commented 3 years ago

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?