Initial commit

Initial commit

Added readme
This commit is contained in:
onyx-and-iris 2021-04-28 17:38:36 +01:00
parent 56e2a3a9cb
commit e1867d0731
10 changed files with 1516 additions and 2 deletions

View File

@ -1,2 +1,77 @@
# voicemeeter-api-powershell
A simple wrapper in Powershell to the Voicemeeter API
# Powershell Wrapper for Voicemeeter API
This wrapper was written in response to a request in the VB-AUDIO discord for
a way to invoke commands using Powershell. It is designed to be simple to use
but not every feature is added.
## Tested against
- Basic 1.0.7.8
- Banana 2.0.5.8
- Potato 3.0.1.8
You may have success with many commands in earlier versions but some commands
(example Macrobuttons) were only added to the API in later releases.
## Requirements
- Voicemeeter: https://voicemeeter.com/
- Powershell 5.1
## Use
You may use try, finally blocks to ensure you login and logout.
```powershell
. $PSScriptRoot\lib\voicemeeter.ps1
try {
# pass a Voicemeeter type to class Remote
$vmr = [Remote]::new('banana')
$vmr.Login()
# Set macrobutton with id 4, mode state to 1
$vmr.button[4].state = 1
$vmr.button[4].state
# Set strip and bus params
$vmr.strip[0].mono = 1
$vmr.strip[0].mono
$vmr.bus[1].mute = 0
$vmr.bus[1].mute
}
finally
{
$vmr.Logout()
}
```
Voicemeeter type can be one of:
- basic
- banana
- potato
There is no bounds checking in this wrapper, meaning if you attempt to set a
parameter that does not exist for that version of Voicemeeter the wrapper will
throw an error and crash. So make sure what you are settings actually exists.
### Macrobuttons
Three modes defined: state, stateonly and trigger.
- State runs associated scripts
- Stateonly does not run associated scripts
- Index range (0, 69)
```
$vmr.button[3].state = 1
$vmr.button[4].stateonly = 0
$vmr.button[5].trigger = 1
```
### Run tests
Run tests using invoke-pester in powershell console from test directory.
Alternatively you may use .\runall.ps1 which accepts two parameters:
- tag Run tests of this type
- num Run this number of tests
Current test types are 'higher' and 'lower'
Example:
`.\runall.ps1 -tag 'higher' -num 3`

26
example.ps1 Normal file
View File

@ -0,0 +1,26 @@
. $PSScriptRoot\lib\voicemeeter.ps1
try {
$vmr = [Remote]::new('potato')
$vmr.Login()
$vmr.button[0].state = 1
$vmr.button[0].state
$vmr.button[0].state = 0
$vmr.button[0].state
$vmr.strip[0].mono = 1
$vmr.strip[0].mono
$vmr.strip[0].mono = 0
$vmr.strip[0].mono
$vmr.bus[2].mute = 1
$vmr.bus[2].mute
$vmr.bus[2].mute = 0
$vmr.bus[2].mute
}
finally
{
$vmr.Logout()
}

244
lib/base.ps1 Normal file
View File

