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
GregS  
#1 Posted : Thursday, November 4, 2021 9:15:53 AM(UTC)
GregS

Rank: Newbie

Groups: Registered
Joined: 10/20/2021(UTC)
Posts: 5
Canada
Location: Ontario

Thanks: 1 times
Was thanked: 1 time(s) in 1 post(s)
When using the Shortcut / scripting function "SetMasterVolume", Integer values between 0 and 100 are permitted.
Setting a Value of 0 or 100 produces the expected result, but any number in between does not work as expected.

For example, the following script:
Quote:

'======================================
' Set Volume Script =
'======================================

'State variables
Dim state as new system.xml.xmldocument
Dim CurrentVolume As Double
Dim TextLine As String

TextLine = "Setting new volume of 40"
Console.WriteLine(TextLine)
API.Function("SetMasterVolume", Value:=40)


'=========Get Current Volume========
'Current status
state.loadxml(API.XML())

CurrentVolume = (state.SelectSingleNode("//audio/master/@volume").Value)
TextLine = "The Volume Actually Set is " + CurrentVolume.ToString()
Console.WriteLine(TextLine)

Produces this result:
Quote:

Starting Script "Set Volume"
Setting new volume of 40
The Volume Actually Set is 2.56
Stopping Script "Set Volume"


I Testes all of the values from 0 to 100 usning the following script:
Quote:

'======================================
' Test Volume Script =
'======================================
'State variables
Dim state as new system.xml.xmldocument
Dim CurrentVolume As Double
Dim NewVolume As Integer
Dim TextLine As String

Console.WriteLine("Set Volume,Actual Volume")
'=========Set Current Volume From 0 to 100========
For NewVolume = 0 To 100
API.Function("SetMasterVolume", Value:=NewVolume)
'Get Actual Volume========
state.loadxml(API.XML())
CurrentVolume = (state.SelectSingleNode("//audio/master/@volume").Value)
TextLine = NewVolume.ToString() + "," + CurrentVolume.ToString()
Console.WriteLine(TextLine)
Next

I plotted the results in Excel and got the following relationship:
Volume Settings Plot.jpg (24kb) downloaded 1 time(s).

I suspect that the input to the SetMasterVolume function is an integer, but is being interpreted by vMix as a float value.
doggy  
#2 Posted : Thursday, November 4, 2021 5:33:10 PM(UTC)
doggy

Rank: Advanced Member

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

Thanks: 291 times
Was thanked: 955 time(s) in 790 post(s)
Explained by Martin (4 years ago):

https://forums.vmix.com/...etVolume-scale#post45658

then turned into the knowledge base

https://www.vmix.com/kno...44/vmix-api-audio-levels
thanks 1 user thanked doggy for this useful post.
GregS on 11/5/2021(UTC)
GregS  
#3 Posted : Thursday, November 4, 2021 9:47:17 PM(UTC)
GregS

Rank: Newbie

Groups: Registered
Joined: 10/20/2021(UTC)
Posts: 5
Canada
Location: Ontario

Thanks: 1 times
Was thanked: 1 time(s) in 1 post(s)
@doggy:
Thank you for pointing me to that link. It was very helpful in explaining what is happening



I have a follow-up question regarding volume settings:

My goal is to make two shortcut keys to incrementally increase and decrease the final sound level so that it can be managed from the xMix Web Controller. Should I set the scripts to increment the sound level by a fixed amplitude, volume or decibel?

I have no audio experience, but my reading on the internet suggests I should use fixed volume increments, similar to a fixed distance on a fader. What do others suggest?
doggy  
#4 Posted : Friday, November 5, 2021 12:58:35 AM(UTC)
doggy

Rank: Advanced Member

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

Thanks: 291 times
Was thanked: 955 time(s) in 790 post(s)
Originally Posted by: GregS Go to Quoted Post
@doggy:
Thank you for pointing me to that link. It was very helpful in explaining what is happening



I have a follow-up question regarding volume settings:

My goal is to make two shortcut keys to incrementally increase and decrease the final sound level so that it can be managed from the xMix Web Controller. Should I set the scripts to increment the sound level by a fixed amplitude, volume or decibel?

I have no audio experience, but my reading on the internet suggests I should use fixed volume increments, similar to a fixed distance on a fader. What do others suggest?


IMO just do a value +=1 for up and -=1 for down in the shortcuts (can change 1 to another for bigger steps )
GregS  
#5 Posted : Friday, November 5, 2021 11:38:44 AM(UTC)
GregS

Rank: Newbie

Groups: Registered
Joined: 10/20/2021(UTC)
Posts: 5
Canada
Location: Ontario

Thanks: 1 times
Was thanked: 1 time(s) in 1 post(s)
To close the loop on this topic:
I found that just changing the "Master Volume" by 1 was too coarse because about 4 clicks of the button went from full volume to mute.
I ended up converting the Audio>Master>Volume (Amplitude*100) to Volume using the formula:
Quote:
CurrentVolume = ((CurrentAmplitude/100)^0.25)*100
. Changing this by 2 gave a comfortable resolution.

The final code is here:
Quote:

'======================================
' Decrease Volume Script =
'======================================
'Input variable
Dim VolumeChange As Double = -2

'State variables
Dim CurrentAmplitude As Double
Dim CurrentVolume As Double
Dim NewVolume As Long
Dim TextLine As String

'=========Get Current Amplitude ========
'Current status
Dim state as new system.xml.xmldocument
state.loadxml(API.XML())

CurrentAmplitude = (state.SelectSingleNode("//audio/master/@volume").Value)/100
TextLine = "The current Amplitude is " + CurrentAmplitude.ToString()
Console.WriteLine(TextLine)

'=========Convert Amplitude to Volume ========
CurrentVolume = (CurrentAmplitude^0.25)*100
TextLine = "The current Volume is " + CurrentVolume.ToString()
Console.WriteLine(TextLine)

'=========Set New Volume========
NewVolume = CurrentVolume + VolumeChange
TextLine = "Setting new volume of " + NewVolume.ToString()
Console.WriteLine(TextLine)

API.Function("SetMasterVolume", Value:=NewVolume)
Users browsing this topic
Guest
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.