mirror of
https://github.com/onyx-and-iris/voicemeeter-api-powershell.git
synced 2026-04-09 17:33:33 +00:00
auto login added, tests updated to take $true, $false
Added $this.Login() into Remote constructor to automatically log user in. Updated test codes accordingly. Boolean params take $true and $false Updated readme to reflect changes.
This commit is contained in:
23
lib/base.ps1
23
lib/base.ps1
@@ -52,11 +52,12 @@ Function Param_Set_Multi {
|
||||
$line = $($line -replace '\s+', ' ')
|
||||
$line = $line.TrimEnd()
|
||||
$line = $line -replace '\s', '='
|
||||
$line = $line -replace 'True', '1'
|
||||
$line = $line -replace 'False', '0'
|
||||
|
||||
$cmd += $line + ';'
|
||||
}
|
||||
[String]$cmd = $cmd.SubString(1)
|
||||
Write-Host $cmd
|
||||
|
||||
$retval = $lib::VBVMR_SetParameters($cmd)
|
||||
if($retval) { Throw "ERROR: CAPI return value: $retval" }
|
||||
@@ -165,7 +166,7 @@ Function Login {
|
||||
)
|
||||
$retval = $lib::VBVMR_Login()
|
||||
if(-not $retval) { Write-Host("LOGGED IN") }
|
||||
elseif($retval -eq 1) {
|
||||
elseif($retval -eq 1) {
|
||||
Write-Host("VB NOT RUNNING")
|
||||
|
||||
if($TYPE -eq 'basic') {
|
||||
@@ -186,7 +187,7 @@ Function Login {
|
||||
|
||||
$ptr = 0
|
||||
$retval = $lib::VBVMR_GetVoicemeeterType([ref]$ptr)
|
||||
if(-not $retval) {
|
||||
if(-not $retval) {
|
||||
if($ptr -eq 1) { Write-Host("VERSION:[BASIC]") }
|
||||
elseif($ptr -eq 2) { Write-Host("VERSION:[BANANA]") }
|
||||
elseif($ptr -eq 3) { Write-Host("VERSION:[POTATO]") }
|
||||
@@ -219,23 +220,23 @@ if ($MyInvocation.InvocationName -ne '.')
|
||||
Login
|
||||
|
||||
$hash = @{
|
||||
"Strip[0].Mute" = 1
|
||||
"Strip[1].Mute" = 1
|
||||
"Strip[2].Mute" = 1
|
||||
"Strip[0].Mono" = 1
|
||||
"Strip[1].Mono" = 1
|
||||
"Strip[2].Mono" = 1
|
||||
"Strip[0].Mute" = $true
|
||||
"Strip[1].Mute" = $true
|
||||
"Strip[2].Mute" = $true
|
||||
"Strip[0].Mono" = $true
|
||||
"Strip[1].Mono" = $true
|
||||
"Strip[2].Mono" = $true
|
||||
}
|
||||
|
||||
|
||||
0..10 | ForEach-Object {
|
||||
foreach($key in $($hash.keys)){
|
||||
$hash[$key] = 1
|
||||
$hash[$key] = $true
|
||||
}
|
||||
Param_Set_Multi -HASH $hash
|
||||
|
||||
foreach($key in $($hash.keys)){
|
||||
$hash[$key] = 0
|
||||
$hash[$key] = $false
|
||||
}
|
||||
Param_Set_Multi -HASH $hash
|
||||
}
|
||||
|
||||
32
lib/bus.ps1
32
lib/bus.ps1
@@ -21,11 +21,9 @@ class Bus {
|
||||
|
||||
hidden $_mono = $($this | Add-Member ScriptProperty 'mono' `
|
||||
{
|
||||
# get
|
||||
$this.Getter($this.cmd('Mono'))
|
||||
}`
|
||||
{
|
||||
# set
|
||||
param ( [Single]$arg )
|
||||
$this._mono = $this.Setter($this.cmd('Mono'), $arg)
|
||||
}
|
||||
@@ -33,11 +31,9 @@ class Bus {
|
||||
|
||||
hidden $_mute = $($this | Add-Member ScriptProperty 'mute' `
|
||||
{
|
||||
# get
|
||||
$this.Getter($this.cmd('Mute'))
|
||||
}`
|
||||
{
|
||||
# set
|
||||
param ( [Single]$arg )
|
||||
$this._mute = $this.Setter($this.cmd('Mute'), $arg)
|
||||
}
|
||||
@@ -45,11 +41,9 @@ class Bus {
|
||||
|
||||
hidden $_gain = $($this | Add-Member ScriptProperty 'gain' `
|
||||
{
|
||||
# get
|
||||
$this.Getter($this.cmd('gain'))
|
||||
}`
|
||||
{
|
||||
# set
|
||||
param ( [Single]$arg )
|
||||
$this._gain = $this.Setter($this.cmd('gain'), $arg)
|
||||
}
|
||||
@@ -67,20 +61,18 @@ Function Buses {
|
||||
if ($MyInvocation.InvocationName -ne '.')
|
||||
{
|
||||
. .\voicemeeter.ps1
|
||||
try {
|
||||
$vmr = [Remote]::new('potato')
|
||||
|
||||
$vmr = [Remote]::new('potato')
|
||||
$vmr.bus[0].mono = $true
|
||||
$vmr.bus[0].mono
|
||||
$vmr.bus[0].mono = $false
|
||||
$vmr.bus[0].mono
|
||||
|
||||
$vmr.Login()
|
||||
|
||||
$vmr.bus[0].mono = 1
|
||||
$vmr.bus[0].mono
|
||||
$vmr.bus[0].mono = 0
|
||||
$vmr.bus[0].mono
|
||||
|
||||
$vmr.bus[1].gain = 3.2
|
||||
$vmr.bus[1].gain
|
||||
$vmr.bus[2].gain = -2.0
|
||||
$vmr.bus[2].gain
|
||||
|
||||
$vmr.Logout()
|
||||
$vmr.bus[1].gain = 3.2
|
||||
$vmr.bus[1].gain
|
||||
$vmr.bus[2].gain = -2.0
|
||||
$vmr.bus[2].gain
|
||||
}
|
||||
finally { $vmr.Logout() }
|
||||
}
|
||||
|
||||
@@ -63,17 +63,13 @@ Function Buttons {
|
||||
if ($MyInvocation.InvocationName -ne '.')
|
||||
{
|
||||
. .\voicemeeter.ps1
|
||||
try {
|
||||
$vmr = [Remote]::new('potato')
|
||||
|
||||
$vmr = [Remote]::new('potato')
|
||||
|
||||
$vmr.Login()
|
||||
|
||||
$vmr.button = Buttons
|
||||
|
||||
$vmr.button[0].state = 1
|
||||
$vmr.button[0].state
|
||||
$vmr.button[0].state = 0
|
||||
$vmr.button[0].state
|
||||
|
||||
$vmr.Logout()
|
||||
$vmr.button[0].state = $true
|
||||
$vmr.button[0].state
|
||||
$vmr.button[0].state = $false
|
||||
$vmr.button[0].state
|
||||
}
|
||||
finally { $vmr.Logout() }
|
||||
}
|
||||
|
||||
@@ -21,11 +21,9 @@ class Strip {
|
||||
|
||||
hidden $_mono = $($this | Add-Member ScriptProperty 'mono' `
|
||||
{
|
||||
# get
|
||||
$this.Getter($this.cmd('Mono'))
|
||||
}`
|
||||
{
|
||||
# set
|
||||
param ( [Single]$arg )
|
||||
$this._mono = $this.Setter($this.cmd('Mono'), $arg)
|
||||
}
|
||||
@@ -33,11 +31,9 @@ class Strip {
|
||||
|
||||
hidden $_solo = $($this | Add-Member ScriptProperty 'solo' `
|
||||
{
|
||||
# get
|
||||
$this.Getter($this.cmd('Solo'))
|
||||
}`
|
||||
{
|
||||
# set
|
||||
param ( [Single]$arg )
|
||||
$this._solo = $this.Setter($this.cmd('Solo'), $arg)
|
||||
}
|
||||
@@ -45,11 +41,9 @@ class Strip {
|
||||
|
||||
hidden $_mute = $($this | Add-Member ScriptProperty 'mute' `
|
||||
{
|
||||
# get
|
||||
$this.Getter($this.cmd('Mute'))
|
||||
}`
|
||||
{
|
||||
# set
|
||||
param ( [Single]$arg )
|
||||
$this._mute = $this.Setter($this.cmd('Mute'), $arg)
|
||||
}
|
||||
@@ -57,11 +51,9 @@ class Strip {
|
||||
|
||||
hidden $_A1 = $($this | Add-Member ScriptProperty 'A1' `
|
||||
{
|
||||
# get
|
||||
$this.Getter($this.cmd('A1'))
|
||||
}`
|
||||
{
|
||||
# set
|
||||
param ( [Single]$arg )
|
||||
$this._A1 = $this.Setter($this.cmd('A1'), $arg)
|
||||
}
|
||||
@@ -69,11 +61,9 @@ class Strip {
|
||||
|
||||
hidden $_A2 = $($this | Add-Member ScriptProperty 'A2' `
|
||||
{
|
||||
# get
|
||||
$this.Getter($this.cmd('A2'))
|
||||
}`
|
||||
{
|
||||
# set
|
||||
param ( [Single]$arg )
|
||||
$this._A2 = $this.Setter($this.cmd('A2'), $arg)
|
||||
}
|
||||
@@ -81,11 +71,9 @@ class Strip {
|
||||
|
||||
hidden $_A3 = $($this | Add-Member ScriptProperty 'A3' `
|
||||
{
|
||||
# get
|
||||
$this.Getter($this.cmd('A3'))
|
||||
}`
|
||||
{
|
||||
# set
|
||||
param ( [Single]$arg )
|
||||
$this._A3 = $this.Setter($this.cmd('A3'), $arg)
|
||||
}
|
||||
@@ -93,11 +81,9 @@ class Strip {
|
||||
|
||||
hidden $_A4 = $($this | Add-Member ScriptProperty 'A4' `
|
||||
{
|
||||
# get
|
||||
$this.Getter($this.cmd('A4'))
|
||||
}`
|
||||
{
|
||||
# set
|
||||
param ( [Single]$arg )
|
||||
$this._A4 = $this.Setter($this.cmd('A4'), $arg)
|
||||
}
|
||||
@@ -105,11 +91,9 @@ class Strip {
|
||||
|
||||
hidden $_A5 = $($this | Add-Member ScriptProperty 'A5' `
|
||||
{
|
||||
# get
|
||||
$this.Getter($this.cmd('A5'))
|
||||
}`
|
||||
{
|
||||
# set
|
||||
param ( [Single]$arg )
|
||||
$this._A5 = $this.Setter($this.cmd('A5'), $arg)
|
||||
}
|
||||
@@ -117,11 +101,9 @@ class Strip {
|
||||
|
||||
hidden $_B1 = $($this | Add-Member ScriptProperty 'B1' `
|
||||
{
|
||||
# get
|
||||
$this.Getter($this.cmd('B1'))
|
||||
}`
|
||||
{
|
||||
# set
|
||||
param ( [Single]$arg )
|
||||
$this._B1 = $this.Setter($this.cmd('B1'), $arg)
|
||||
}
|
||||
@@ -129,11 +111,9 @@ class Strip {
|
||||
|
||||
hidden $_B2 = $($this | Add-Member ScriptProperty 'B2' `
|
||||
{
|
||||
# get
|
||||
$this.Getter($this.cmd('B2'))
|
||||
}`
|
||||
{
|
||||
# set
|
||||
param ( [Single]$arg )
|
||||
$this._B2 = $this.Setter($this.cmd('B2'), $arg)
|
||||
}
|
||||
@@ -141,11 +121,9 @@ class Strip {
|
||||
|
||||
hidden $_B3 = $($this | Add-Member ScriptProperty 'B3' `
|
||||
{
|
||||
# get
|
||||
$this.Getter($this.cmd('B3'))
|
||||
}`
|
||||
{
|
||||
# set
|
||||
param ( [Single]$arg )
|
||||
$this._B3 = $this.Setter($this.cmd('B3'), $arg)
|
||||
}
|
||||
@@ -153,11 +131,9 @@ class Strip {
|
||||
|
||||
hidden $_gain = $($this | Add-Member ScriptProperty 'gain' `
|
||||
{
|
||||
# get
|
||||
$this.Getter($this.cmd('gain'))
|
||||
}`
|
||||
{
|
||||
# set
|
||||
param ( [Single]$arg )
|
||||
$this._gain = $this.Setter($this.cmd('gain'), $arg)
|
||||
}
|
||||
@@ -175,21 +151,19 @@ Function Strips {
|
||||
if ($MyInvocation.InvocationName -ne '.')
|
||||
{
|
||||
. .\voicemeeter.ps1
|
||||
try {
|
||||
$vmr = [Remote]::new('potato')
|
||||
|
||||
$vmr = [Remote]::new('potato')
|
||||
|
||||
$vmr.Login()
|
||||
|
||||
$vmr.strip[1].A1 = 1
|
||||
$vmr.strip[1].A1
|
||||
$vmr.strip[2].A2 = 0
|
||||
$vmr.strip[2].A2
|
||||
$vmr.strip[1].A1 = $true
|
||||
$vmr.strip[1].A1
|
||||
$vmr.strip[2].A2 = $false
|
||||
$vmr.strip[2].A2
|
||||
|
||||
|
||||
$vmr.strip[1].gain = 3.2
|
||||
$vmr.strip[1].gain
|
||||
$vmr.strip[2].gain = -2.0
|
||||
$vmr.strip[2].gain
|
||||
|
||||
$vmr.Logout()
|
||||
$vmr.strip[1].gain = 3.2
|
||||
$vmr.strip[1].gain
|
||||
$vmr.strip[2].gain = -2.0
|
||||
$vmr.strip[2].gain
|
||||
}
|
||||
finally { $vmr.Logout() }
|
||||
}
|
||||
|
||||
@@ -10,6 +10,7 @@ class Remote {
|
||||
Remote ([String]$type)
|
||||
{
|
||||
$this.type = $type
|
||||
$this.Login()
|
||||
}
|
||||
|
||||
[void] Login () {
|
||||
@@ -24,4 +25,3 @@ class Remote {
|
||||
Logout
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user