@ -0,0 +1,244 @@
$Handles = @'
[DllImport(@"C:\Program Files (x86)\VB\Voicemeeter\VoicemeeterRemote64.dll")]
public static extern int VBVMR_Login();
[DllImport(@"C:\Program Files (x86)\VB\Voicemeeter\VoicemeeterRemote64.dll")]
public static extern int VBVMR_Logout();
[DllImport(@"C:\Program Files (x86)\VB\Voicemeeter\VoicemeeterRemote64.dll")]
public static extern int VBVMR_RunVoicemeeter(Int64 run);
[DllImport(@"C:\Program Files (x86)\VB\Voicemeeter\VoicemeeterRemote64.dll")]
public static extern int VBVMR_GetVoicemeeterType(ref int ptr);
[DllImport(@"C:\Program Files (x86)\VB\Voicemeeter\VoicemeeterRemote64.dll")]
public static extern int VBVMR_MacroButton_IsDirty();
[DllImport(@"C:\Program Files (x86)\VB\Voicemeeter\VoicemeeterRemote64.dll")]
public static extern int VBVMR_MacroButton_SetStatus(Int64 id, Single state, Int64 mode);
[DllImport(@"C:\Program Files (x86)\VB\Voicemeeter\VoicemeeterRemote64.dll")]
public static extern int VBVMR_MacroButton_GetStatus(Int64 id, ref float ptr, Int64 mode);
[DllImport(@"C:\Program Files (x86)\VB\Voicemeeter\VoicemeeterRemote64.dll")]
public static extern int VBVMR_IsParametersDirty();
[DllImport(@"C:\Program Files (x86)\VB\Voicemeeter\VoicemeeterRemote64.dll")]
public static extern int VBVMR_SetParameterFloat(String param, Single value);
[DllImport(@"C:\Program Files (x86)\VB\Voicemeeter\VoicemeeterRemote64.dll")]
public static extern int VBVMR_GetParameterFloat(String param, ref float ptr);
[DllImport(@"C:\Program Files (x86)\VB\Voicemeeter\VoicemeeterRemote64.dll")]
public static extern int VBVMR_SetParameterStringA(String param, String value);
[DllImport(@"C:\Program Files (x86)\VB\Voicemeeter\VoicemeeterRemote64.dll")]
public static extern int VBVMR_GetParameterStringA(String param, byte[] buff);
[DllImport(@"C:\Program Files (x86)\VB\Voicemeeter\VoicemeeterRemote64.dll")]
public static extern int VBVMR_SetParameters(String param);
'@
$lib = Add-Type -MemberDefinition $Handles -Name VMRemote -PassThru
$global:layout = $null
Function Param_Set_Multi {
param(
[HashTable]$HASH
)
Start-Sleep -m 50
while(M_Dirty) { Start-Sleep -m 1 }
[string[]]$params = ($HASH | out-string -stream) -ne '' | select -Skip 2
[String]$cmd = [String]::new(512)
ForEach ($line in $params) {
$line = $($line -replace '\s+', ' ')
$line = $line.TrimEnd()
$line = $line -replace '\s', '='
$cmd += $line + ';'
}
[String]$cmd = $cmd.SubString(1)
Write-Host $cmd
$retval = $lib::VBVMR_SetParameters($cmd)
if($retval) { Throw "ERROR: CAPI return value: $retval" }
}
Function Param_Set_String {
param(
[String]$PARAM, [String]$VALUE
)
$retval = $lib::VBVMR_SetParameterStringA($PARAM, $VALUE)
if($retval) { Throw "ERROR: CAPI return value: $retval" }
}
Function Param_Get_String {
param(
[String]$PARAM
)
Start-Sleep -m 50
while(P_Dirty) { Start-Sleep -m 1 }
$BYTES = [System.Byte[]]::new(512)
$retval = $lib::VBVMR_GetParameterStringA($PARAM, $BYTES)
if($retval) { Throw "ERROR: CAPI return value: $retval" }
[System.Text.Encoding]::ASCII.GetString($BYTES).Trim([char]0)
}
Function Param_Set {
param(
[String]$PARAM, [Single]$VALUE
)
$retval = $lib::VBVMR_SetParameterFloat($PARAM, $VALUE)
if($retval) { Throw "ERROR: CAPI return value: $retval" }
}
Function Param_Get {
param(
[String]$PARAM
)
Start-Sleep -m 50
while(P_Dirty) { Start-Sleep -m 1 }
$ptr = 0.0
$retval = $lib::VBVMR_GetParameterFloat($PARAM, [ref]$ptr)
if($retval) { Throw "ERROR: CAPI return value: $retval" }
$ptr
}
Function MB_Set {
param(
[Int64]$ID, [Single]$SET, [Int64]$MODE
)
$retval = $lib::VBVMR_MacroButton_SetStatus($ID, $SET, $MODE)
if($retval) { Throw "ERROR: CAPI return value: $retval" }
}
Function MB_Get {
param(
[Int64]$ID, [Int64]$MODE
)
Start-Sleep -m 50
while(M_Dirty) { Start-Sleep -m 1 }
$ptr = 0.0
$retval = $lib::VBVMR_MacroButton_GetStatus($ID, [ref]$ptr, $MODE)
if($retval) { Throw "ERROR: CAPI return value: $retval" }
$ptr
}
Function DefineVersion {
param(
[Int]$TYPE
)
$layout = @{}
if($TYPE -eq 1) {
$layout = @{
"strip" = 3
"bus" = 2
}
}
elseif($TYPE -eq 2) {
$layout = @{
"strip" = 5
"bus" = 5
}
}
elseif($TYPE -eq 3) {
$layout = @{
"strip" = 8
"bus" = 8
}
}
$global:layout = $layout
$button = Buttons
$strip = Strips
$bus = Buses
}
Function Login {
param(
[String]$TYPE=$null
)
$retval = $lib::VBVMR_Login()
if(-not $retval) { Write-Host("LOGGED IN") }
elseif($retval -eq 1) {
Write-Host("VB NOT RUNNING")
if($TYPE -eq 'basic') {
$retval = $lib::VBVMR_RunVoicemeeter([Int64]1)
if(-not $retval) { Write-Host("STARTING VB") }
}
elseif($TYPE -eq 'banana') {
$retval = $lib::VBVMR_RunVoicemeeter([Int64]2)
if(-not $retval) { Write-Host("STARTING VB") }
}
elseif($TYPE -eq 'potato') {
$retval = $lib::VBVMR_RunVoicemeeter([Int64]3)
if(-not $retval) { Write-Host("STARTING VB") }
}
} else { Exit }
while(P_Dirty -or M_Dirty) { Start-Sleep -m 1 }
$ptr = 0
$retval = $lib::VBVMR_GetVoicemeeterType([ref]$ptr)
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]") }
Start-Sleep -s 1
}
DefineVersion -TYPE $ptr
}
Function Logout {
Start-Sleep -m 20
$retval = $lib::VBVMR_Logout()
if(-not $retval) { Write-Host("LOGGED OUT") }
}
Function P_Dirty {
$lib::VBVMR_IsParametersDirty()
}
Function M_Dirty {
$lib::VBVMR_MacroButton_IsDirty()
}
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
}
0..10 | ForEach-Object {
foreach($key in $($hash.keys)){
$hash[$key] = 1
}
Param_Set_Multi -HASH $hash
foreach($key in $($hash.keys)){
$hash[$key] = 0
}
Param_Set_Multi -HASH $hash
}
Logout
}

67
lib/bus.ps1 Normal file
View File

