Resource icon

Auto mute/unmute/duck audio volume in Scene 1.3

DCStrato

Member
DCStrato submitted a new resource:

Auto mute/unmute audio in Scene - Mutes or Unmutes a selected audio source only when specific scene is active

Lua Source Script to either Mute if Unmuted or Unmute if Muted, a selected Audio Source when the scene becomes active in the stream and replaces the prior Mute state of the selected Audio Source when the scene is no longer active in the stream.

Load the "automute.lua" script then add an "Audio Mute/Unmute" source to the scene. In that new source's properties select the Audio Source to Mute/Unmute. Default is to mute the selected audio source when active. Check the Unmute if...

Read more about this resource...
 

DCStrato

Member
Maybe. The dropdown is a filtered list of sources that are of ID type wasapi_input_capture, or wasapi_output_capture. Do you have any default sources like Desktop Audio enabled? I suspect if none of your sources are of that type for some reason then the list would not populate any options to drop down. I fear I am going to struggle to duplicate the problem. Do you only have one enabled Audio Source? Is the selection blank or only showing one option?

D.C.
 

Frankiemagic13

New Member
so the drop down menu isnt working for me at all the section is blank im also on a mac idk if mac is supported
Screen Shot 2021-09-09 at 3.21.15 PM.png
 

DCStrato

Member
Okay, thanks for letting me know you are on a Mac. Here is the new 1.02 version which hopefully will fix this.
 

Attachments

  • automute.zip
    1.3 KB · Views: 157

BoredDan

New Member
This script has been really helpful. That said I noticed a couple of bugs. Sometimes when editing properties, and possible sometimes on load (unsure on that part) the wrong source will get renamed. This is a bit annoying in itself, but it also causes a secondary issue as it can allow for duplicate source names. Duplicate source names aren't allowed in OBS and I assume it uses them as identifiers since the two duplicate named sources will eventually merge into one. This probably happens during serialization and deserialization as changing the scene collection and changing back or closing and opening OBS will cause it. Further testing it seems to always change the name of the last item added to the scene as far as I can tell.

Second bug is just that editing properties sometimes cause OBS to freeze up and crash. This one is harder to nail down the conditions for.
 

DCStrato

