DC,
Here's an update, after having spent some time studying your code and learning LUA in the process.
1. Ducking goes into an endless loop when the volume fader starts at the bottom
2. When Ducking Volume is set to 0, the volume fader steps toward 0 (the top), then jumps to the bottom
3. "Unmute If Muted" does not work if "Duck Volume instead of Mute" is also checked. In that case, for a muted source the effect is "Duck volume and leave muted", which IMHO does not make a lot of sense.
4. The restore feature in the deactive function includes a complex condition that compares audio_source_name to loaded_source_name. I don't know the intent of that condition, but since loaded_source_name is undeclared, it cannot work as intended.
--------------------
5. Sorry, this is a tough one. A number of scenarios can produce source faders that overlap, in which case their fader callbacks are interleaved. For example, fading two different sources in the same scene. Or one activating while another deactivates. Or changing scenes rapidly, such that a second fader starts before an earlier one finishes. And so forth...
Anyway, overlapping faders are compromised by the use of global variables to control their progress. When a subsequent fader (even for a different source) engages before the first one finishes, variables like "audio_source_name", "fade direction", "duck_volume", "duck_speed", etc. are overwritten. Havoc ensues as all active faders assume the properties meant for the last one. Effectively, all audio sources except the last one are abandoned in unpredictable states and all faders continue to operate concurrently on the remaining audio source.
----------
6. The active/deactive signals do not trigger in studio mode in OBS V30 and up. I believe this is an OBS bug, not an issue with your code.
FYI, I am developing an upgrade that address the above issues. Now waiting for #6 to be resolved before considering publishing it. Will keep you informed if I decide to move forward.
Here's an update, after having spent some time studying your code and learning LUA in the process.
1. Ducking goes into an endless loop when the volume fader starts at the bottom
2. When Ducking Volume is set to 0, the volume fader steps toward 0 (the top), then jumps to the bottom
3. "Unmute If Muted" does not work if "Duck Volume instead of Mute" is also checked. In that case, for a muted source the effect is "Duck volume and leave muted", which IMHO does not make a lot of sense.
4. The restore feature in the deactive function includes a complex condition that compares audio_source_name to loaded_source_name. I don't know the intent of that condition, but since loaded_source_name is undeclared, it cannot work as intended.
--------------------
5. Sorry, this is a tough one. A number of scenarios can produce source faders that overlap, in which case their fader callbacks are interleaved. For example, fading two different sources in the same scene. Or one activating while another deactivates. Or changing scenes rapidly, such that a second fader starts before an earlier one finishes. And so forth...
Anyway, overlapping faders are compromised by the use of global variables to control their progress. When a subsequent fader (even for a different source) engages before the first one finishes, variables like "audio_source_name", "fade direction", "duck_volume", "duck_speed", etc. are overwritten. Havoc ensues as all active faders assume the properties meant for the last one. Effectively, all audio sources except the last one are abandoned in unpredictable states and all faders continue to operate concurrently on the remaining audio source.
----------
6. The active/deactive signals do not trigger in studio mode in OBS V30 and up. I believe this is an OBS bug, not an issue with your code.
FYI, I am developing an upgrade that address the above issues. Now waiting for #6 to be resolved before considering publishing it. Will keep you informed if I decide to move forward.