mirror of
https://github.com/onyx-and-iris/voicemeeter-api-powershell.git
synced 2025-01-18 05:10:48 +00:00
VBVMR_GetLevel binding added
Get_Level implemented in base.ps1 strip.{PreFader,PostFader,PostMute} methods added bus.{All} added
This commit is contained in:
parent
aee3430962
commit
1c9c400f12
26
README.md
26
README.md
@ -215,6 +215,20 @@ $vmr.strip[5].AppGain("Spotify", 0.5)
|
||||
$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
|
||||
|
||||
The following bus commands are available:
|
||||
@ -264,6 +278,18 @@ $vmr.bus[0].mode.centeronly = $true
|
||||
$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
|
||||
|
||||
#### device
|
||||
|
15
lib/base.ps1
15
lib/base.ps1
@ -203,3 +203,18 @@ function Set_By_Script {
|
||||
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
|
||||
}
|
@ -47,6 +47,9 @@ function Setup_DLL {
|
||||
|
||||
[DllImport(@"$dll")]
|
||||
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
|
||||
|
33
lib/bus.ps1
33
lib/bus.ps1
@ -33,6 +33,7 @@ class IBus {
|
||||
class Bus : IBus {
|
||||
[Object]$mode
|
||||
[Object]$eq
|
||||
[Object]$levels
|
||||
|
||||
Bus ([int]$index, [Object]$remote) : base ($index, $remote) {
|
||||
AddBoolMembers -PARAMS @('mono', 'mute')
|
||||
@ -41,6 +42,7 @@ class Bus : IBus {
|
||||
|
||||
$this.mode = [Mode]::new($index, $remote)
|
||||
$this.eq = [Eq]::new($index, $remote)
|
||||
$this.levels = [Levels]::new($index, $remote)
|
||||
}
|
||||
|
||||
[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 {
|
||||
[System.Collections.ArrayList]$modes
|
||||
|
||||
|
@ -27,6 +27,8 @@ class IStrip {
|
||||
}
|
||||
|
||||
class Strip : IStrip {
|
||||
[Object]$levels
|
||||
|
||||
Strip ([int]$index, [Object]$remote) : base ($index, $remote) {
|
||||
AddBoolMembers -PARAMS @('mono', 'solo', 'mute')
|
||||
AddIntMembers -PARAMS @('limit')
|
||||
@ -35,6 +37,8 @@ class Strip : IStrip {
|
||||
|
||||
AddChannelMembers
|
||||
AddGainlayerMembers
|
||||
|
||||
$this.levels = [Levels]::new($index, $remote)
|
||||
}
|
||||
|
||||
[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 {
|
||||
[Object]$comp
|
||||
[Object]$gate
|
||||
|
Loading…
Reference in New Issue
Block a user