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: 50
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: 303
Switzerland

Thanks: 17 times
Was thanked: 79 time(s) in 60 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: 50
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: 5,243
Belgium
Location: Belgium

Thanks: 294 times
Was thanked: 960 time(s) in 794 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: 8 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: 50
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: 5,243
Belgium
Location: Belgium

Thanks: 294 times
Was thanked: 960 time(s) in 794 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: 50
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: 74
Man
Germany

Thanks: 13 times
Was thanked: 9 time(s) in 9 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
mhngg  
#12 Posted : Friday, September 8, 2023 9:23:38 PM(UTC)
mhngg

Rank: Newbie

Groups: Registered
Joined: 9/8/2023(UTC)
Posts: 1
Pakistan
Location: Karachi

I was able to achieve this with one script that is available on youtube. Here is how it looks in action: https://www.linkedin.com...tm_medium=member_desktop
kirik  
#13 Posted : Saturday, October 28, 2023 7:38:20 AM(UTC)
kirik

Rank: Advanced Member

Groups: Registered
Joined: 10/25/2018(UTC)
Posts: 39
Russian Federation
Location: Moscow

Thanks: 7 times
Was thanked: 3 time(s) in 3 post(s)
Originally Posted by: vMix-Viktor Go to Quoted Post
Nevermind I found the mistake .D Here's the updated code:

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




Greetings! I am the same Kirill Kudryavtsev who wrote the script! Please tell me where the mistake was and what did you write instead? I have already prepared the second version of the script, it is very interesting to know about the incorrect code and its location!
thanks 1 user thanked kirik for this useful post.
Kos Live Studio on 10/24/2024(UTC)
vjmandala  
#14 Posted : Tuesday, December 3, 2024 3:31:07 PM(UTC)
vjmandala

Rank: Member

Groups: Registered
Joined: 6/14/2023(UTC)
Posts: 24
Man
Australia
Location: Melbourne

Script works a treat, thanks heaps to Kirill - only issue for me is, if I have two simultaneous vmix calls running, how does one alter script to accommodate ducking on both calls at same time?



'--- Many thanks to Kirill Kudryavtsev @ kin0shkin from https://sbtg.ru/ for the script!
'--- Change translateInput & origInput "names"
'--- Begin Script

dim translateInput as string = "AJAX-VMIX-CALL" 'Input name with Translator
dim origInput as string = "sMAC SRT OBS aMAC SRT OBO Vmix" '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
nikosman88  
#15 Posted : Tuesday, December 10, 2024 10:27:50 PM(UTC)
nikosman88

Rank: Advanced Member

Groups: Registered
Joined: 12/24/2021(UTC)
Posts: 543
Greece
Location: athens

Thanks: 130 times
Was thanked: 74 time(s) in 70 post(s)
Hello. This is a very usefull script. For what you need try this version. Rename your inputs for your needs
Code:

'--- Begin Modified Script

dim translateInput as string = "Audio In 1" 'Input name for Translator
dim origInput as string = "Audio In 2" 'Input name for Original audio track

dim volumeStandart as string = "100" 'Volume of input when silent
dim fadeTimeStandart as string = "1200" 'Fade-in duration when silent

dim volumeSpeaking as string = "60" 'Volume of input when speaking
dim fadeTimeSpeaking as string = "200" 'Fade-out duration when speaking

dim voicethreshold as string = "0.02" 'Response threshold for signal detection

dim checkingIter as integer = 2 'Number of checks for silence
dim checkingIterTime as integer = 200 'Interval (milliseconds) between checks

dim voicemeter1 as string = ""
dim voicemeter2 as string = ""
dim speaking1 as boolean = false
dim speaking2 as boolean = false
dim silenceChecking1 as integer = 0
dim silenceChecking2 as integer = 0
dim muted1 as boolean = false
dim muted2 as boolean = false

do while true

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

    ' Get volume meter values for both inputs
    voicemeter1 = (x.SelectSingleNode("//input[@title='" & translateInput & "']/@meterF1").Value)
    if (x.SelectSingleNode("//input[@title='" & translateInput & "']/@meterF2").Value) > voicemeter1 then
        voicemeter1 = (x.SelectSingleNode("//input[@title='" & translateInput & "']/@meterF2").Value)
    end if

    voicemeter2 = (x.SelectSingleNode("//input[@title='" & origInput & "']/@meterF1").Value)
    if (x.SelectSingleNode("//input[@title='" & origInput & "']/@meterF2").Value) > voicemeter2 then
        voicemeter2 = (x.SelectSingleNode("//input[@title='" & origInput & "']/@meterF2").Value)
    end if

    ' Check if inputs are muted
    muted1 = (x.SelectSingleNode("//input[@title='" & translateInput & "']/@muted").Value)
    muted2 = (x.SelectSingleNode("//input[@title='" & origInput & "']/@muted").Value)

    ' Handle Audio In 1 (Translator) activity
    if voicemeter1 > voicethreshold and Not muted1 then
        silenceChecking1 = 0
        Input.Find(origInput).Function("SetVolumeFade", volumeSpeaking & "," & fadeTimeSpeaking)
    else
        silenceChecking1 += 1
        if silenceChecking1 >= checkingIter then
            Input.Find(origInput).Function("SetVolumeFade", volumeStandart & "," & fadeTimeStandart)
        end if
    end if

    ' Handle Audio In 2 (Original) activity
    if voicemeter2 > voicethreshold and Not muted2 then
        silenceChecking2 = 0
        Input.Find(translateInput).Function("SetVolumeFade", volumeSpeaking & "," & fadeTimeSpeaking)
    else
        silenceChecking2 += 1
        if silenceChecking2 >= checkingIter then
            Input.Find(translateInput).Function("SetVolumeFade", volumeStandart & "," & fadeTimeStandart)
        end if
    end if

    ' Wait before next check
    sleep(checkingIterTime)

