Resource icon

Auto mute/unmute audio in Scene 1.03

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.
 

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

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.
 
Top