Resource icon

Auto mute/unmute/duck audio volume in Scene 1.3

DCStrato

Member
@Zyr

It looks like a new behavior where unmuting with obs.obs_source_set_muted(audio_source, false) toggles mute back off and sticks around after the call. The opposite, obs.obs_source_set_muted(audio_source, true) will toggle the source off briefly then it it comes back on by itself. I will try to isolate the issue to just those calls and verify its OBS and not the script. If it is a verified OBS issue it make take time to repair. Try using the source volume ducking and see if that works for you until I sort this out.

DC
 

DCStrato

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).
Zyr:
Here is a new version 1.2 with some updates. OBS loads a next scene before it unloads the prior scene. The script was restoring the old audio setting from the last scene after the new scene had changed it when loading. That won't happen now. 1. Restore is optional. 2. Restore is ignored if the new scene made a change to the same audio source. You can try this out and let me know how it goes.
D.C.
 

Attachments

  • automute-duck.zip
    2.7 KB · Views: 36

DCStrato

Member
DCStrato updated Auto mute/unmute audio in Scene with a new update entry:

Auto Mute-Duck Audio Source in Scene+

This LUA Source script will mute/unmute or set volume of a source (duck) to a specified level when entering a scene. Option to restore previous level on exit. Manages OBS loading new scene before exiting existing scene by ignoring restore if the new scene is also modifying volume for the same source.

Newest version adds volume level set and managing script exit issues with a few bug fixes.

1. Add source to scene
2. In source properties select Audio source to modify, Unmute if muted...

Read the rest of this update entry...
 

DaemonCross

New Member
Hi!
Epic script! I've been looking for this for quite a while. It's simpler and less faff than using manual audio capture, when you're a variety streamer and juggling multiple games and have to reconfigure for every game.

== FEATURE REQUEST ==
I've noticed that I -CAN NOT- put/drag the mute/unmute source -INSIDE- a group/folder. Is it possible to update your script for that little extra QoL, to Allow that function?
 

DaemonCross

New Member
Addtional:
Also request if there is a way to "Fade-in/Out" To mute/unmute. For a smooth transition back, to avoid abrupt/jarring switch back to higher volumes.
 

DCStrato

Member
Hi!
Epic script! I've been looking for this for quite a while. It's simpler and less faff than using manual audio capture, when you're a variety streamer and juggling multiple games and have to reconfigure for every game.

== FEATURE REQUEST ==
I've noticed that I -CAN NOT- put/drag the mute/unmute source -INSIDE- a group/folder. Is it possible to update your script for that little extra QoL, to Allow that function?
Hey Daemon,
Interesting. I'll take a look at the group issue. Stay tuned.
 

DCStrato

Member
Addtional:
Also request if there is a way to "Fade-in/Out" To mute/unmute. For a smooth transition back, to avoid abrupt/jarring switch back to higher volumes.
I would think a callback could vary the volume towards a target over time. I have done visual fading this way with other scripts, so audio should be similar. I suspect I can repurpose the visual fade code for audio pretty quickly. D.C.
 

DCStrato

Member
Hey Daemon,
Interesting. I'll take a look at the group issue. Stay tuned.
Daemon,

Apparently OBS does not allow "visible" sources that use bold type with <b> source name </b> to be moved. You can verify this by renaming any of your sources to be inside of the html bold tags <b> and </b> . They WILL be bold faced, but they also won't move if visible. Not sure if this is some sort of feature or bug. I will make corrections to use something other than bold face for the audio source being modified. Meanwhile, turn the source visibility OFF, move it, drag it into a group, whatever, then turn its visibility back on.
D.C.
 

DCStrato

Member
Daemon,

Correction.... If I remove the mute source OBS allows bold just fine. I am going to have to do some detail debugging to find out what is going on and how this script is somehow affecting OBS and its tolerance with visible formatted labels. Might be a few days as I get time to dig into it.

D.C.
 

DCStrato

Member
Daemon,

I was able to reset the UI from the View menu and all is working now with dragging visible formatted objects. What I don't know is what is causing it and if it is something in the automute script or just an OBS thing. Can you try that and see what happens? I am now unable to reproduce the issue. Maybe someone else has experienced this same strange UI issue? Working on your fade audio request. Should have it this week.

D.C.
 

