VBVMR_GetLevel binding added

Get_Level implemented in base.ps1

strip.{PreFader,PostFader,PostMute} methods added

bus.{All} added
This commit is contained in:
onyx-and-iris 2023-08-09 14:16:27 +01:00
parent aee3430962
commit 1c9c400f12
5 changed files with 257 additions and 130 deletions

284
README.md
View File

@ -8,14 +8,14 @@ For past/future changes to this project refer to: [CHANGELOG](CHANGELOG.md)
## Tested against ## Tested against
- Basic 1.0.8.8 - Basic 1.0.8.8
- Banana 2.0.6.8 - Banana 2.0.6.8
- Potato 3.0.2.8 - Potato 3.0.2.8
## Requirements ## Requirements
- [Voicemeeter](https://voicemeeter.com/) - [Voicemeeter](https://voicemeeter.com/)
- Powershell 5.1+ or Powershell 7.2+ - Powershell 5.1+ or Powershell 7.2+
## Installation ## Installation
@ -35,9 +35,9 @@ When prompted you will need to accept PSGallery as a trusted repository.
More Info: More Info:
- [PowerShellGet](https://docs.microsoft.com/en-us/powershell/scripting/gallery/installing-psget?view=powershell-7.1) - [PowerShellGet](https://docs.microsoft.com/en-us/powershell/scripting/gallery/installing-psget?view=powershell-7.1)
- [NuGet](https://www.powershellgallery.com/packages/NuGet/1.3.3) - [NuGet](https://www.powershellgallery.com/packages/NuGet/1.3.3)
- [PSGallery](https://docs.microsoft.com/en-gb/powershell/scripting/gallery/overview?view=powershell-7.1) - [PSGallery](https://docs.microsoft.com/en-gb/powershell/scripting/gallery/overview?view=powershell-7.1)
#### Direct download: #### Direct download:
@ -75,14 +75,14 @@ finally { $vmr.Logout() }
Voicemeeter factory function can be: Voicemeeter factory function can be:
- Get-RemoteBasic - Get-RemoteBasic
- Get-RemoteBanana - Get-RemoteBanana
- Get-RemotePotato - Get-RemotePotato
Added in `v3` you may also use the following entry/exit points: Added in `v3` you may also use the following entry/exit points:
- Connect-Voicemeeter - Connect-Voicemeeter
- Disconnect-Voicemeeter - Disconnect-Voicemeeter
`Connect-Voicemeeter` takes a single parameter `Kind`. `Connect-Voicemeeter` takes a single parameter `Kind`.
@ -115,31 +115,31 @@ $vmr.Logout()
The following strip commands are available: The following strip commands are available:
- mute: boolean - mute: boolean
- mono: boolean - mono: boolean
- mc: boolean - mc: boolean
- k: int, from 0 to 4 - k: int, from 0 to 4
- solo: boolean - solo: boolean
- A1-A5: boolean - A1-A5: boolean
- B1-B3: boolean - B1-B3: boolean
- limit: int, from -40 to 12 - limit: int, from -40 to 12
- gain: float, from -60.0 to 12.0 - gain: float, from -60.0 to 12.0
- label: string - label: string
- reverb: float, from 0.0 to 10.0 - reverb: float, from 0.0 to 10.0
- delay: float, from 0.0 to 10.0 - delay: float, from 0.0 to 10.0
- fx1: float, from 0.0 to 10.0 - fx1: float, from 0.0 to 10.0
- fx2: float, from 0.0 to 10.0 - fx2: float, from 0.0 to 10.0
- pan_x: float, from -0.5 to 0.5 - pan_x: float, from -0.5 to 0.5
- pan_y: float, from 0.0 to 1.0 - pan_y: float, from 0.0 to 1.0
- color_x: float, from -0.5 to 0.5 - color_x: float, from -0.5 to 0.5
- color_y: float, from 0.0 to 1.0 - color_y: float, from 0.0 to 1.0
- fx_x: float, from -0.5 to 0.5 - fx_x: float, from -0.5 to 0.5
- fx_y: float, from 0.0 to 1.0 - fx_y: float, from 0.0 to 1.0
- postreverb: boolean - postreverb: boolean
- postdelay: boolean - postdelay: boolean
- postfx1: boolean - postfx1: boolean
- postfx2: boolean - postfx2: boolean
- gainlayer0-gainlayer7: float - gainlayer0-gainlayer7: float
for example: for example:
@ -157,15 +157,15 @@ mc, k for virtual strips only.
The following strip.comp commands are available: The following strip.comp commands are available:
- knob: float, from 0.0 to 10.0 - knob: float, from 0.0 to 10.0
- gainin: float, from -24.0 to 24.0 - gainin: float, from -24.0 to 24.0
- ratio: float, from 1.0 to 8.0 - ratio: float, from 1.0 to 8.0
- threshold: float, from -40.0 to -3.0 - threshold: float, from -40.0 to -3.0
- attack: float, from 0.0 to 200.0 - attack: float, from 0.0 to 200.0
- release: float, from 0.0 to 5000.0 - release: float, from 0.0 to 5000.0
- knee: float, 0.0 to 1.0 - knee: float, 0.0 to 1.0
- gainout: float, from -24.0 to 24.0 - gainout: float, from -24.0 to 24.0
- makeup: boolean - makeup: boolean
for example: for example:
@ -177,13 +177,13 @@ $vmr.strip[3].comp.attack = 8.5
The following strip.gate commands are available: The following strip.gate commands are available:
- knob: float, from 0.0 to 10.0 - knob: float, from 0.0 to 10.0
- threshold: float, from -60.0 to -10.0 - threshold: float, from -60.0 to -10.0
- damping: float, from -60.0 to -10.0 - damping: float, from -60.0 to -10.0
- bpsidechain: int, from 100 to 4000 - bpsidechain: int, from 100 to 4000
- attack: float, from 0.0 to 1000.0 - attack: float, from 0.0 to 1000.0
- hold: float, from 0.0 to 5000.0 - hold: float, from 0.0 to 5000.0
- release: float, from 0.0 to 5000.0 - release: float, from 0.0 to 5000.0
for example: for example:
@ -195,7 +195,7 @@ $vmr.strip[3].gate.threshold = -40.5
The following strip.denoiser commands are available: The following strip.denoiser commands are available:
- knob: float, from 0.0 to 10.0 - knob: float, from 0.0 to 10.0
for example: for example:
@ -205,8 +205,8 @@ $vmr.strip[3].denoiser.knob = 5
#### AppGain | AppMute #### AppGain | AppMute
- `AppGain(amount, gain)` : string, float - `AppGain(amount, gain)` : string, float
- `AppMute(amount, mutestate)` : string, boolean - `AppMute(amount, mutestate)` : string, boolean
for example: for example:
@ -215,19 +215,33 @@ $vmr.strip[5].AppGain("Spotify", 0.5)
$vmr.strip[5].AppMute("Spotify", $true) $vmr.strip[5].AppMute("Spotify", $true)
``` ```
#### levels
The following strip.level commands are available:
- PreFader()
- PostFader()
- PostMute()
for example:
```powershell
$vmr.strip[2].levels.PreFader() -Join ', ' | Write-Host
```
### Bus ### Bus
The following bus commands are available: The following bus commands are available:
- mute: bool - mute: bool
- mono: bool - mono: bool
- limit: int, from -40 to 12 - limit: int, from -40 to 12
- gain: float, from -60.0 to 12.0 - gain: float, from -60.0 to 12.0
- label: string - label: string
- returnreverb: float, from 0.0 to 10.0 - returnreverb: float, from 0.0 to 10.0
- returndelay: float, from 0.0 to 10.0 - returndelay: float, from 0.0 to 10.0
- returnfx1: float, from 0.0 to 10.0 - returnfx1: float, from 0.0 to 10.0
- returnfx2: float, from 0.0 to 10.0 - returnfx2: float, from 0.0 to 10.0
for example: for example:
@ -239,22 +253,22 @@ $vmr.bus[3].returnreverb = 5.7
The following bus.mode members are available: The following bus.mode members are available:
- normal: boolean - normal: boolean
- amix: boolean - amix: boolean
- bmix: boolean - bmix: boolean
- repeat: boolean - repeat: boolean
- composite: boolean - composite: boolean
- tvmix: boolean - tvmix: boolean
- upmix21: boolean - upmix21: boolean
- upmix41: boolean - upmix41: boolean
- upmix61: boolean - upmix61: boolean
- centeronly: boolean - centeronly: boolean
- lfeonly: boolean - lfeonly: boolean
- rearonly: boolean - rearonly: boolean
The following bus.mode commands are available: The following bus.mode commands are available:
- Get(): returns the current bus mode. - Get(): returns the current bus mode.
for example: for example:
@ -264,18 +278,30 @@ $vmr.bus[0].mode.centeronly = $true
$vmr.bus[0].mode.Get() $vmr.bus[0].mode.Get()
``` ```
#### levels
The following strip.level commands are available:
- All()
for example:
```powershell
$vmr.bus[2].levels.All() -Join ', ' | Write-Host
```
### Strip|Bus ### Strip|Bus
#### device #### device
The following strip.device | bus.device commands are available: The following strip.device | bus.device commands are available:
- name: string - name: string
- sr: int - sr: int
- wdm: string - wdm: string
- ks: string - ks: string
- mme: string - mme: string
- asio: string - asio: string
for example: for example:
@ -291,8 +317,8 @@ wdm, ks, mme, asio are defined as write only.
The following strip.eq | bus.eq commands are available: The following strip.eq | bus.eq commands are available:
- on: boolean - on: boolean
- ab: boolean - ab: boolean
for example: for example:
@ -303,8 +329,8 @@ $vmr.bus[0].eq.ab = $false
#### FadeTo | FadeBy #### FadeTo | FadeBy
- `FadeTo(amount, time)` : float, int - `FadeTo(amount, time)` : float, int
- `FadeBy(amount, time)` : float, int - `FadeBy(amount, time)` : float, int
Modify gain to or by the selected amount in db over a time interval in ms. Modify gain to or by the selected amount in db over a time interval in ms.
@ -319,9 +345,9 @@ $vmr.bus[0].FadeBy(-10, 500)
Three modes defined: state, stateonly and trigger. Three modes defined: state, stateonly and trigger.
- State runs associated scripts - State runs associated scripts
- Stateonly does not run associated scripts - Stateonly does not run associated scripts
- Index range (0, 69) - Index range (0, 69)
```powershell ```powershell
$vmr.button[3].state = $true $vmr.button[3].state = $true
@ -333,19 +359,19 @@ $vmr.button[5].trigger = $true
### VBAN ### VBAN
- vmr.vban.enable: Toggle VBAN on or off. Accepts a boolean value. - vmr.vban.enable: Toggle VBAN on or off. Accepts a boolean value.
For each vban in/out stream the following parameters are defined: For each vban in/out stream the following parameters are defined:
- on: boolean - on: boolean
- name: string - name: string
- ip: string - ip: string
- port: int from 1024 - 65535 - port: int from 1024 - 65535
- sr: int (11025, 16000, 22050, 24000, 32000, 44100, 48000, 64000, 88200, 96000) - sr: int (11025, 16000, 22050, 24000, 32000, 44100, 48000, 64000, 88200, 96000)
- channel: int from 1 to 8 - channel: int from 1 to 8
- bit: int 16 or 24 - bit: int 16 or 24
- quality: int from 0 to 4 - quality: int from 0 to 4
- route: int from 0 to 8 - route: int from 0 to 8
SR, channel and bit are defined as readonly for instreams. Attempting to write SR, channel and bit are defined as readonly for instreams. Attempting to write
to those parameters will throw an error. They are read and write for outstreams. to those parameters will throw an error. They are read and write for outstreams.
@ -366,16 +392,16 @@ Certain 'special' commands are defined by the API as performing actions rather t
The following methods are available: The following methods are available:
- show - show
- hide - hide
- restart - restart
- shutdown - shutdown
- Load(filepath) - Load(filepath)
The following properties are write only and accept boolean values: The following properties are write only and accept boolean values:
- showvbanchat - showvbanchat
- lock - lock
example: example:
@ -391,18 +417,18 @@ $vmr.command.Load("path/to/filename.xml")
The following methods are available: The following methods are available:
- play - play
- stop - stop
- pause - pause
- record - record
- ff - ff
- rew - rew
The following properties accept boolean values. The following properties accept boolean values.
- loop - loop
- A1 - A5 - A1 - A5
- B1 - B3 - B1 - B3
example: example:
@ -460,9 +486,9 @@ will load a config file at profiles/banana/config.psd1 for Voicemeeter Banana.
Access to lower level Getters and Setters are provided with these functions: Access to lower level Getters and Setters are provided with these functions:
- `$vmr.Getter(param)`: For getting the value of a parameter expected to return a value other than string. - `$vmr.Getter(param)`: For getting the value of a parameter expected to return a value other than string.
- `$vmr.Getter_String(param)`: For getting the value of any parameter expected to return a string. - `$vmr.Getter_String(param)`: For getting the value of any parameter expected to return a string.
- `$vmr.Setter(param, value)`: For setting the value of any parameter. - `$vmr.Setter(param, value)`: For setting the value of any parameter.
```powershell ```powershell
$vmr.Getter('Strip[2].Mute') $vmr.Getter('Strip[2].Mute')
@ -471,7 +497,7 @@ $vmr.Setter('Strip[4].Label', 'stripname')
$vmr.Setter('Strip[0].Gain', -3.6) $vmr.Setter('Strip[0].Gain', -3.6)
``` ```
- `$vmr.SendText`: Set parameters by script - `$vmr.SendText`: Set parameters by script
```powershell ```powershell
$vmr.SendText("strip[0].mute=1;strip[2].gain=3.8;bus[1].eq.On=1") $vmr.SendText("strip[0].mute=1;strip[2].gain=3.8;bus[1].eq.On=1")
@ -479,17 +505,17 @@ $vmr.Setter('Strip[0].Gain', -3.6)
Access to lower level polling functions are provided with these functions: Access to lower level polling functions are provided with these functions:
- `$vmr.PDirty`: Returns true if a parameter has been updated. - `$vmr.PDirty`: Returns true if a parameter has been updated.
- `$vmr.MDirty`: Returns true if a macrobutton has been updated. - `$vmr.MDirty`: Returns true if a macrobutton has been updated.
### Run tests ### Run tests
Run tests using .\tests\pre-commit.ps1 which accepts the following parameters: Run tests using .\tests\pre-commit.ps1 which accepts the following parameters:
- `kind`: Run tests of this kind - `kind`: Run tests of this kind
- `tag`: Run tests tagged with this marker (currently `higher` or `lower`) - `tag`: Run tests tagged with this marker (currently `higher` or `lower`)
- `num`: Run this number of tests - `num`: Run this number of tests
- `log`: Write summary log file - `log`: Write summary log file
Run tests from repository root in a subshell and write logs, like so: Run tests from repository root in a subshell and write logs, like so:
@ -497,4 +523,4 @@ Run tests from repository root in a subshell and write logs, like so:
### Official Documentation ### Official Documentation
- [Voicemeeter Remote C API](https://github.com/onyx-and-iris/Voicemeeter-SDK/blob/update-docs/VoicemeeterRemoteAPI.pdf) - [Voicemeeter Remote C API](https://github.com/onyx-and-iris/Voicemeeter-SDK/blob/update-docs/VoicemeeterRemoteAPI.pdf)

View File

@ -23,7 +23,7 @@ function Login {
New-Variable -Name vmExe -Value 0 New-Variable -Name vmExe -Value 0
if ( $kindId -eq "basic" ) { $vmExe = 1 } if ( $kindId -eq "basic" ) { $vmExe = 1 }
elseif ( $kindId -eq "banana" ) { $vmExe = 2 } elseif ( $kindId -eq "banana" ) { $vmExe = 2 }
elseif ( $kindId -eq "potato" ) { elseif ( $kindId -eq "potato" ) {
$vmExe = $(if ([Environment]::Is64BitOperatingSystem) { 6 } else { 3 }) $vmExe = $(if ([Environment]::Is64BitOperatingSystem) { 6 } else { 3 })
} }
@ -203,3 +203,18 @@ function Set_By_Script {
Write-Warning $_.Exception.ErrorMessage() Write-Warning $_.Exception.ErrorMessage()
} }
} }
function Get_Level {
param(
[int64]$MODE, [int64]$INDEX
)
New-Variable -Name ptr -Value 0.0
try {
$retval = [int][Voicemeeter.Remote]::VBVMR_GetLevel($MODE, $INDEX, [ref]$ptr)
if ($retval) { throw [CAPIError]::new($retval, $MyInvocation.MyCommand) }
}
catch [CAPIError] {
Write-Warning $_.Exception.ErrorMessage()
}
[float]$ptr
}

View File

@ -47,6 +47,9 @@ function Setup_DLL {
[DllImport(@"$dll")] [DllImport(@"$dll")]
public static extern int VBVMR_SetParameters(String param); public static extern int VBVMR_SetParameters(String param);
[DllImport(@"$dll")]
public static extern int VBVMR_GetLevel(Int64 mode, Int64 index, ref float ptr);
"@ "@
Add-Type -MemberDefinition $Signature -Name Remote -Namespace Voicemeeter -PassThru | Out-Null Add-Type -MemberDefinition $Signature -Name Remote -Namespace Voicemeeter -PassThru | Out-Null

View File

@ -33,6 +33,7 @@ class IBus {
class Bus : IBus { class Bus : IBus {
[Object]$mode [Object]$mode
[Object]$eq [Object]$eq
[Object]$levels
Bus ([int]$index, [Object]$remote) : base ($index, $remote) { Bus ([int]$index, [Object]$remote) : base ($index, $remote) {
AddBoolMembers -PARAMS @('mono', 'mute') AddBoolMembers -PARAMS @('mono', 'mute')
@ -41,6 +42,7 @@ class Bus : IBus {
$this.mode = [Mode]::new($index, $remote) $this.mode = [Mode]::new($index, $remote)
$this.eq = [Eq]::new($index, $remote) $this.eq = [Eq]::new($index, $remote)
$this.levels = [Levels]::new($index, $remote)
} }
[void] FadeTo ([single]$target, [int]$time) { [void] FadeTo ([single]$target, [int]$time) {
@ -52,6 +54,37 @@ class Bus : IBus {
} }
} }
class Levels : IBus {
[int]$init
[int]$offset
Levels ([int]$index, [Object]$remote) : base ($index, $remote) {
$this.init = $index * 8
$this.offset = 8
}
[float] Convert([float]$val) {
if ($val -gt 0) {
return [math]::Round(20 * [math]::Log10($val), 1)
}
else {
return -200.0
}
}
[System.Collections.ArrayList] Getter([int]$mode) {
[System.Collections.ArrayList]$vals = @()
$this.init..$($this.init + $this.offset - 1) | ForEach-Object {
$vals.Add($this.Convert($(Get_Level -MODE $mode -INDEX $_)))
}
return $vals
}
[System.Collections.ArrayList] All() {
return $this.Getter(3)
}
}
class Mode : IBus { class Mode : IBus {
[System.Collections.ArrayList]$modes [System.Collections.ArrayList]$modes

View File

@ -27,6 +27,8 @@ class IStrip {
} }
class Strip : IStrip { class Strip : IStrip {
[Object]$levels
Strip ([int]$index, [Object]$remote) : base ($index, $remote) { Strip ([int]$index, [Object]$remote) : base ($index, $remote) {
AddBoolMembers -PARAMS @('mono', 'solo', 'mute') AddBoolMembers -PARAMS @('mono', 'solo', 'mute')
AddIntMembers -PARAMS @('limit') AddIntMembers -PARAMS @('limit')
@ -35,6 +37,8 @@ class Strip : IStrip {
AddChannelMembers AddChannelMembers
AddGainlayerMembers AddGainlayerMembers
$this.levels = [Levels]::new($index, $remote)
} }
[string] ToString() { [string] ToString() {
@ -50,6 +54,52 @@ class Strip : IStrip {
} }
} }
class Levels : IStrip {
[int]$init
[int]$offset
Levels ([int]$index, [Object]$remote) : base ($index, $remote) {
$p_in = $remote.kind.p_in
if ($index -lt $p_in) {
$this.init = $index * 2
$this.offset = 2
}
else {
$this.init = ($p_in * 2) + (($index - $p_in) * 8)
$this.offset = 8
}
}
[float] Convert([float]$val) {
if ($val -gt 0) {
return [math]::Round(20 * [math]::Log10($val), 1)
}
else {
return -200.0
}
}
[System.Collections.ArrayList] Getter([int]$mode) {
[System.Collections.ArrayList]$vals = @()
$this.init..$($this.init + $this.offset - 1) | ForEach-Object {
$vals.Add($this.Convert($(Get_Level -MODE $mode -INDEX $_)))
}
return $vals
}
[System.Collections.ArrayList] PreFader() {
return $this.Getter(0)
}
[System.Collections.ArrayList] PostFader() {
return $this.Getter(1)
}
[System.Collections.ArrayList] PostMute() {
return $this.Getter(2)
}
}
class PhysicalStrip : Strip { class PhysicalStrip : Strip {
[Object]$comp [Object]$comp
[Object]$gate [Object]$gate