@ -0,0 +1,67 @@
class Bus {
[int32]$id
# Constructor
Bus ([Int]$id)
{
$this.id = $id
}
[void] Setter($cmd, $set) {
Param_Set -PARAM $cmd -VALUE $set
}
[int] Getter($cmd) {
return Param_Get -PARAM $cmd
}
[string] cmd ($arg) {
return "Bus[" + $this.id + "].$arg"
}
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)
}
)
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)
}
)
}
Function Buses {
[System.Collections.ArrayList]$bus = @()
0..$($layout.Bus-1) | ForEach-Object {
[void]$bus.Add([Bus]::new($_))
}
$bus
}
if ($MyInvocation.InvocationName -ne '.')
{
Login
$bus = Buses
$bus[0].mono = 1
$bus[0].mono
$bus[0].mono = 0
$bus[0].mono
Logout
}

76
lib/macrobuttons.ps1 Normal file
View File

@ -0,0 +1,76 @@
class MacroButton {
[int32]$id
# Constructor
MacroButton ([Int]$id)
{
$this.id = $id
}
[void] Setter($set, $mode) {
MB_Set -ID $this.id -SET $set -MODE $mode
}
[int] Getter($mode) {
return MB_Get -ID $this.id -MODE $mode
}
hidden $_state = $($this | Add-Member ScriptProperty 'state' `
{
# get
$this.Getter(1)
}`
{
# set
param ( $arg )
$this._state = $this.Setter($arg, 1)
}
)
hidden $_stateonly = $($this | Add-Member ScriptProperty 'stateonly' `
{
# get
$this.Getter(2)
}`
{
# set
param ( $arg )
$this._stateonly = $this.Setter($arg, 2)
}
)
hidden $_trigger = $($this | Add-Member ScriptProperty 'trigger' `
{
# get
$this.Getter(3)
}`
{
# set
param ( $arg )
$this._trigger = $this.Setter($arg, 3)
}
)
}
Function Buttons {
[System.Collections.ArrayList]$button = @()
0..69 | ForEach-Object {
[void]$button.Add([MacroButton]::new($_))
}
$button
}
if ($MyInvocation.InvocationName -ne '.')
{
Login
$button = Buttons
$button[0].state = 1
$button[0].state
$button[0].state = 0
$button[0].state
Logout
}

176
lib/strip.ps1 Normal file
View File

@ -0,0 +1,176 @@
class Strip {
[int32]$id
# Constructor
Strip ([Int]$id)
{
$this.id = $id
}
[void] Setter($cmd, $set) {
Param_Set -PARAM $cmd -VALUE $set
}
[int] Getter($cmd) {
return Param_Get -PARAM $cmd
}
[string] cmd ($arg) {
return "Strip[" + $this.id + "].$arg"
}
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)
}
)
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)
}
)
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)
}
)
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)
}
)
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)
}
)
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)
}
)
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)
}
)
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)
}
)
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)
}
)
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)
}
)
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)
}
)
}
Function Strips {
[System.Collections.ArrayList]$strip = @()
0..$($layout.Strip-1) | ForEach-Object {
[void]$strip.Add([Strip]::new($_))
}
$strip
}
if ($MyInvocation.InvocationName -ne '.')
{
Login
$strip = Strips
$strip[1].A1 = 1
$strip[1].A1
$strip[2].A2 = 0
$strip[2].A2
Logout
}

30
lib/voicemeeter.ps1 Normal file
View File

@ -0,0 +1,30 @@
. $PSScriptRoot\base.ps1
. $PSScriptRoot\strip.ps1
. $PSScriptRoot\bus.ps1
. $PSScriptRoot\macrobuttons.ps1
class Remote {
[String]$type
[System.Collections.ArrayList]$button
[System.Collections.ArrayList]$strip
[System.Collections.ArrayList]$bus
# Constructor
Remote ([String]$type)
{
$this.type = $type
}
[void] Login () {
Login -TYPE $this.type
$this.button = Buttons
$this.strip = Strips
$this.bus = Buses
}
[void] Logout () {
Logout
}
}

389
test/higher.Tests.ps1 Normal file
View File

