Skip to content

Commit

Permalink
Add setGainPercentage and getdB methods
Browse files Browse the repository at this point in the history
  • Loading branch information
SaifAqqad committed May 20, 2023
1 parent 569cf48 commit a0d25c9
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 0 deletions.
4 changes: 4 additions & 0 deletions docs/VMR-Class/bus-strip-object.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,12 @@ Use this object to access or modify bus/strip parameters.
Returns the value of a bus/strip's parameter
* #### `getGainPercentage()`
Returns the bus/strip's gain as a scalar percentage
* #### `setGainPercentage(percentage)`
Sets the bus/strip's gain using a scalar percentage
* #### `getPercentage(dB)`
Converts a dB value to a scalar percentage
* #### `getdB(percentage)`
Converts a scalar percentage to a dB value
* #### `isPhysical()`
Returns `1` if the bus/strip is a physical one (Hardware bus/strip), otherwise return `0`

Expand Down
9 changes: 9 additions & 0 deletions src/BusStrip.ahk
Original file line number Diff line number Diff line change
Expand Up @@ -118,11 +118,20 @@
return Format("{:.2f}",this.getPercentage(this.gain))
}

setGainPercentage(percentage){
return this.gain := this.getdB(percentage)
}

getPercentage(dB){
min_s := 10**(-60/20), max_s := 10**(0/20)
return ((10**(dB/20))-min_s)/(max_s-min_s)*100
}

getdB(percentage){
min_s := 10**(-60/20), max_s := 10**(0/20)
return 20*Log(min_s + percentage/100*(max_s-min_s))
}

setParameter(parameter, value){
local func
if parameter contains device,FadeTo,Label,FadeBy,AppGain,AppMute
Expand Down

0 comments on commit a0d25c9

Please sign in to comment.