logo

Live Production Software Forums


Welcome Guest! To enable all features please Login or Register.

Notification

Icon
Error

Options
Go to last post Go to first unread
Bob Brazner  
#1 Posted : Tuesday, December 21, 2021 2:45:24 PM(UTC)
Bob Brazner

Rank: Advanced Member

Groups: Registered
Joined: 3/22/2020(UTC)
Posts: 49
United States
Location: River Hills

Thanks: 3 times
Was thanked: 2 time(s) in 2 post(s)
Does anyone have a script that demonstrates how I can duck one input based on volume level of another input? I know I can do this with Waves C1 compressor, but I'm hoping there's a script way to do it.

I was hoping to be able to figure this out for myself by reviewing the object reference for the vMix API, but I can't even find that. Can anyone point that out to me?
Peter1000  
#2 Posted : Tuesday, December 21, 2021 5:22:08 PM(UTC)
Peter1000

Rank: Advanced Member

Groups: Registered
Joined: 1/25/2019(UTC)
Posts: 235
Switzerland

Thanks: 13 times
Was thanked: 53 time(s) in 41 post(s)
thanks 3 users thanked Peter1000 for this useful post.
doggy on 12/21/2021(UTC), jelutalica on 12/22/2021(UTC), raugert on 12/25/2021(UTC)
Bob Brazner  
#3 Posted : Wednesday, December 22, 2021 5:34:17 AM(UTC)
Bob Brazner

Rank: Advanced Member

Groups: Registered
Joined: 3/22/2020(UTC)
Posts: 49
United States
Location: River Hills

Thanks: 3 times
Was thanked: 2 time(s) in 2 post(s)
I watched this video, but unfortunately it doesn't include any information about the script itself. So, the hunt continues.
doggy  
#4 Posted : Wednesday, December 22, 2021 6:45:21 AM(UTC)
doggy

Rank: Advanced Member

Groups: Registered
Joined: 12/27/2012(UTC)
Posts: 4,032
Belgium
Location: Belgium

Thanks: 239 times
Was thanked: 731 time(s) in 595 post(s)
Originally Posted by: Bob Brazner Go to Quoted Post
I watched this video, but unfortunately it doesn't include any information about the script itself. So, the hunt continues.


The full script is in the pinned comment. The comments within the script can be translated with google translate
Stealth77  
#5 Posted : Friday, December 24, 2021 5:02:45 AM(UTC)
Stealth77

Rank: Member

Groups: Registered
Joined: 8/4/2015(UTC)
Posts: 17
Man
Russian Federation

Thanks: 3 times
Was thanked: 7 time(s) in 4 post(s)
'--- Many thanks to Kirill Kudryavtsev @ kin0shkin from https://sbtg.ru/ for the script!

'--- Begin Script

dim translateInput as string = "Rus Translate" 'Input name with Translator
dim origInput as string = "Orig Program L" 'Input name with Original audio track

dim volumeStandart as string = "100" 'Volume Orig. input when the Translator is silent
dim fadeTimeStandart as string = "1200" 'Duration increase the volume Orig. when the Translator is silent

dim volumeSpeaking as string = "60" 'Volume of the Original input when the Translator speaks
dim fadeTimeSpeaking as string = "200" 'Duration fading Orig. when the Translator speaks

dim voicethreshold as string = "0.05" 'Response threshold to the interpreter's signal, from 0 to 1 (logical scale)
'Corresponds to the values ​​(not the length) on the volume slider: 0.5 = 50% ~ = -6dB, 0.1 = 10% ~ = -20dB ...
'Response may not work with a single pulse signal, but works well with a signal such as voice or music

dim checkingIter as integer = 10 'Number of iterations to check for translator silence before firing
dim checkingIterTime as integer = 200 'Interval (milliseconds) between check iterations (recommended from 100, default 200)
'So it lasts. verifying that the translation is silent and you can turn on Orig. = checkingIter * checkingIterTime (milliseconds)

'---- End of settings ----

dim voicemeter as string = ""
dim speaking as boolean = false
dim silence as boolean = false
dim silencechecking as integer = 0
dim muted as boolean = false

do while true

dim xml as string = API.XML()
dim x as new system.xml.xmldocument
x.loadxml(xml)

voicemeter = (x.SelectSingleNode("//input[@title='"& translateInput &"']/@meterF1").Value)
if (x.SelectSingleNode("//input[@title='"& translateInput &"']/@meterF2").Value) > voicemeter
voicemeter = (x.SelectSingleNode("//input[@title='"& translateInput &"']/@meterF2").Value)
end if
muted = (x.SelectSingleNode("//input[@title='"& translateInput &"']/@muted").Value)

'API.Function("SetText",Input:="TextInput",SelectedName:="Timer.Text" ,Value:=voicemeter)
'console.writeline(voicemeter)