@ -0,0 +1,389 @@
Describe -Tag 'higher', -TestName 'All Alias Tests' {
Describe 'Macrobutton Tests' {
Context 'mode = State' {
It 'Should set macrobutton[0] State to 1' {
$vmr.button[0].state = 1
$vmr.button[0].state | Should -Be 1
}
It 'Should set macrobutton[0] State to 0' {
$vmr.button[0].state = 0
$vmr.button[0].state | Should -Be 0
}
It 'Should set macrobutton[1] State to 1' {
$vmr.button[1].state = 1
$vmr.button[1].state | Should -Be 1
}
It 'Should set macrobutton[1] State to 0' {
$vmr.button[1].state = 0
$vmr.button[1].state | Should -Be 0
}
It 'Should set macrobutton[2] State to 1' {
$vmr.button[2].state = 1
$vmr.button[2].state | Should -Be 1
}
It 'Should set macrobutton[2] State to 0' {
$vmr.button[2].state = 0
$vmr.button[2].state | Should -Be 0
}
}
Context 'mode = StateOnly' {
It 'Should set macrobutton[0] StateOnly to 1' {
$vmr.button[0].stateonly = 1
$vmr.button[0].stateonly | Should -Be 1
}
It 'Should set macrobutton[0] StateOnly to 0' {
$vmr.button[0].stateonly = 0
$vmr.button[0].stateonly | Should -Be 0
}
It 'Should set macrobutton[1] StateOnly to 1' {
$vmr.button[1].stateonly = 1
$vmr.button[1].stateonly | Should -Be 1
}
It 'Should set macrobutton[1] StateOnly to 0' {
$vmr.button[1].stateonly = 0
$vmr.button[1].stateonly | Should -Be 0
}
It 'Should set macrobutton[2] StateOnly to 1' {
$vmr.button[2].stateonly = 1
$vmr.button[2].stateonly | Should -Be 1
}
It 'Should set macrobutton[2] StateOnly to 0' {
$vmr.button[2].stateonly = 0
$vmr.button[2].stateonly | Should -Be 0
}
}
Context 'mode = Trigger' {
It 'Should set macrobutton[0] Trigger to 1' {
$vmr.button[0].trigger = 1
$vmr.button[0].trigger | Should -Be 1
}
It 'Should set macrobutton[0] Trigger to 0' {
$vmr.button[0].trigger = 0
$vmr.button[0].trigger | Should -Be 0
}
It 'Should set macrobutton[1] Trigger to 1' {
$vmr.button[1].trigger = 1
$vmr.button[1].trigger | Should -Be 1
}
It 'Should set macrobutton[1] Trigger to 0' {
$vmr.button[1].trigger = 0
$vmr.button[1].trigger | Should -Be 0
}
It 'Should set macrobutton[2] Trigger to 1' {
$vmr.button[2].trigger = 1
$vmr.button[2].trigger | Should -Be 1
}
It 'Should set macrobutton[2] Trigger to 0' {
$vmr.button[2].trigger = 0
$vmr.button[2].trigger | Should -Be 0
}
}
}
Describe 'Set and Get Param Float Tests' {
Context 'Strip[i].Mute' {
It 'Should set Strip[0].Mute to 1' {
$vmr.strip[0].mute = 1
$vmr.strip[0].mute | Should -Be 1
}
It 'Should set Strip[0].Mute to 0' {
$vmr.strip[0].mute = 0
$vmr.strip[0].mute | Should -Be 0
}
It 'Should set Strip[1].Mute to 1' {
$vmr.strip[1].mute = 1
$vmr.strip[1].mute | Should -Be 1
}
It 'Should set Strip[1].Mute to 0' {
$vmr.strip[1].mute = 0
$vmr.strip[1].mute | Should -Be 0
}
It 'Should set Strip[2].Mute to 1' {
$vmr.strip[2].mute = 1
$vmr.strip[2].mute | Should -Be 1
}
It 'Should set Strip[2].Mute to 0' {
$vmr.strip[2].mute = 0
$vmr.strip[2].mute | Should -Be 0
}
}
Context 'Strip[i].Solo' {
It 'Should set Strip[0].Solo to 1' {
$vmr.strip[0].solo = 1
$vmr.strip[0].solo | Should -Be 1
}
It 'Should set Strip[0].Solo to 0' {
$vmr.strip[0].solo = 0
$vmr.strip[0].solo | Should -Be 0
}
It 'Should set Strip[1].Solo to 1' {
$vmr.strip[1].solo = 1
$vmr.strip[1].solo | Should -Be 1
}
It 'Should set Strip[1].Solo to 0' {
$vmr.strip[1].solo = 0
$vmr.strip[1].solo | Should -Be 0
}
It 'Should set Strip[2].Solo to 1' {
$vmr.strip[2].solo = 1
$vmr.strip[2].solo | Should -Be 1
}
It 'Should set Strip[2].Solo to 0' {
$vmr.strip[2].solo = 0
$vmr.strip[2].solo | Should -Be 0
}
}
Context 'Strip[i].Mono' {
It 'Should set Strip[0].Mono to 1' {
$vmr.strip[0].mono = 1
$vmr.strip[0].mono | Should -Be 1
}
It 'Should set Strip[0].Mono to 0' {
$vmr.strip[0].mono = 0
$vmr.strip[0].mono | Should -Be 0
}
It 'Should set Strip[1].Mono to 1' {
$vmr.strip[1].mono = 1
$vmr.strip[1].mono | Should -Be 1
}
It 'Should set Strip[1].Mono to 0' {
$vmr.strip[1].mono = 0
$vmr.strip[1].mono | Should -Be 0
}
It 'Should set Strip[2].Mono to 1' {
$vmr.strip[2].mono = 1
$vmr.strip[2].mono | Should -Be 1
}
It 'Should set Strip[2].Mono to 0' {
$vmr.strip[2].mono = 0
$vmr.strip[2].mono | Should -Be 0
}
}
Context 'Strip[i].A1' {
It 'Should set Strip[0].A1 to 1' {
$vmr.strip[0].A1 = 1
$vmr.strip[0].A1 | Should -Be 1
}
It 'Should set Strip[0].A1 to 0' {
$vmr.strip[0].A1 = 0
$vmr.strip[0].A1 | Should -Be 0
}
It 'Should set Strip[1].A1 to 1' {
$vmr.strip[1].A1 = 1
$vmr.strip[1].A1 | Should -Be 1
}
It 'Should set Strip[1].A1 to 0' {
$vmr.strip[1].A1 = 0
$vmr.strip[1].A1 | Should -Be 0
}
It 'Should set Strip[2].A1 to 1' {
$vmr.strip[2].A1 = 1
$vmr.strip[2].A1 | Should -Be 1
}
It 'Should set Strip[2].A1 to 0' {
$vmr.strip[2].A1 = 0
$vmr.strip[2].A1 | Should -Be 0
}
}
Context 'Strip[i].A2' {
It 'Should set Strip[0].A2 to 1' {
$vmr.strip[0].A2 = 1
$vmr.strip[0].A2 | Should -Be 1
}
It 'Should set Strip[0].v to 0' {
$vmr.strip[0].A2 = 0
$vmr.strip[0].A2 | Should -Be 0
}
It 'Should set Strip[1].A2 to 1' {
$vmr.strip[1].A2 = 1
$vmr.strip[1].A2 | Should -Be 1
}
It 'Should set Strip[1].A2 to 0' {
$vmr.strip[1].A2 = 0
$vmr.strip[1].A2 | Should -Be 0
}
It 'Should set Strip[2].A2 to 1' {
$vmr.strip[2].A2 = 1
$vmr.strip[2].A2 | Should -Be 1
}
It 'Should set Strip[2].A2 to 0' {
$vmr.strip[2].A2 = 0
$vmr.strip[2].A2 | Should -Be 0
}
}
Context 'Strip[i].A3' {
It 'Should set Strip[0].A3 to 1' {
$vmr.strip[0].A3 = 1
$vmr.strip[0].A3 | Should -Be 1
}
It 'Should set Strip[0].A3 to 0' {
$vmr.strip[0].A3 = 0
$vmr.strip[0].A3 | Should -Be 0
}
It 'Should set Strip[1].A3 to 1' {
$vmr.strip[1].A3 = 1
$vmr.strip[1].A3 | Should -Be 1
}
It 'Should set Strip[1].A3 to 0' {
$vmr.strip[1].A3 = 0
$vmr.strip[1].A3 | Should -Be 0
}
It 'Should set Strip[2].A3 to 1' {
$vmr.strip[2].A3 = 1
$vmr.strip[2].A3 | Should -Be 1
}
It 'Should set Strip[2].A3 to 0' {
$vmr.strip[2].A3 = 0
$vmr.strip[2].A3 | Should -Be 0
}
}
Context 'Strip[i].B1' {
It 'Should set Strip[0].B1 to 1' {
$vmr.strip[0].B1 = 1
$vmr.strip[0].B1 | Should -Be 1
}
It 'Should set Strip[0].B1 to 0' {
$vmr.strip[0].B1 = 0
$vmr.strip[0].B1 | Should -Be 0
}
It 'Should set Strip[1].B1 to 1' {
$vmr.strip[1].B1 = 1
$vmr.strip[1].B1 | Should -Be 1
}
It 'Should set Strip[1].B1 to 0' {
$vmr.strip[1].B1 = 0
$vmr.strip[1].B1 | Should -Be 0
}
It 'Should set Strip[2].B1 to 1' {
$vmr.strip[2].B1 = 1
$vmr.strip[2].B1 | Should -Be 1
}
It 'Should set Strip[2].B1 to 0' {
$vmr.strip[2].B1 = 0
$vmr.strip[2].B1 | Should -Be 0
}
}
Context 'Strip[i].B2' {
It 'Should set Strip[0].B2 to 1' {
$vmr.strip[0].B2 = 1
$vmr.strip[0].B2 | Should -Be 1
}
It 'Should set Strip[0].B2 to 0' {
$vmr.strip[0].B2 = 0
$vmr.strip[0].B2 | Should -Be 0
}
It 'Should set Strip[1].B2 to 1' {
$vmr.strip[1].B2 = 1
$vmr.strip[1].B2 | Should -Be 1
}
It 'Should set Strip[1].B2 to 0' {
$vmr.strip[1].B2 = 0
$vmr.strip[1].B2 | Should -Be 0
}
It 'Should set Strip[2].B2 to 1' {
$vmr.strip[2].B2 = 1
$vmr.strip[2].B2 | Should -Be 1
}
It 'Should set Strip[2].B2 to 0' {
$vmr.strip[2].B2 = 0
$vmr.strip[2].B2 | Should -Be 0
}
}
Context 'Strip[i].B3' {
It 'Should set Strip[0].B3 to 1' {
$vmr.strip[0].B3 = 1
$vmr.strip[0].B3 | Should -Be 1
}
It 'Should set Strip[0].B3 to 0' {
$vmr.strip[0].B3 = 0
$vmr.strip[0].B3 | Should -Be 0
}
It 'Should set Strip[1].B3 to 1' {
$vmr.strip[1].B3 = 1
$vmr.strip[1].B3 | Should -Be 1
}
It 'Should set Strip[1].B3 to 0' {
$vmr.strip[1].B3 = 0
$vmr.strip[1].B3 | Should -Be 0
}
It 'Should set Strip[2].B3 to 1' {
$vmr.strip[2].B3 = 1
$vmr.strip[2].B3 | Should -Be 1
}
It 'Should set Strip[2].B3 to 0' {
$vmr.strip[2].B3 = 0
$vmr.strip[2].B3 | Should -Be 0
}
}
}
}

