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

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