loop

'--- End Modified Script

or this
Code:

dim translateInput1 as string = "Audio In 1" 'Πρώτη πηγή ήχου (π.χ. μεταφραστής)
dim translateInput2 as string = "Audio In 2" 'Δεύτερη πηγή ήχου (π.χ. άλλο μικρόφωνο)
dim origInput as string = "music" 'Όνομα εισόδου με το πρωτότυπο ηχητικό

dim volumeStandart as string = "100" 'Ένταση πρωτότυπου ήχου όταν τα μικρόφωνα σιωπούν
dim fadeTimeStandart as string = "1200" 'Χρόνος αυξησης έντασης όταν τα μικρόφωνα σιωπούν

dim volumeSpeaking as string = "60" 'Ένταση πρωτότυπου ήχου όταν κάποιο μικρόφωνο μιλάει
dim fadeTimeSpeaking as string = "200" 'Χρόνος μείωσης έντασης όταν κάποιο μικρόφωνο μιλάει

dim voicethreshold as string = "0.05" 'Κατώφλι αντίδρασης στο σήμα των μικροφώνων
dim checkingIter as integer = 10 'Αριθμός ελέγχων σιωπής πριν δράση
dim checkingIterTime as integer = 200 'Χρόνος ανάμεσα στους ελέγχους σιωπής

dim voicemeter1 as string = ""
dim voicemeter2 as string = ""
dim silencechecking as integer = 0
dim muted1 as boolean = false
dim muted2 as boolean = false

do while true

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

    ' Λήψη δεδομένων για την πρώτη πηγή ήχου
    voicemeter1 = (x.SelectSingleNode("//input[@title='"& translateInput1 &"']/@meterF1").Value)
    if (x.SelectSingleNode("//input[@title='"& translateInput1 &"']/@meterF2").Value) > voicemeter1 then
        voicemeter1 = (x.SelectSingleNode("//input[@title='"& translateInput1 &"']/@meterF2").Value)
    end if
    muted1 = (x.SelectSingleNode("//input[@title='"& translateInput1 &"']/@muted").Value)

    ' Λήψη δεδομένων για τη δεύτερη πηγή ήχου
    voicemeter2 = (x.SelectSingleNode("//input[@title='"& translateInput2 &"']/@meterF1").Value)
    if (x.SelectSingleNode("//input[@title='"& translateInput2 &"']/@meterF2").Value) > voicemeter2 then
        voicemeter2 = (x.SelectSingleNode("//input[@title='"& translateInput2 &"']/@meterF2").Value)
    end if
    muted2 = (x.SelectSingleNode("//input[@title='"& translateInput2 &"']/@muted").Value)

    ' Έλεγχος αν μιλάει η πρώτη πηγή
    if voicemeter1 > voicethreshold And voicemeter1.IndexOfAny("[E]".ToCharArray) = -1 And Not muted1 then
        silencechecking = 0
        Input.Find(origInput).Function("SetVolumeFade", volumeSpeaking + "," + fadeTimeSpeaking)
    ' Έλεγχος αν μιλάει η δεύτερη πηγή
    elseif voicemeter2 > voicethreshold And voicemeter2.IndexOfAny("[E]".ToCharArray) = -1 And Not muted2 then
        silencechecking = 0
        Input.Find(origInput).Function("SetVolumeFade", volumeSpeaking + "," + fadeTimeSpeaking)
    else
        ' Αν και οι δύο πηγές είναι σιωπηλές
        if silencechecking < checkingIter then
            silencechecking += 1
        end if
        if silencechecking = checkingIter then
            Input.Find(origInput).Function("SetVolumeFade", volumeStandart + "," + fadeTimeStandart)
            silencechecking = checkingIter + 1
        end if
    end if

    sleep(checkingIterTime)

loop


and with 3 mics/audios
Code:

'--- Begin Script with 3 Microphones