410
test/lower.Tests.ps1 Normal file
View File

@ -0,0 +1,410 @@
Describe -Tag 'lower', -TestName 'All Tests' {
Describe 'Macrobutton Tests' {
Context 'mode = State' {
It 'Should set macrobutton[0] State to 1' {
MB_Set -ID 0 -SET 1 -MODE 1
MB_Get -ID 0 -MODE 1 | Should -Be 1
}
It 'Should set macrobutton[0] State to 0' {
MB_Set -ID 0 -SET 0 -MODE 1
MB_Get -ID 0 -MODE 1 | Should -Be 0
}
It 'Should set macrobutton[1] State to 1' {
MB_Set -ID 1 -SET 1 -MODE 1
MB_Get -ID 1 -MODE 1 | Should -Be 1
}
It 'Should set macrobutton[1] State to 0' {
MB_Set -ID 1 -SET 0 -MODE 1
MB_Get -ID 1 -MODE 1 | Should -Be 0
}
It 'Should set macrobutton[2] State to 1' {
MB_Set -ID 2 -SET 1 -MODE 1
MB_Get -ID 2 -MODE 1 | Should -Be 1
}
It 'Should set macrobutton[2] State to 0' {
MB_Set -ID 2 -SET 0 -MODE 1
MB_Get -ID 2 -MODE 1 | Should -Be 0
}
}
Context 'mode = StateOnly' {
It 'Should set macrobutton[0] StateOnly to 1' {
MB_Set -ID 0 -SET 1 -MODE 2
MB_Get -ID 0 -MODE 2 | Should -Be 1
}
It 'Should set macrobutton[0] StateOnly to 0' {
MB_Set -ID 0 -SET 0 -MODE 2
MB_Get -ID 0 -MODE 2 | Should -Be 0
}
It 'Should set macrobutton[1] StateOnly to 1' {
MB_Set -ID 1 -SET 1 -MODE 2
MB_Get -ID 1 -MODE 2 | Should -Be 1
}
It 'Should set macrobutton[1] StateOnly to 0' {
MB_Set -ID 1 -SET 0 -MODE 2
MB_Get -ID 1 -MODE 2 | Should -Be 0
}
It 'Should set macrobutton[2] StateOnly to 1' {
MB_Set -ID 2 -SET 1 -MODE 2
MB_Get -ID 2 -MODE 2 | Should -Be 1
}
It 'Should set macrobutton[2] StateOnly to 0' {
MB_Set -ID 2 -SET 0 -MODE 2
MB_Get -ID 2 -MODE 2 | Should -Be 0
}
}
Context 'mode = Trigger' {
It 'Should set macrobutton[0] Trigger to 1' {
MB_Set -ID 0 -SET 1 -MODE 3
MB_Get -ID 0 -MODE 3 | Should -Be 1
}
It 'Should set macrobutton[0] Trigger to 0' {
MB_Set -ID 0 -SET 0 -MODE 3
MB_Get -ID 0 -MODE 3 | Should -Be 0
}
It 'Should set macrobutton[1] Trigger to 1' {
MB_Set -ID 1 -SET 1 -MODE 3
MB_Get -ID 1 -MODE 3 | Should -Be 1
}
It 'Should set macrobutton[1] Trigger to 0' {
MB_Set -ID 1 -SET 0 -MODE 3
MB_Get -ID 1 -MODE 3 | Should -Be 0
}
It 'Should set macrobutton[2] Trigger to 1' {
MB_Set -ID 2 -SET 1 -MODE 3
MB_Get -ID 2 -MODE 3 | Should -Be 1
}
It 'Should set macrobutton[2] Trigger to 0' {
MB_Set -ID 2 -SET 0 -MODE 3
MB_Get -ID 2 -MODE 3 | Should -Be 0
}
}
}
Describe 'Set and Get Param Float Tests' {
Context 'Strip[i].Mute' {
It 'Should set Strip[0].Mute to 1' {
Param_Set -PARAM "Strip[0].Mute" -VALUE 1
Param_Get -PARAM "Strip[0].Mute" | Should -Be 1
}
It 'Should set Strip[0].Mute to 0' {
Param_Set -PARAM "Strip[0].Mute" -VALUE 0
Param_Get -PARAM "Strip[0].Mute" | Should -Be 0
}
It 'Should set Strip[1].Mute to 1' {
Param_Set -PARAM "Strip[1].Mute" -VALUE 1
Param_Get -PARAM "Strip[1].Mute" | Should -Be 1
}
It 'Should set Strip[1].Mute to 0' {
Param_Set -PARAM "Strip[1].Mute" -VALUE 0
Param_Get -PARAM "Strip[1].Mute" | Should -Be 0
}
It 'Should set Strip[2].Mute to 1' {
Param_Set -PARAM "Strip[2].Mute" -VALUE 1
Param_Get -PARAM "Strip[2].Mute" | Should -Be 1
}
It 'Should set Strip[2].Mute to 0' {
Param_Set -PARAM "Strip[2].Mute" -VALUE 0
Param_Get -PARAM "Strip[2].Mute" | Should -Be 0
}
}
Context 'Strip[i].Solo' {
It 'Should set Strip[0].Solo to 1' {
Param_Set -PARAM "Strip[0].Solo" -VALUE 1
Param_Get -PARAM "Strip[0].Solo" | Should -Be 1
}
It 'Should set Strip[0].Solo to 0' {
Param_Set -PARAM "Strip[0].Solo" -VALUE 0
Param_Get -PARAM "Strip[0].Solo" | Should -Be 0
}
It 'Should set Strip[1].Solo to 1' {
Param_Set -PARAM "Strip[1].Solo" -VALUE 1
Param_Get -PARAM "Strip[1].Solo" | Should -Be 1
}
It 'Should set Strip[1].Solo to 0' {
Param_Set -PARAM "Strip[1].Solo" -VALUE 0
Param_Get -PARAM "Strip[1].Solo" | Should -Be 0
}
It 'Should set Strip[2].Solo to 1' {
Param_Set -PARAM "Strip[2].Solo" -VALUE 1
Param_Get -PARAM "Strip[2].Solo" | Should -Be 1
}
It 'Should set Strip[2].Solo to 0' {
Param_Set -PARAM "Strip[2].Solo" -VALUE 0
Param_Get -PARAM "Strip[2].Solo" | Should -Be 0
}
}
Context 'Strip[i].Mono' {
It 'Should set Strip[0].Mono to 1' {
Param_Set -PARAM "Strip[0].Mono" -VALUE 1
Param_Get -PARAM "Strip[0].Mono" | Should -Be 1
}
It 'Should set Strip[0].Mono to 0' {
Param_Set -PARAM "Strip[0].Mono" -VALUE 0
Param_Get -PARAM "Strip[0].Mono" | Should -Be 0
}
It 'Should set Strip[1].Mono to 1' {
Param_Set -PARAM "Strip[1].Mono" -VALUE 1
Param_Get -PARAM "Strip[1].Mono" | Should -Be 1
}
It 'Should set Strip[1].Mono to 0' {
Param_Set -PARAM "Strip[1].Mono" -VALUE 0
Param_Get -PARAM "Strip[1].Mono" | Should -Be 0
}
It 'Should set Strip[2].Mono to 1' {
Param_Set -PARAM "Strip[2].Mono" -VALUE 1
Param_Get -PARAM "Strip[2].Mono" | Should -Be 1
}
It 'Should set Strip[2].Mono to 0' {
Param_Set -PARAM "Strip[2].Mono" -VALUE 0
Param_Get -PARAM "Strip[2].Mono" | Should -Be 0
}
}
Context 'Strip[i].A1' {
It 'Should set Strip[0].A1 to 1' {
Param_Set -PARAM "Strip[0].A1" -VALUE 1
Param_Get -PARAM "Strip[0].A1" | Should -Be 1
}
It 'Should set Strip[0].A1 to 0' {
Param_Set -PARAM "Strip[0].A1" -VALUE 0
Param_Get -PARAM "Strip[0].A1" | Should -Be 0
}
It 'Should set Strip[1].A1 to 1' {
Param_Set -PARAM "Strip[1].A1" -VALUE 1
Param_Get -PARAM "Strip[1].A1" | Should -Be 1
}
It 'Should set Strip[1].A1 to 0' {
Param_Set -PARAM "Strip[1].A1" -VALUE 0
Param_Get -PARAM "Strip[1].A1" | Should -Be 0
}
It 'Should set Strip[2].A1 to 1' {
Param_Set -PARAM "Strip[2].A1" -VALUE 1
Param_Get -PARAM "Strip[2].A1" | Should -Be 1
}
It 'Should set Strip[2].A1 to 0' {
Param_Set -PARAM "Strip[2].A1" -VALUE 0
Param_Get -PARAM "Strip[2].A1" | Should -Be 0
}
}
Context 'Strip[i].A2' {
It 'Should set Strip[0].A2 to 1' {
Param_Set -PARAM "Strip[0].A2" -VALUE 1
Param_Get -PARAM "Strip[0].A2" | Should -Be 1
}
It 'Should set Strip[0].A2 to 0' {
Param_Set -PARAM "Strip[0].A2" -VALUE 0
Param_Get -PARAM "Strip[0].A2" | Should -Be 0
}
It 'Should set Strip[1].A2 to 1' {
Param_Set -PARAM "Strip[1].A2" -VALUE 1
Param_Get -PARAM "Strip[1].A2" | Should -Be 1
}
It 'Should set Strip[1].A2 to 0' {
Param_Set -PARAM "Strip[1].A2" -VALUE 0
Param_Get -PARAM "Strip[1].A2" | Should -Be 0
}
It 'Should set Strip[2].A2 to 1' {
Param_Set -PARAM "Strip[2].A2" -VALUE 1
Param_Get -PARAM "Strip[2].A2" | Should -Be 1
}
It 'Should set Strip[2].A2 to 0' {
Param_Set -PARAM "Strip[2].A2" -VALUE 0
Param_Get -PARAM "Strip[2].A2" | Should -Be 0
}
}
Context 'Strip[i].A3' {
It 'Should set Strip[0].A3 to 1' {
Param_Set -PARAM "Strip[0].A3" -VALUE 1
Param_Get -PARAM "Strip[0].A3" | Should -Be 1
}
It 'Should set Strip[0].A3 to 0' {
Param_Set -PARAM "Strip[0].A3" -VALUE 0
Param_Get -PARAM "Strip[0].A3" | Should -Be 0
}
It 'Should set Strip[1].A3 to 1' {
Param_Set -PARAM "Strip[1].A3" -VALUE 1
Param_Get -PARAM "Strip[1].A3" | Should -Be 1
}
It 'Should set Strip[1].A3 to 0' {
Param_Set -PARAM "Strip[1].A3" -VALUE 0
Param_Get -PARAM "Strip[1].A3" | Should -Be 0
}
It 'Should set Strip[2].A3 to 1' {
Param_Set -PARAM "Strip[2].A3" -VALUE 1
Param_Get -PARAM "Strip[2].A3" | Should -Be 1
}
It 'Should set Strip[2].A3 to 0' {
Param_Set -PARAM "Strip[2].A3" -VALUE 0
Param_Get -PARAM "Strip[2].A3" | Should -Be 0
}
}
Context 'Strip[i].B1' {
It 'Should set Strip[0].B1 to 1' {
Param_Set -PARAM "Strip[0].B1" -VALUE 1
Param_Get -PARAM "Strip[0].B1" | Should -Be 1
}
It 'Should set Strip[0].B1 to 0' {
Param_Set -PARAM "Strip[0].B1" -VALUE 0
Param_Get -PARAM "Strip[0].B1" | Should -Be 0
}
It 'Should set Strip[1].B1 to 1' {
Param_Set -PARAM "Strip[1].B1" -VALUE 1
Param_Get -PARAM "Strip[1].B1" | Should -Be 1
}
It 'Should set Strip[1].B1 to 0' {
Param_Set -PARAM "Strip[1].B1" -VALUE 0
Param_Get -PARAM "Strip[1].B1" | Should -Be 0
}
It 'Should set Strip[2].B1 to 1' {
Param_Set -PARAM "Strip[2].B1" -VALUE 1
Param_Get -PARAM "Strip[2].B1" | Should -Be 1
}
It 'Should set Strip[2].B1 to 0' {
Param_Set -PARAM "Strip[2].B1" -VALUE 0
Param_Get -PARAM "Strip[2].B1" | Should -Be 0
}
}
Context 'Strip[i].B2' {
It 'Should set Strip[0].B2 to 1' {
Param_Set -PARAM "Strip[0].B2" -VALUE 1
Param_Get -PARAM "Strip[0].B2" | Should -Be 1
}
It 'Should set Strip[0].B2 to 0' {
Param_Set -PARAM "Strip[0].B2" -VALUE 0
Param_Get -PARAM "Strip[0].B2" | Should -Be 0
}
It 'Should set Strip[1].B2 to 1' {
Param_Set -PARAM "Strip[1].B2" -VALUE 1
Param_Get -PARAM "Strip[1].B2" | Should -Be 1
}
It 'Should set Strip[1].B2 to 0' {
Param_Set -PARAM "Strip[1].B2" -VALUE 0
Param_Get -PARAM "Strip[1].B2" | Should -Be 0
}
It 'Should set Strip[2].B2 to 1' {
Param_Set -PARAM "Strip[2].B2" -VALUE 1
Param_Get -PARAM "Strip[2].B2" | Should -Be 1
}
It 'Should set Strip[2].B2 to 0' {
Param_Set -PARAM "Strip[2].B2" -VALUE 0
Param_Get -PARAM "Strip[2].B2" | Should -Be 0
}
}
}
Describe 'Set and Get Param String Tests' {
Context 'Strip[i].Label test0' {
It 'Should set Strip[0].Label to test0' {
Param_Set_String -PARAM "Strip[0].Label" -VALUE 'test0'
Param_Get_String -PARAM "Strip[0].Label" | Should -Be 'test0'
}
It 'Should set Strip[1].Label to test0' {
Param_Set_String -PARAM "Strip[1].Label" -VALUE 'test0'
Param_Get_String -PARAM "Strip[1].Label" | Should -Be 'test0'
}
It 'Should set Strip[2].Label to test0' {
Param_Set_String -PARAM "Strip[2].Label" -VALUE 'test0'
Param_Get_String -PARAM "Strip[2].Label" | Should -Be 'test0'
}
}
Context 'Strip[i].Label test1' {
It 'Should set Strip[0].Label to test1' {
Param_Set_String -PARAM "Strip[0].Label" -VALUE 'test1'
Param_Get_String -PARAM "Strip[0].Label" | Should -Be 'test1'
}
It 'Should set Strip[1].Label to test1' {
Param_Set_String -PARAM "Strip[1].Label" -VALUE 'test1'
Param_Get_String -PARAM "Strip[1].Label" | Should -Be 'test1'
}
It 'Should set Strip[2].Label to test1' {
Param_Set_String -PARAM "Strip[2].Label" -VALUE 'test1'
Param_Get_String -PARAM "Strip[2].Label" | Should -Be 'test1'
}
}
Context 'Strip[i].Label test2' {
It 'Should set Strip[0].Label to test2' {
Param_Set_String -PARAM "Strip[0].Label" -VALUE 'test2'
Param_Get_String -PARAM "Strip[0].Label" | Should -Be 'test2'
}
It 'Should set Strip[1].Label to test2' {
Param_Set_String -PARAM "Strip[1].Label" -VALUE 'test2'
Param_Get_String -PARAM "Strip[1].Label" | Should -Be 'test2'
}
It 'Should set Strip[2].Label to test2' {
Param_Set_String -PARAM "Strip[2].Label" -VALUE 'test2'
Param_Get_String -PARAM "Strip[2].Label" | Should -Be 'test2'
}
}
}
}

21
test/runall.ps1 Normal file
View File

@ -0,0 +1,21 @@
Param(
[String]$tag, [Int]$num=1
)
try
{
. ..\lib\voicemeeter.ps1
$vmr = [Remote]::new('banana')
$vmr.Login()
1..$num | ForEach-Object {
Write-Host "Running test $_ of $num"
Invoke-Pester -Tag $tag
}
}
finally
{
$vmr.Logout()
}