if voicemeter > voicethreshold And voicemeter.IndexOfAny("[E]".ToCharArray) = -1 And Not muted

if silencechecking >= checkingIter '<> 0 '!=

'console.writeline("Speaking")
silencechecking = 0
'API.Function("SetTextColour",Input:="TextInput",SelectedName:="Timer.Text",Value:="yellow")
'API.Function("SetText",Input:="TextInput",SelectedName:="Timer.Text" ,Value:="Перевод говорит! " + voicemeter)
Input.Find(origInput).Function("SetVolumeFade", volumeSpeaking + "," + fadeTimeSpeaking)

end if

'console.writeline(silencechecking)

else

if silencechecking < checkingIter

silencechecking += 1

end if
if silencechecking = checkingIter

'console.writeline("Silence")
'API.Function("SetTextColour",Input:="TextInput",SelectedName:="Timer.Text",Value:="white")
'API.Function("SetText",Input:="TextInput",SelectedName:="Timer.Text" ,Value:="Перевод молчит! " + voicemeter)
Input.Find(origInput).Function("SetVolumeFade", volumeStandart + "," + fadeTimeStandart)
silencechecking = checkingIter + 1

end if


'console.writeline(silencechecking)

end if


sleep(checkingIterTime)

Loop

'--- End Script
thanks 3 users thanked Stealth77 for this useful post.
jelutalica on 12/25/2021(UTC), Bob Brazner on 12/28/2021(UTC), jpetrie on 12/29/2021(UTC)
Bob Brazner  
#6 Posted : Tuesday, December 28, 2021 8:42:07 AM(UTC)
Bob Brazner

Rank: Advanced Member

Groups: Registered
Joined: 3/22/2020(UTC)
Posts: 49
United States
Location: River Hills

Thanks: 3 times
Was thanked: 2 time(s) in 2 post(s)
Is there a way to unconditionally run this script upon loading a given preset? Or, must I start it manually with a shortcut or Stream Deck button?
doggy  
#7 Posted : Tuesday, December 28, 2021 9:38:47 AM(UTC)
doggy

Rank: Advanced Member

Groups: Registered
Joined: 12/27/2012(UTC)
Posts: 4,032
Belgium
Location: Belgium

Thanks: 239 times
Was thanked: 731 time(s) in 595 post(s)
Originally Posted by: Bob Brazner Go to Quoted Post
Is there a way to unconditionally run this script upon loading a given preset? Or, must I start it manually with a shortcut or Stream Deck button?


Assuming you started the preset manually, start it manually with a shortcut or Stream Deck (or other controller) button or open Settings -> scripting -> select script -> start

Can be potentially "dangerous" to autorun a script at preset loading , must be sure the script is completely bug free

Can always make a auto launch external option (bat file or alike) but must be sure all is fully loaded before commanding the script to run

Maybe a feature request ?
Bob Brazner  
#8 Posted : Wednesday, December 29, 2021 8:41:20 AM(UTC)
Bob Brazner

Rank: Advanced Member

Groups: Registered
Joined: 3/22/2020(UTC)
Posts: 49
United States
Location: River Hills

Thanks: 3 times
Was thanked: 2 time(s) in 2 post(s)
I figured as much; an overt act (e.g., shortcut, button, etc.) is necessary to start scripts.

The script is great; it works perfectly and I like the settings for controlling how it behaves. The only thing I'm going to change is the variable names for the two inputs as my use case does not involve a Russian translator. This is turning out to be not as simple as it sounds. Any suggestions?
vMix-Viktor  
#9 Posted : Wednesday, February 23, 2022 12:57:11 AM(UTC)
vMix-Viktor

Rank: Newbie

Groups: Registered
Joined: 2/23/2022(UTC)
Posts: 2
Germany

Was thanked: 1 time(s) in 1 post(s)
Hey guys, thx for this amazing script :D

I unfortunately might have found an issue though:

When running the script with the "translator"-input unmuted nothing will happen until I muted and unmuted it again.
This happens every time that I start the script.
But of course, I'd like the ducking to happen as soon as the script has been started.

Any suggestions?
vMix-Viktor  
#10 Posted : Wednesday, February 23, 2022 1:53:29 AM(UTC)
vMix-Viktor

Rank: Newbie

Groups: Registered
Joined: 2/23/2022(UTC)
Posts: 2
Germany

Was thanked: 1 time(s) in 1 post(s)
Nevermind I found the mistake .D Here's the updated code:

'--- Many thanks to Kirill Kudryavtsev @ kin0shkin from https://sbtg.ru/ for the script!

'--- Begin Script

dim translateInput as string = "Source" 'Input name with Translator
dim origInput as string = "Duck" 'Input name with Original audio track

