2021-04-29 20:23:02 +01:00
|
|
|
. $PSScriptRoot\errors.ps1
|
2022-06-25 23:12:02 +01:00
|
|
|
. $PSScriptRoot\binding.ps1
|
|
|
|
. $PSScriptRoot\profiles.ps1
|
2021-05-04 17:29:38 +01:00
|
|
|
. $PSScriptRoot\inst.ps1
|
2021-04-28 18:21:32 +01:00
|
|
|
. $PSScriptRoot\strip.ps1
|
|
|
|
. $PSScriptRoot\bus.ps1
|
|
|
|
. $PSScriptRoot\macrobuttons.ps1
|
2021-05-11 19:09:57 +01:00
|
|
|
. $PSScriptRoot\vban.ps1
|
2022-01-19 21:53:49 +00:00
|
|
|
. $PSScriptRoot\command.ps1
|
2022-03-08 22:54:34 +00:00
|
|
|
. $PSScriptRoot\recorder.ps1
|
2021-04-28 18:21:32 +01:00
|
|
|
|
2022-10-27 21:20:03 +01:00
|
|
|
function Login {
|
2022-06-25 23:12:02 +01:00
|
|
|
param(
|
2022-10-27 21:20:03 +01:00
|
|
|
[string]$KIND = $null
|
2022-06-25 23:12:02 +01:00
|
|
|
)
|
2021-05-04 17:29:38 +01:00
|
|
|
try {
|
2022-10-27 21:20:03 +01:00
|
|
|
$retval = [int][Voicemeeter.Remote]::VBVMR_Login()
|
|
|
|
if (-not $retval) { "LOGGED IN" | Write-Verbose }
|
2022-06-25 23:12:02 +01:00
|
|
|
elseif ($retval -eq 1) {
|
2022-10-27 21:20:03 +01:00
|
|
|
"VM NOT RUNNING" | Write-Verbose
|
2022-06-25 23:12:02 +01:00
|
|
|
New-Variable -Name vm_exe -Value 0
|
2021-05-04 17:29:38 +01:00
|
|
|
|
2022-10-27 21:20:03 +01:00
|
|
|
switch ($KIND) {
|
|
|
|
'basic' { $vm_exe = 1; break }
|
|
|
|
'banana' { $vm_exe = 2; break }
|
2022-06-25 23:12:02 +01:00
|
|
|
'potato' {
|
|
|
|
if ([Environment]::Is64BitOperatingSystem) {
|
|
|
|
$vm_exe = 6
|
|
|
|
}
|
|
|
|
else { $vm_exe = 3 }
|
2022-10-27 21:20:03 +01:00
|
|
|
break
|
2022-06-25 23:12:02 +01:00
|
|
|
}
|
2022-10-27 21:20:03 +01:00
|
|
|
default { throw [LoginError]::new('Unknown Voicemeeter type') }
|
2022-06-25 23:12:02 +01:00
|
|
|
}
|
|
|
|
|
2022-10-27 21:20:03 +01:00
|
|
|
$retval = [int][Voicemeeter.Remote]::VBVMR_RunVoicemeeter([int64]$vm_exe)
|
|
|
|
if (-not $retval) { "STARTING VOICEMEETER" | Write-Verbose }
|
|
|
|
else { throw [CAPIError]::new($retval, $MyInvocation.MyCommand) }
|
2022-06-25 23:12:02 +01:00
|
|
|
Start-Sleep -s 1
|
2021-05-04 17:29:38 +01:00
|
|
|
}
|
2022-10-27 21:20:03 +01:00
|
|
|
elseif ($retval -eq -2) {
|
2022-06-25 23:12:02 +01:00
|
|
|
throw [LoginError]::new('Login may only be called once per session')
|
2021-05-04 17:29:38 +01:00
|
|
|
}
|
2022-10-30 19:10:17 +00:00
|
|
|
else { throw [CAPIError]::new($retval, $MyInvocation.MyCommand) }
|
2021-05-04 17:29:38 +01:00
|
|
|
}
|
2022-06-25 23:12:02 +01:00
|
|
|
catch [LoginError], [CAPIError] {
|
2021-05-04 17:29:38 +01:00
|
|
|
Write-Warning $_.Exception.ErrorMessage()
|
2022-12-17 20:10:53 +00:00
|
|
|
throw
|
2021-05-04 17:29:38 +01:00
|
|
|
}
|
|
|
|
|
2022-06-25 23:12:02 +01:00
|
|
|
while (P_Dirty -or M_Dirty) { Start-Sleep -m 1 }
|
2022-10-27 21:20:03 +01:00
|
|
|
"VERSION:[" + $(VmType).ToUpper() + "]" | Write-Verbose
|
2022-06-25 23:12:02 +01:00
|
|
|
}
|
2021-04-28 17:38:36 +01:00
|
|
|
|
2022-10-27 21:20:03 +01:00
|
|
|
function Logout {
|
2022-06-25 23:12:02 +01:00
|
|
|
Start-Sleep -m 20
|
2022-10-27 21:20:03 +01:00
|
|
|
$retval = [int][Voicemeeter.Remote]::VBVMR_Logout()
|
|
|
|
if (-not $retval) { "LOGGED OUT" | Write-Verbose }
|
|
|
|
}
|
|
|
|
|
|
|
|
function P_Dirty {
|
|
|
|
[bool][Voicemeeter.Remote]::VBVMR_IsParametersDirty()
|
2022-06-25 23:12:02 +01:00
|
|
|
}
|
2021-04-28 17:38:36 +01:00
|
|
|
|
2022-10-27 21:20:03 +01:00
|
|
|
function M_Dirty {
|
|
|
|
[bool][Voicemeeter.Remote]::VBVMR_MacroButton_IsDirty()
|
2022-06-25 23:12:02 +01:00
|
|
|
}
|
2021-04-28 17:38:36 +01:00
|
|
|
|
2022-10-27 21:20:03 +01:00
|
|
|
function VmType {
|
|
|
|
New-Variable -Name ptr -Value 0
|
|
|
|
$retval = [int][Voicemeeter.Remote]::VBVMR_GetVoicemeeterType([ref]$ptr)
|
|
|
|
if ($retval) { throw [CAPIError]::new($retval, $MyInvocation.MyCommand) }
|
|
|
|
switch ($ptr) {
|
|
|
|
1 { return "basic" }
|
|
|
|
2 { return "banana" }
|
|
|
|
3 { return "potato" }
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
function Version {
|
|
|
|
New-Variable -Name ptr -Value 0
|
|
|
|
$retval = [int][Voicemeeter.Remote]::VBVMR_GetVoicemeeterVersion([ref]$ptr)
|
|
|
|
if ($retval) { throw [CAPIError]::new($retval, $MyInvocation.MyCommand) }
|
|
|
|
$v1 = ($ptr -band 0xFF000000) -shr 24
|
|
|
|
$v2 = ($ptr -band 0x00FF0000) -shr 16
|
|
|
|
$v3 = ($ptr -band 0x0000FF00) -shr 8
|
|
|
|
$v4 = $ptr -band 0x000000FF
|
|
|
|
"$v1.$v2.$v3.$v4"
|
2021-05-04 17:29:38 +01:00
|
|
|
}
|
2021-04-28 17:38:36 +01:00
|
|
|
|
2022-06-25 23:12:02 +01:00
|
|
|
|
2022-10-27 21:20:03 +01:00
|
|
|
function Param_Get {
|
2021-04-28 17:38:36 +01:00
|
|
|
param(
|
2022-10-27 21:20:03 +01:00
|
|
|
[string]$PARAM, [bool]$IS_STRING = $false
|
2021-04-28 17:38:36 +01:00
|
|
|
)
|
|
|
|
Start-Sleep -m 50
|
2022-06-25 15:20:36 +01:00
|
|
|
while (P_Dirty) { Start-Sleep -m 1 }
|
2021-04-28 17:38:36 +01:00
|
|
|
|
2022-06-25 15:20:36 +01:00
|
|
|
if ($IS_STRING) {
|
2022-01-19 21:53:49 +00:00
|
|
|
$BYTES = [System.Byte[]]::new(512)
|
|
|
|
try {
|
2022-10-27 21:20:03 +01:00
|
|
|
$retval = [int][Voicemeeter.Remote]::VBVMR_GetParameterStringA($PARAM, $BYTES)
|
|
|
|
if ($retval) { throw [CAPIError]::new($retval, $MyInvocation.MyCommand) }
|
2022-01-19 21:53:49 +00:00
|
|
|
}
|
|
|
|
catch [CAPIError] {
|
|
|
|
Write-Warning $_.Exception.ErrorMessage()
|
|
|
|
}
|
2022-10-27 21:20:03 +01:00
|
|
|
[System.Text.Encoding]::ASCII.GetString($BYTES).Trim([char]0)
|
2021-04-29 20:23:02 +01:00
|
|
|
}
|
2022-01-19 21:53:49 +00:00
|
|
|
else {
|
|
|
|
New-Variable -Name ptr -Value 0.0
|
|
|
|
try {
|
2022-10-27 21:20:03 +01:00
|
|
|
$retval = [int][Voicemeeter.Remote]::VBVMR_GetParameterFloat($PARAM, [ref]$ptr)
|
|
|
|
if ($retval) { throw [CAPIError]::new($retval, $MyInvocation.MyCommand) }
|
2022-01-19 21:53:49 +00:00
|
|
|
}
|
|
|
|
catch [CAPIError] {
|
|
|
|
Write-Warning $_.Exception.ErrorMessage()
|
|
|
|
}
|
2022-10-27 21:20:03 +01:00
|
|
|
[single]$ptr
|
2021-04-29 20:23:02 +01:00
|
|
|
}
|
2021-04-28 17:38:36 +01:00
|
|
|
}
|
|
|
|
|
2022-10-27 21:20:03 +01:00
|
|
|
function Param_Set {
|
2021-04-28 17:38:36 +01:00
|
|
|
param(
|
2022-10-27 21:20:03 +01:00
|
|
|
[string]$PARAM, [Object]$VALUE
|
2021-04-28 17:38:36 +01:00
|
|
|
)
|
2021-04-29 20:23:02 +01:00
|
|
|
try {
|
2022-10-27 21:20:03 +01:00
|
|
|
if ($VALUE -is [string]) {
|
|
|
|
$retval = [int][Voicemeeter.Remote]::VBVMR_SetParameterStringA($PARAM, $VALUE)
|
2022-01-19 21:53:49 +00:00
|
|
|
}
|
|
|
|
else {
|
2022-10-27 21:20:03 +01:00
|
|
|
$retval = [int][Voicemeeter.Remote]::VBVMR_SetParameterFloat($PARAM, $VALUE)
|
2022-01-19 21:53:49 +00:00
|
|
|
}
|
2022-10-27 21:20:03 +01:00
|
|
|
if ($retval) { throw [CAPIError]::new($retval, $MyInvocation.MyCommand) }
|
2021-04-29 20:23:02 +01:00
|
|
|
}
|
|
|
|
catch [CAPIError] {
|
|
|
|
Write-Warning $_.Exception.ErrorMessage()
|
|
|
|
}
|
2021-04-28 17:38:36 +01:00
|
|
|
}
|
|
|
|
|
2022-10-27 21:20:03 +01:00
|
|
|
function MB_Set {
|
2021-04-28 17:38:36 +01:00
|
|
|
param(
|
2022-10-27 21:20:03 +01:00
|
|
|
[int64]$ID, [single]$SET, [int64]$MODE
|
2021-04-28 17:38:36 +01:00
|
|
|
)
|
2021-04-29 20:23:02 +01:00
|
|
|
try {
|
2022-10-27 21:20:03 +01:00
|
|
|
$retval = [int][Voicemeeter.Remote]::VBVMR_MacroButton_SetStatus($ID, $SET, $MODE)
|
|
|
|
if ($retval) { throw [CAPIError]::new($retval, $MyInvocation.MyCommand) }
|
2021-04-29 20:23:02 +01:00
|
|
|
}
|
|
|
|
catch [CAPIError] {
|
|
|
|
Write-Warning $_.Exception.ErrorMessage()
|
|
|
|
}
|
2021-04-28 17:38:36 +01:00
|
|
|
}
|
|
|
|
|
2022-10-27 21:20:03 +01:00
|
|
|
function MB_Get {
|
2021-04-28 17:38:36 +01:00
|
|
|
param(
|
2022-10-27 21:20:03 +01:00
|
|
|
[int64]$ID, [int64]$MODE
|
2021-04-28 17:38:36 +01:00
|
|
|
)
|
|
|
|
Start-Sleep -m 50
|
2022-06-25 15:20:36 +01:00
|
|
|
while (M_Dirty) { Start-Sleep -m 1 }
|
2021-04-28 17:38:36 +01:00
|
|
|
|
2021-04-29 20:23:02 +01:00
|
|
|
New-Variable -Name ptr -Value 0.0
|
|
|
|
try {
|
2022-10-27 21:20:03 +01:00
|
|
|
$retval = [int][Voicemeeter.Remote]::VBVMR_MacroButton_GetStatus($ID, [ref]$ptr, $MODE)
|
|
|
|
if ($retval) { throw [CAPIError]::new($retval, $MyInvocation.MyCommand) }
|
2021-04-29 20:23:02 +01:00
|
|
|
}
|
|
|
|
catch [CAPIError] {
|
|
|
|
Write-Warning $_.Exception.ErrorMessage()
|
|
|
|
}
|
2022-10-27 21:20:03 +01:00
|
|
|
[int]$ptr
|
2021-04-28 17:38:36 +01:00
|
|
|
}
|
|
|
|
|
2022-10-27 21:20:03 +01:00
|
|
|
function Param_Set_Multi {
|
2022-01-19 21:53:49 +00:00
|
|
|
param(
|
2022-10-27 21:20:03 +01:00
|
|
|
[hashtable]$HASH
|
2022-01-19 21:53:49 +00:00
|
|
|
)
|
2022-10-27 21:20:03 +01:00
|
|
|
foreach ($key in $HASH.keys) {
|
|
|
|
$classobj, $m2, $m3 = $key.Split("_")
|
2022-06-25 15:20:36 +01:00
|
|
|
if ($m2 -match "^\d+$") { $index = [int]$m2 } else { $index = [int]$m3 }
|
2022-01-19 21:53:49 +00:00
|
|
|
|
2022-10-27 21:20:03 +01:00
|
|
|
foreach ($h in $HASH[$key].GetEnumerator()) {
|
2022-01-19 21:53:49 +00:00
|
|
|
$property = $h.Name
|
|
|
|
$value = $h.Value
|
|
|
|
if ($value -in ('False', 'True')) { [System.Convert]::ToBoolean($value) }
|
|
|
|
|
2022-10-27 21:20:03 +01:00
|
|
|
switch ($classobj) {
|
2022-01-19 21:53:49 +00:00
|
|
|
'strip' { $this.strip[$index].$property = $value }
|
|
|
|
'bus' { $this.bus[$index].$property = $value }
|
2022-06-25 15:20:36 +01:00
|
|
|
{ ($_ -eq 'button') -or ($_ -eq 'mb') } { $this.button[$index].$property = $value }
|
2022-01-19 21:53:49 +00:00
|
|
|
'vban' { $this.vban.$m2[$index].$property = $value }
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2022-10-27 21:20:03 +01:00
|
|
|
|
|
|
|
function Set_By_Script {
|
|
|
|
param(
|
|
|
|
[string]$script
|
|
|
|
)
|
|
|
|
try {
|
|
|
|
$retval = [int][Voicemeeter.Remote]::VBVMR_SetParameters($script)
|
|
|
|
if ($retval) { throw [CAPIError]::new($retval, $MyInvocation.MyCommand) }
|
|
|
|
}
|
|
|
|
catch [CAPIError] {
|
|
|
|
Write-Warning $_.Exception.ErrorMessage()
|
|
|
|
}
|
|
|
|
}
|