DCStrato

Member
DCStrato updated Auto mute/unmute/duck audio volume in Scene with a new update entry:

Auto mute/unmute/duck audio volume in Scene 1.3

Jan 7, 2023

This LUA Source script will mute/unmute or set volume of a source (duck) to a specified level when entering a scene. Option to restore previous level on exit. Manages OBS loading new scene before exiting existing scene by ignoring restore if the new scene is also modifying volume for the same source.

Newest version adds volume level fade in/out and a few more bug fixes.

1. Add source to scene

2. In source properties select Audio source to modify, Unmute if muted, mute if...

Read the rest of this update entry...
 

DCStrato

Member
Hey Daemon,

Looks like khaver may also have you covered! You might want to checkout that script as well. I don't actually use this script and just wrote it because of a request, but I posted an updated v1.3 that has the fade in/out you requested just the same. In and out speeds can be different. No problem dragging it around after the UI reset. Also added it as a zip file here. Let me know how it goes. Cheers!

D.C.
 

Attachments

  • AutoMuteDuck.zip
    3 KB · Views: 50

DaemonCross

New Member
Yo D.C.,

Tried it out, so far so good. That did the trick! Thanks! Except for the dragging part, I tried the reset thing and, no go. Still can't nest it under a group. haha.

#SideIssue
I tried it on a "Media Source (MP3)", but it's not responding to the script. But for Desktop Source it's fine.
 

DCStrato

Member
Try turning visibility off then dragging it then turning visibility back on. Not sure what is going on with OBS on this one.
 

DaemonCross

New Member
Yup, That did it! Thanks! Yeah, Kinda weird how toggling visibility is a thing for folders, lol. The logic is lost to me. haha.
 

stacker

New Member
Hello everyone 1st time poster here. Was not sure if I should make a new topic or post here as its related to this topic. I have been for a long time trying to find a way to MUTE an audio source when audio is detected on another input.. I've been through pages and pages and its all the same thing about setting up auto-ducking but this is not the result I need... My issues is I want it to fully mute not just turn it down. I can not seem to find a way for it to do that.

Why? you might ask... Well my situation is this... I use OBS + some cameras down at a field complex to live stream games. Between innings music is played and If I or who ever is running the stream is not there to mute the audio feed Facebook / YouTube etc eventually block the stream etc. The microphone that is hooked to the camera is what picks up the music.

The Setup... On the desktop with OBS we also run Spotify / other. When I setup auto-ducking I would basically have OBS watch for any audio happening over the general speaker output and in return it would indeed duck the public microphone out by the field... However it was just "turned down". The Facebook / Youtube system still is able to detect the audio even at its low volume so I still ran into the problem.

I guess what I'm asking is... How can I use the same concept as auto-ducking only to FULLY MUTE an audio source IF anything is detected from X source ( I notice the new OBS has select program for audio in which case I would select Spotify but I'd be happy to just detect playback to the default speaker) I am not looking to switch scenes like the above script is built for. This is a static stream that can run by itself EXCEPT for having to mute the stream when music plays. My goal is to be able to not have to worry about manually muting / UN-muting and just let it run unattended.

This would end a lot of my pain this upcoming summer.
Thanks to anyone who has this answer
 
Last edited:

dqm

Member
Have been using automute for some time on obs 29.0.2 with good success. Thought I'd give the automute/duck version a try. Thus, far mixed results.

What I want is to unmute AND set the volume level. I'm admittedly confused because setting the volume level appears to be an alternative to muting, not something I can do in conjunction with unmuting. Nonetheless...

Unmute if muted works consistently (as before) if that's the only option checked. But, enable "duck instead of mute" at the same time and things go south. I mean, sometimes it sets the volume level, sometimes it unmutes, sometimes both, sometimes neither. Can't discern a pattern to it.

If I only enable "duck instead of mute", then volume usually changes, but audio does not unmute.

I've also tried adding two separate sources: one to unmute and another to duck. I've tried them in both orders. Works sometimes, but not consistently.

What am I doing wrong?
 

DCStrato

Member
Hey,

I have not looked at this script for a long time. I will try to find some time to see if I can repeat what you are experiencing. I am the end user for most of my scripts, but I just wrote this one for somebody who asked for it (Can't remember who).

DC
 
Top