dim volumeStandart as string = "100" 'Volume Orig. input when the Translator is silent
dim fadeTimeStandart as string = "1200" 'Duration increase the volume Orig. when the Translator is silent

dim volumeSpeaking as string = "60" 'Volume of the Original input when the Translator speaks
dim fadeTimeSpeaking as string = "200" 'Duration fading Orig. when the Translator speaks

dim voicethreshold as string = "0.02" 'Response threshold to the interpreter's signal, from 0 to 1 (logical scale)
'Corresponds to the values ​​(not the length) on the volume slider: 0.5 = 50% ~ = -6dB, 0.1 = 10% ~ = -20dB ...
'Response may not work with a single pulse signal, but works well with a signal such as voice or music

dim checkingIter as integer = 2 'Number of iterations to check for translator silence before firing
dim checkingIterTime as integer = 200 'Interval (milliseconds) between check iterations (recommended from 100, default 200)
'So it lasts. verifying that the translation is silent and you can turn on Orig. = checkingIter * checkingIterTime (milliseconds)

'---- End of settings ----

dim voicemeter as string = ""
dim speaking as boolean = false
dim silence as boolean = false
dim silencechecking as integer = 0
dim muted as boolean = false

do while true

dim xml as string = API.XML()
dim x as new system.xml.xmldocument
x.loadxml(xml)

voicemeter = (x.SelectSingleNode("//input[@title='"& translateInput &"']/@meterF1").Value)

if (x.SelectSingleNode("//input[@title='"& translateInput &"']/@meterF2").Value) > voicemeter

voicemeter = (x.SelectSingleNode("//input[@title='"& translateInput &"']/@meterF2").Value)

end if

Console.WriteLine(voicemeter)

muted = (x.SelectSingleNode("//input[@title='"& translateInput &"']/@muted").Value)

'API.Function("SetText",Input:="TextInput",SelectedName:="Timer.Text" ,Value:=voicemeter)
'console.writeline(voicemeter)

if voicemeter > voicethreshold And voicemeter.IndexOfAny("[E]".ToCharArray) = -1 And Not muted

if silencechecking >= checkingIter '<> 0 '!=

'console.writeline("Speaking")
silencechecking = 0
'API.Function("SetTextColour",Input:="TextInput",SelectedName:="Timer.Text",Value:="yellow")
'API.Function("SetText",Input:="TextInput",SelectedName:="Timer.Text" ,Value:="Перевод говорит! " + voicemeter)
Input.Find(origInput).Function("SetVolumeFade", volumeSpeaking + "," + fadeTimeSpeaking)

else 'this has initially been missing so silencechecking could never reach the value of "2" unless the translator input has been silenced or turned down

silencechecking += 1

end if

'console.writeline(silencechecking)

else

if silencechecking < checkingIter

silencechecking += 1

end if

if silencechecking = checkingIter

'console.writeline("Silence")
'API.Function("SetTextColour",Input:="TextInput",SelectedName:="Timer.Text",Value:="white")
'API.Function("SetText",Input:="TextInput",SelectedName:="Timer.Text" ,Value:="Перевод молчит! " + voicemeter)
Input.Find(origInput).Function("SetVolumeFade", volumeStandart + "," + fadeTimeStandart)
silencechecking = checkingIter + 1

end if

'console.writeline(silencechecking)

end if

sleep(checkingIterTime)

Loop

'--- End Script

thanks 1 user thanked vMix-Viktor for this useful post.
Stealth77 on 3/13/2022(UTC)
Chris Daum  
#11 Posted : Tuesday, April 19, 2022 5:28:50 AM(UTC)
Chris Daum

Rank: Advanced Member

Groups: Registered
Joined: 11/20/2020(UTC)
Posts: 66
Man
Germany

Thanks: 12 times
Was thanked: 8 time(s) in 8 post(s)
a while ago I posted an example.

Long time not used so no comlaining!!:-)
for example you have a moderator and then a video with sound running.


If now the moderator talks in his mic the video audio decreases
and is increased again when mod stops talking

Code:
do 
Dim xml as string = API.XML() 
Dim x as new system.xml.xmldocument
Dim HSLvl as string = ""
x.load("http://127.0.0.1:8088/api")

HSLvl = x.SelectSingleNode("//input[4]/@meterF1").InnerText

 ' adjust video level corresponding to mod mic level

if HSLvl >= "0.02"
api.function("SetVolumeFade", input:= 'video', value:= "50,500")
sleep(500) 'to have the audio level not jumping around...
else
api.function("SetVolumeFade", input:= 'video', value:= "100,500")

end if

'console.writeline(HSLvl) 'just for debugging and level monitoring

loop
Users browsing this topic
Forum Jump  
You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.