From a0d25c9e1fe26c896e1a4d50c4e4a52558293657 Mon Sep 17 00:00:00 2001 From: Saif Alaqqad Date: Sat, 20 May 2023 10:15:09 +0300 Subject: [PATCH] Add setGainPercentage and getdB methods --- docs/VMR-Class/bus-strip-object.md | 4 ++++ src/BusStrip.ahk | 9 +++++++++ 2 files changed, 13 insertions(+) diff --git a/docs/VMR-Class/bus-strip-object.md b/docs/VMR-Class/bus-strip-object.md index 717e922..ed6d894 100644 --- a/docs/VMR-Class/bus-strip-object.md +++ b/docs/VMR-Class/bus-strip-object.md @@ -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` diff --git a/src/BusStrip.ahk b/src/BusStrip.ahk index c6f9189..c8b4328 100644 --- a/src/BusStrip.ahk +++ b/src/BusStrip.ahk @@ -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