mirror of
https://github.com/onyx-and-iris/voicemeeter-api-powershell.git
synced 2026-04-09 17:33:33 +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:
17
lib/base.ps1
17
lib/base.ps1
@@ -23,7 +23,7 @@ function Login {
|
||||
New-Variable -Name vmExe -Value 0
|
||||
|
||||
if ( $kindId -eq "basic" ) { $vmExe = 1 }
|
||||
elseif ( $kindId -eq "banana" ) { $vmExe = 2 }
|
||||
elseif ( $kindId -eq "banana" ) { $vmExe = 2 }
|
||||
elseif ( $kindId -eq "potato" ) {
|
||||
$vmExe = $(if ([Environment]::Is64BitOperatingSystem) { 6 } else { 3 })
|
||||
}
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user