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
aircooled76@gmail.com  
#1 Posted : Sunday, September 9, 2018 12:31:26 PM(UTC)
aircooled76@gmail.com

Rank: Advanced Member

Groups: Registered
Joined: 8/15/2013(UTC)
Posts: 93
Man
Australia
Location: Could be Australia could be Europe/UK!

Thanks: 1 times
Was thanked: 7 time(s) in 7 post(s)
Hi Guys,

I have a script that fades the background music at the end of the broadcast to play the outro for the production that has its own audio.

I have made a script that fades from where the audio level of the background music is set for the production. (eg if it is set at 70, it should fade to zero from 70.)

I have a script that gets the audio level from API.XML but the numbers reported in API.XML are in a different scale to the numbers I need to set via the shortcut API.

Volume Set via API---------Volume Reported via API.XML
or Shortcut

100---------------------------------100
90---------------------------------65.60999
80---------------------------------40.96
70---------------------------------24.01
60---------------------------------12.96
50---------------------------------6.25
40---------------------------------2.56
30---------------------------------0.8100001
20---------------------------------0.16
10---------------------------------0.01


It seems that the API volume set is a linear 0-100, but the fader volume in vMix and the reported number are logarithmic. It is a bit of a pain in the ass. Any suggestions on how to make this work elegantly?

If the dev team could add an Audio Fade function that would eliminate my need to do this script :) It is a lot of stuffing around to just automatically fade an audio channel out.

My Script:

Code:
Dim doc As New XmlDocument()
dim bgmi = Input.Find("MUSIC")

doc.LoadXml(API.XML())

Dim node As XmlNode = doc.SelectSingleNode("/vmix/inputs/input[@title='MUSIC']")
Dim volume As Integer = node.Attributes.GetNamedItem("volume").Value
Console.WriteLine(volume)

Do While volume > 0
Console.WriteLine(volume)

  bgmi.Function("SetVolume", volume)
volume = volume - 1
sleep(10)

Loop


aircooled76@gmail.com  
#2 Posted : Monday, September 10, 2018 8:41:03 AM(UTC)
aircooled76@gmail.com

Rank: Advanced Member

Groups: Registered
Joined: 8/15/2013(UTC)
Posts: 93
Man
Australia
Location: Could be Australia could be Europe/UK!

Thanks: 1 times
Was thanked: 7 time(s) in 7 post(s)
OK so my dad is an engineer and he worked out that it is a power curve relationship.

So to get the correct volume level to set with the preset I need to do the volume reported, multiplied by one million to the power of 0.25 or

Code:
(volume * 1000000) ^ 0.25


Bunch of googling later I have the following working script:

Code:
Dim doc As New XmlDocument()
doc.LoadXml(API.XML())

Dim node As XmlNode = doc.SelectSingleNode("/vmix/inputs/input[@title='MUSIC']")
Dim volume As Long  = node.Attributes.GetNamedItem("volume").Value

Dim y As Integer = (volume * 1000000) ^ 0.25

Do While y > -1

Input.Find("MUSIC").Function("SetVolume", y)
y = y - 1

sleep(8)

Loop


I had to set y = -1 in the loop as I can only set the volume as an integer (whole number) and it was rounding to 0 and exiting the loop before zeroing the volume.

So it jumps to 0 if the volume slider is below 1, but I can live with that. Hope this helps someone else!
on_call  
#3 Posted : Sunday, April 11, 2021 3:29:13 AM(UTC)
on_call

Rank: Newbie

Groups: Registered
Joined: 12/15/2018(UTC)
Posts: 7
United States

Was thanked: 2 time(s) in 2 post(s)
Thank you for this script. I was able to reverse it for a fade-up function as well, I tried setting the less-than volume to 101 just in case. I changed the sleep time to 30 instead of 8, and that's giving me a slower transition time. I hope others are able to find this script as it works very well.

One question, is there an if/or function where we could have a single script raise or lower the volume based on its current state? If volume > -1, fade down, right? Or If volume < 101, fade up. I'm not sure there is a way to accomplish this, but it would make for a great single button script if it could be made to work.
doggy  
#4 Posted : Sunday, April 11, 2021 3:39:44 AM(UTC)
doggy

Rank: Advanced Member

Groups: Registered
Joined: 12/27/2012(UTC)
Posts: 5,042
Belgium
Location: Belgium

Thanks: 283 times
Was thanked: 913 time(s) in 752 post(s)
Originally Posted by: on_call Go to Quoted Post

One question, is there an if/or function where we could have a single script raise or lower the volume based on its current state? If volume > -1, fade down, right? Or If volume < 101, fade up. I'm not sure there is a way to accomplish this, but it would make for a great single button script if it could be made to work.


vMix scripts are written in vb.net.

Search google for IF THEN ELSE logic

Henny  
#5 Posted : Sunday, April 11, 2021 4:41:12 PM(UTC)
Henny

Rank: Advanced Member

Groups: Registered
Joined: 5/14/2013(UTC)
Posts: 136
Man
Location: uk

Thanks: 2 times
Was thanked: 23 time(s) in 20 post(s)
Why not use the SetVolumeFade shortcut/command ???
aircooled76@gmail.com  
#6 Posted : Sunday, September 4, 2022 9:30:30 PM(UTC)
aircooled76@gmail.com

Rank: Advanced Member

Groups: Registered
Joined: 8/15/2013(UTC)
Posts: 93
Man
Australia
Location: Could be Australia could be Europe/UK!

Thanks: 1 times
Was thanked: 7 time(s) in 7 post(s)
Originally Posted by: Henny Go to Quoted Post
Why not use the SetVolumeFade shortcut/command ???


I don't think this shortcut was available back then! This feature came in on vMix 21!
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.