dim mic1 as string = "Audio In 1" ' First microphone
dim mic2 as string = "Audio In 2" ' Second microphone
dim mic3 as string = "Audio In 3" ' Third microphone

dim volumeStandart as string = "100" ' Default volume when silent
dim fadeTimeStandart as string = "1200" ' Fade-in duration

dim volumeSpeaking as string = "60" ' Volume when speaking
dim fadeTimeSpeaking as string = "200" ' Fade-out duration

dim voicethreshold as string = "0.02" ' Threshold for activity detection

dim checkingIter as integer = 2 ' Number of silence checks
dim checkingIterTime as integer = 200 ' Interval between checks

dim voicemeter1 as string = ""
dim voicemeter2 as string = ""
dim voicemeter3 as string = ""
dim silenceChecking1 as integer = 0
dim silenceChecking2 as integer = 0
dim silenceChecking3 as integer = 0
dim muted1 as boolean = false
dim muted2 as boolean = false
dim muted3 as boolean = false

do while true

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

    ' Get volume meter values for all microphones
    voicemeter1 = (x.SelectSingleNode("//input[@title='" & mic1 & "']/@meterF1").Value)
    if (x.SelectSingleNode("//input[@title='" & mic1 & "']/@meterF2").Value) > voicemeter1 then
        voicemeter1 = (x.SelectSingleNode("//input[@title='" & mic1 & "']/@meterF2").Value)
    end if

    voicemeter2 = (x.SelectSingleNode("//input[@title='" & mic2 & "']/@meterF1").Value)
    if (x.SelectSingleNode("//input[@title='" & mic2 & "']/@meterF2").Value) > voicemeter2 then
        voicemeter2 = (x.SelectSingleNode("//input[@title='" & mic2 & "']/@meterF2").Value)
    end if

    voicemeter3 = (x.SelectSingleNode("//input[@title='" & mic3 & "']/@meterF1").Value)
    if (x.SelectSingleNode("//input[@title='" & mic3 & "']/@meterF2").Value) > voicemeter3 then
        voicemeter3 = (x.SelectSingleNode("//input[@title='" & mic3 & "']/@meterF2").Value)
    end if

    ' Check if microphones are muted
    muted1 = (x.SelectSingleNode("//input[@title='" & mic1 & "']/@muted").Value)
    muted2 = (x.SelectSingleNode("//input[@title='" & mic2 & "']/@muted").Value)
    muted3 = (x.SelectSingleNode("//input[@title='" & mic3 & "']/@muted").Value)

    ' Handle Audio In 1 activity
    if voicemeter1 > voicethreshold and Not muted1 then
        silenceChecking1 = 0
        Input.Find(mic2).Function("SetVolumeFade", volumeSpeaking & "," & fadeTimeSpeaking)
        Input.Find(mic3).Function("SetVolumeFade", volumeSpeaking & "," & fadeTimeSpeaking)
    else
        silenceChecking1 += 1
        if silenceChecking1 >= checkingIter then
            Input.Find(mic2).Function("SetVolumeFade", volumeStandart & "," & fadeTimeStandart)
            Input.Find(mic3).Function("SetVolumeFade", volumeStandart & "," & fadeTimeStandart)
        end if
    end if

    ' Handle Audio In 2 activity
    if voicemeter2 > voicethreshold and Not muted2 then
        silenceChecking2 = 0
        Input.Find(mic1).Function("SetVolumeFade", volumeSpeaking & "," & fadeTimeSpeaking)
        Input.Find(mic3).Function("SetVolumeFade", volumeSpeaking & "," & fadeTimeSpeaking)
    else
        silenceChecking2 += 1
        if silenceChecking2 >= checkingIter then
            Input.Find(mic1).Function("SetVolumeFade", volumeStandart & "," & fadeTimeStandart)
            Input.Find(mic3).Function("SetVolumeFade", volumeStandart & "," & fadeTimeStandart)
        end if
    end if

    ' Handle Audio In 3 activity
    if voicemeter3 > voicethreshold and Not muted3 then
        silenceChecking3 = 0
        Input.Find(mic1).Function("SetVolumeFade", volumeSpeaking & "," & fadeTimeSpeaking)
        Input.Find(mic2).Function("SetVolumeFade", volumeSpeaking & "," & fadeTimeSpeaking)
    else
        silenceChecking3 += 1
        if silenceChecking3 >= checkingIter then
            Input.Find(mic1).Function("SetVolumeFade", volumeStandart & "," & fadeTimeStandart)
            Input.Find(mic2).Function("SetVolumeFade", volumeStandart & "," & fadeTimeStandart)
        end if
    end if

    ' Wait before next check
    sleep(checkingIterTime)

loop

'--- End Script with 3 Microphones

Be aware that im not a guru script. I gave to chatgpt the original script and ask it to do the changes. It seems to me,that it work and i was really suprised that chagpt give this script in it`s 1st attempt
Users browsing this topic
Guest (2)
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.