Member
Ooops. I forgot that Lua script let you create a duplicate name in OBS (wish it didn't, but oh well).
Here is a version that limits renaming to after properties are saved and enumerates the sources in the name to keep them unique!

This should help with both bugs.

DC
 

Attachments

  • automute.zip
    1.4 KB · Views: 134
Last edited:

BoredDan

New Member
Another thing I noticed that I hadn't before because I rarely use studio mode, but the scripts don't handle it properly. I use a Auto Mute scene that handles the muting on switch and unmuting on leave of my mic and audio for my AFK screens. I then use that scene as a source for my starting, brb, and ending screens. However if I am on an AFK scene with the source muted and I enter studio mode (or about half of the time if I switch scenes in studio mode to another (or the same) scene) with the mute/unmute sources the audio will unmute itself. I assume the audio is auto unmuting as per the settings but either not registering the auto mute source is still active to either remute or not un mute in the first place depening how your code works. Whatever the case it appears to be an issue exclusive to starting studio mode with the auto mute source active and transitioning scene in studio mode with auto mute active in both scenes. It may be related to my use of a subscene source to contain the auto mutes as well.
 

DCStrato

Member
Another thing I noticed that I hadn't before because I rarely use studio mode, but the scripts don't handle it properly. I use a Auto Mute scene that handles the muting on switch and unmuting on leave of my mic and audio for my AFK screens. I then use that scene as a source for my starting, brb, and ending screens. However if I am on an AFK scene with the source muted and I enter studio mode (or about half of the time if I switch scenes in studio mode to another (or the same) scene) with the mute/unmute sources the audio will unmute itself. I assume the audio is auto unmuting as per the settings but either not registering the auto mute source is still active to either remute or not un mute in the first place depening how your code works. Whatever the case it appears to be an issue exclusive to starting studio mode with the auto mute source active and transitioning scene in studio mode with auto mute active in both scenes. It may be related to my use of a subscene source to contain the auto mutes as well.
I only use Studio Mode so it is just something else with the OBS we all know and love. I am sure we will sort it out. There are often issues getting both modes to work. We auto mute our mixer input for scenes that have audio sources going back to the mixer. Just in case the mix operator forgets on their end. Then unmute when the next scene starts. I have learned a few tricks to knowing when OBS has "really" completed the transition and will put those in. Subscenes may be related! Thanks for that piece of information. Trying to get a new version of OBS Lyrics out the door soon so my time is shortened but will move back to Automute ASAP.
 

DCStrato

Member
Another thing I noticed that I hadn't before because I rarely use studio mode, but the scripts don't handle it properly. I use a Auto Mute scene that handles the muting on switch and unmuting on leave of my mic and audio for my AFK screens. I then use that scene as a source for my starting, brb, and ending screens. However if I am on an AFK scene with the source muted and I enter studio mode (or about half of the time if I switch scenes in studio mode to another (or the same) scene) with the mute/unmute sources the audio will unmute itself. I assume the audio is auto unmuting as per the settings but either not registering the auto mute source is still active to either remute or not un mute in the first place depening how your code works. Whatever the case it appears to be an issue exclusive to starting studio mode with the auto mute source active and transitioning scene in studio mode with auto mute active in both scenes. It may be related to my use of a subscene source to contain the auto mutes as well.
BoredDan,

I created four scenes, Scene 1 has a mute mic source added. Scene 2 and 3 use scene 1 as a source. Scene 4 does not have either a mute source or a scene with a mute source. Started scene 2 out of studio mode, mic went mute. Switched to studio mode. mic stayed muted. Transitioned while in studio mode to source 3, mic stayed muted. Transitioned to scene 4 and mic unmuted. I tried all the combinations of studio mode, with and without Auto Mute source and everything still worked as expected. I am missing your scenario someplace?

DC
 

SallyIV

New Member
Finally a script that does exactly what it says it does and perfectly. I could have used an installation tutorial so if someone else can't find out how to do it either, I'll put how I did it here:

I searched for LUA and found: C:\Program Files\obs-studio\data\obs-plugins\frontend-tools\scripts. I put the file there and launched OBS. Under Tools/Scripts I was able to "+" add it. Then it works exactly as needed. I use it to mute the game during a freeze frame while streaming. When the freeze frame is done it comes right back on (with the right options selected in the script).

Super cool, thank you so much for this LUA!
 

JVRaines

New Member
Thank you for this script! Saves me a ton of twiddling to cut echo in a complicated Zoom scenario.
Now, just to make it interesting, what if you added an option to duck to a configurable level instead of muting completely? That would be even more perfect.
 

DCStrato

Member
Thank you for this script! Saves me a ton of twiddling to cut echo in a complicated Zoom scenario.
Now, just to make it interesting, what if you added an option to duck to a configurable level instead of muting completely? That would be even more perfect.
I will see what might be possible the next time I get a chance to look into it. Probably an easy addition but OBS does surprise.

D.C.
 

DCStrato

Member
Thank you for this script! Saves me a ton of twiddling to cut echo in a complicated Zoom scenario.
Now, just to make it interesting, what if you added an option to duck to a configurable level instead of muting completely? That would be even more perfect.
JVRaines:

Here is a version that ducks a selected source to a preset ducking volume as requested. The additional Default volume is used when forcing a volume for a source that may have been set by a prior mute/ducking source in a prior scene. In this case, the original volume is lost and the volume for the source is set to the selected default. Please test this and let me know if there are any issues.

D.C.
 

Attachments

  • automute-duck.zip
    2.2 KB · Views: 82

DCStrato

Member
Add the Source to a Scene and adjust properties of the Source not the Script.

sourceproperties.png

D.C.
 
Last edited:

Zyr

New Member
Hi @DCStrato,

I'm currently using OBS Studio 28.1.2 (64-bit). I noticed that the unmute seems to be not working properly.

Scenario 1:
1.) Set the Scene 1 with Mute Scenario
2.) Set the Scene 2 with Unmute Scenario
3.) Closed the OBS application with Scene 1 being the last selected Scene.
4.) Open the OBS Application again and Scene 1 is in Mute status
5.) However, when I switched to Scene 2 for the Unmute it is not working.

Scenario 2:
1.) Set the Scene 1 with Mute Scenario
2.) Set the Scene 2 with Unmute Scenario
3.) Closed the OBS application with Scene 2 being the last selected Scene.
4.) Open the OBS Application again and Scene 2 is still in Mute status
5.) I Unmute Scene 2 manually
6.) When I switch back to Scene 1, it is now in Unmute status.

I've been using your script for a long time now and this was my issue when I updated the OBS again (since I haven't used the application for quite some time now).
 
Top