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

View File

@ -215,6 +215,20 @@ $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:
@ -264,6 +278,18 @@ $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

View File

@ -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