mirror of
https://github.com/onyx-and-iris/voicemeeter-api-powershell.git
synced 2025-01-18 05:10:48 +00:00
debug statements added to getters and setters
made some rearrangements to the dot sourcing ButtonTypes enum added to macrobuttons.ps1 login string now includes version number Test-RegistryValue added to inst.ps1
This commit is contained in:
parent
ff1bd5e6cc
commit
1397c14522
@ -1,14 +1,22 @@
|
|||||||
. $PSScriptRoot\kinds.ps1
|
. $PSScriptRoot\errors.ps1
|
||||||
|
. $PSScriptRoot\meta.ps1
|
||||||
. $PSScriptRoot\base.ps1
|
. $PSScriptRoot\base.ps1
|
||||||
|
. $PSScriptRoot\kinds.ps1
|
||||||
|
. $PSScriptRoot\strip.ps1
|
||||||
|
. $PSScriptRoot\bus.ps1
|
||||||
|
. $PSScriptRoot\macrobuttons.ps1
|
||||||
|
. $PSScriptRoot\vban.ps1
|
||||||
|
. $PSScriptRoot\command.ps1
|
||||||
|
. $PSScriptRoot\recorder.ps1
|
||||||
|
. $PSScriptRoot\profiles.ps1
|
||||||
|
|
||||||
class Remote {
|
class Remote {
|
||||||
|
[String]$vmpath
|
||||||
[Hashtable]$kind
|
[Hashtable]$kind
|
||||||
[Object]$profiles
|
[Object]$profiles
|
||||||
|
|
||||||
Remote ([String]$kindId) {
|
Remote ([String]$kindId) {
|
||||||
if (!(Setup_DLL)) {
|
$this.vmpath = Setup_DLL
|
||||||
Exit -1
|
|
||||||
}
|
|
||||||
$this.kind = GetKind($kindId)
|
$this.kind = GetKind($kindId)
|
||||||
$this.profiles = Get_Profiles($this.kind.name)
|
$this.profiles = Get_Profiles($this.kind.name)
|
||||||
}
|
}
|
||||||
@ -31,7 +39,7 @@ class Remote {
|
|||||||
}
|
}
|
||||||
|
|
||||||
[String] GetVersion() {
|
[String] GetVersion() {
|
||||||
return Version
|
return VmVersion
|
||||||
}
|
}
|
||||||
|
|
||||||
[void] Set_Profile([String]$config) {
|
[void] Set_Profile([String]$config) {
|
||||||
@ -147,6 +155,12 @@ Function Connect-Voicemeeter {
|
|||||||
Write-Warning $_.Exception.ErrorMessage()
|
Write-Warning $_.Exception.ErrorMessage()
|
||||||
throw
|
throw
|
||||||
}
|
}
|
||||||
|
catch [VMRemoteError] {
|
||||||
|
$_.Exception.ErrorMessage() | Write-Warning
|
||||||
|
if ($_.Exception.ErrorMessage() -eq "Couldn't get Voicemeeter path") {
|
||||||
|
Exit -1
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Function Disconnect-Voicemeeter {
|
Function Disconnect-Voicemeeter {
|
||||||
|
62
lib/base.ps1
62
lib/base.ps1
@ -1,13 +1,5 @@
|
|||||||
. $PSScriptRoot\errors.ps1
|
. $PSScriptRoot\errors.ps1
|
||||||
. $PSScriptRoot\binding.ps1
|
. $PSScriptRoot\binding.ps1
|
||||||
. $PSScriptRoot\profiles.ps1
|
|
||||||
. $PSScriptRoot\inst.ps1
|
|
||||||
. $PSScriptRoot\strip.ps1
|
|
||||||
. $PSScriptRoot\bus.ps1
|
|
||||||
. $PSScriptRoot\macrobuttons.ps1
|
|
||||||
. $PSScriptRoot\vban.ps1
|
|
||||||
. $PSScriptRoot\command.ps1
|
|
||||||
. $PSScriptRoot\recorder.ps1
|
|
||||||
|
|
||||||
function Login {
|
function Login {
|
||||||
param(
|
param(
|
||||||
@ -15,46 +7,46 @@ function Login {
|
|||||||
)
|
)
|
||||||
try {
|
try {
|
||||||
$retval = [int][Voicemeeter.Remote]::VBVMR_Login()
|
$retval = [int][Voicemeeter.Remote]::VBVMR_Login()
|
||||||
if (-not $retval) {
|
if ($retval -ne 0) {
|
||||||
"LOGGED IN" | Write-Verbose
|
switch ($retval) {
|
||||||
}
|
1 {
|
||||||
elseif ($retval -eq 1) {
|
New-Variable -Name vmExe -Value 0
|
||||||
"VM NOT RUNNING" | Write-Verbose
|
|
||||||
New-Variable -Name vmExe -Value 0
|
|
||||||
|
|
||||||
if ( $kindId -eq "basic" ) { $vmExe = 1 }
|
if ( $kindId -eq "basic" ) { $vmExe = 1 }
|
||||||
elseif ( $kindId -eq "banana" ) { $vmExe = 2 }
|
elseif ( $kindId -eq "banana" ) { $vmExe = 2 }
|
||||||
elseif ( $kindId -eq "potato" ) {
|
elseif ( $kindId -eq "potato" ) {
|
||||||
$vmExe = $(if ([Environment]::Is64BitOperatingSystem) { 6 } else { 3 })
|
$vmExe = $(if ([Environment]::Is64BitOperatingSystem) { 6 } else { 3 })
|
||||||
}
|
}
|
||||||
|
|
||||||
$retval = [int][Voicemeeter.Remote]::VBVMR_RunVoicemeeter([int64]$vmExe)
|
$retval = [int][Voicemeeter.Remote]::VBVMR_RunVoicemeeter([int64]$vmExe)
|
||||||
if (-not $retval) {
|
if (-not $retval) {
|
||||||
"STARTING VOICEMEETER" | Write-Verbose
|
"Voicemeeter Engine running but GUI not launched. Launching GUI now." | Write-Verbose
|
||||||
Start-Sleep -s 1
|
Start-Sleep -s 1
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
throw [CAPIError]::new($retval, $MyInvocation.MyCommand)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
-2 {
|
||||||
|
throw [LoginError]::new('Login may only be called once per session')
|
||||||
|
}
|
||||||
|
default { throw [CAPIError]::new($retval, $MyInvocation.MyCommand) }
|
||||||
}
|
}
|
||||||
else {
|
}
|
||||||
throw [CAPIError]::new($retval, $MyInvocation.MyCommand)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
elseif ($retval -eq -2) {
|
|
||||||
throw [LoginError]::new('login may only be called once per session')
|
|
||||||
}
|
|
||||||
else { throw [CAPIError]::new($retval, $MyInvocation.MyCommand) }
|
|
||||||
}
|
}
|
||||||
catch [LoginError] {
|
catch [LoginError] {
|
||||||
Write-Warning "$($_.Exception.ErrorMessage()). Fatal error, exiting..."
|
"$($_.Exception.ErrorMessage()). Fatal error, exiting..." | Write-Warning
|
||||||
exit -2
|
exit -2
|
||||||
}
|
}
|
||||||
|
|
||||||
while (P_Dirty -or M_Dirty) { Start-Sleep -m 1 }
|
while (P_Dirty -or M_Dirty) { Start-Sleep -m 1 }
|
||||||
"VERSION:[" + $(VmType).ToUpper() + "]" | Write-Verbose
|
"Successfully logged into Voicemeeter [" + $(VmType).ToUpper() + "] Version " + $(VmVersion) | Write-Verbose
|
||||||
}
|
}
|
||||||
|
|
||||||
function Logout {
|
function Logout {
|
||||||
Start-Sleep -m 20
|
Start-Sleep -m 20
|
||||||
$retval = [int][Voicemeeter.Remote]::VBVMR_Logout()
|
$retval = [int][Voicemeeter.Remote]::VBVMR_Logout()
|
||||||
if (-not $retval) { "LOGGED OUT" | Write-Verbose }
|
if ($retval -eq 0) { "Sucessfully logged out" | Write-Verbose }
|
||||||
}
|
}
|
||||||
|
|
||||||
function P_Dirty {
|
function P_Dirty {
|
||||||
@ -76,7 +68,7 @@ function VmType {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function Version {
|
function VmVersion {
|
||||||
New-Variable -Name ptr -Value 0
|
New-Variable -Name ptr -Value 0
|
||||||
$retval = [int][Voicemeeter.Remote]::VBVMR_GetVoicemeeterVersion([ref]$ptr)
|
$retval = [int][Voicemeeter.Remote]::VBVMR_GetVoicemeeterVersion([ref]$ptr)
|
||||||
if ($retval) { throw [CAPIError]::new($retval, $MyInvocation.MyCommand) }
|
if ($retval) { throw [CAPIError]::new($retval, $MyInvocation.MyCommand) }
|
||||||
|
@ -1,18 +1,11 @@
|
|||||||
function Setup_DLL {
|
. $PSScriptRoot\inst.ps1
|
||||||
try {
|
|
||||||
$vb_path = Get_VMPath
|
|
||||||
|
|
||||||
if ([string]::IsNullOrWhiteSpace($vb_path)) {
|
function Setup_DLL {
|
||||||
throw [VMRemoteError]::new("couldn't get Voicemeeter path")
|
$VMPATH = Get_VMPath
|
||||||
}
|
|
||||||
$dll = Join-Path -Path $vb_path -ChildPath ("VoicemeeterRemote" + `
|
$dll = Join-Path -Path $VMPATH -ChildPath ("VoicemeeterRemote" + `
|
||||||
(& { if ([Environment]::Is64BitOperatingSystem) { "64" } else { "" } }) + `
|
(& { if ([Environment]::Is64BitOperatingSystem) { "64" } else { "" } }) + `
|
||||||
".dll")
|
".dll")
|
||||||
}
|
|
||||||
catch [VMRemoteError] {
|
|
||||||
Write-Warning $_.Exception.ErrorMessage()
|
|
||||||
return $false
|
|
||||||
}
|
|
||||||
|
|
||||||
$Signature = @"
|
$Signature = @"
|
||||||
[DllImport(@"$dll")]
|
[DllImport(@"$dll")]
|
||||||
@ -53,5 +46,5 @@ function Setup_DLL {
|
|||||||
"@
|
"@
|
||||||
|
|
||||||
Add-Type -MemberDefinition $Signature -Name Remote -Namespace Voicemeeter -PassThru | Out-Null
|
Add-Type -MemberDefinition $Signature -Name Remote -Namespace Voicemeeter -PassThru | Out-Null
|
||||||
return $true
|
return $VMPATH
|
||||||
}
|
}
|
||||||
|
26
lib/bus.ps1
26
lib/bus.ps1
@ -1,5 +1,3 @@
|
|||||||
. $PSScriptRoot\meta.ps1
|
|
||||||
|
|
||||||
class IBus {
|
class IBus {
|
||||||
[int]$index
|
[int]$index
|
||||||
[Object]$remote
|
[Object]$remote
|
||||||
@ -13,20 +11,26 @@ class IBus {
|
|||||||
return "Bus[" + $this.index + "]"
|
return "Bus[" + $this.index + "]"
|
||||||
}
|
}
|
||||||
|
|
||||||
[string] ToString() {
|
|
||||||
return $this.GetType().Name + $this.index
|
|
||||||
}
|
|
||||||
|
|
||||||
[single] Getter ($param) {
|
[single] Getter ($param) {
|
||||||
return $this.remote.Getter("$($this.identifier()).$param")
|
$this.ToString() + " Getter: $($this.Cmd($param))" | Write-Debug
|
||||||
|
return $this.remote.Getter($this.Cmd($param))
|
||||||
}
|
}
|
||||||
|
|
||||||
[string] Getter_String ($param) {
|
[string] Getter_String ($param) {
|
||||||
return $this.remote.Getter_String("$($this.identifier()).$param")
|
$this.ToString() + " Getter_String: $($this.Cmd($param))" | Write-Debug
|
||||||
|
return $this.remote.Getter_String($this.Cmd($param))
|
||||||
}
|
}
|
||||||
|
|
||||||
[void] Setter ($param, $val) {
|
[void] Setter ($param, $val) {
|
||||||
$this.remote.Setter("$($this.identifier()).$param", $val)
|
$this.ToString() + " Setter: $($this.Cmd($param))=$val" | Write-Debug
|
||||||
|
$this.remote.Setter($this.Cmd($param), $val)
|
||||||
|
}
|
||||||
|
|
||||||
|
[string] Cmd ($param) {
|
||||||
|
if ([string]::IsNullOrEmpty($param)) {
|
||||||
|
return $this.identifier()
|
||||||
|
}
|
||||||
|
return "$($this.identifier()).$param"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -45,6 +49,10 @@ class Bus : IBus {
|
|||||||
$this.levels = [BusLevels]::new($index, $remote)
|
$this.levels = [BusLevels]::new($index, $remote)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[string] ToString() {
|
||||||
|
return $this.GetType().Name + $this.index
|
||||||
|
}
|
||||||
|
|
||||||
[void] FadeTo ([single]$target, [int]$time) {
|
[void] FadeTo ([single]$target, [int]$time) {
|
||||||
$this.Setter('FadeTo', "($target, $time)")
|
$this.Setter('FadeTo', "($target, $time)")
|
||||||
}
|
}
|
||||||
|
@ -1,6 +1,3 @@
|
|||||||
. $PSScriptRoot\meta.ps1
|
|
||||||
. $PSScriptRoot\inst.ps1
|
|
||||||
|
|
||||||
class Special {
|
class Special {
|
||||||
[Object]$remote
|
[Object]$remote
|
||||||
|
|
||||||
@ -32,10 +29,12 @@ class Special {
|
|||||||
}
|
}
|
||||||
|
|
||||||
[void] RunMacrobuttons() {
|
[void] RunMacrobuttons() {
|
||||||
Start-Process -FilePath $(Join-Path -Path $(Get_VMPath) -ChildPath "VoicemeeterMacroButtons.exe")
|
"Launching the MacroButtons app" | Write-Verbose
|
||||||
|
Start-Process -FilePath $(Join-Path -Path $this.remote.vmpath -ChildPath "VoicemeeterMacroButtons.exe")
|
||||||
}
|
}
|
||||||
|
|
||||||
[void] CloseMacrobuttons() {
|
[void] CloseMacrobuttons() {
|
||||||
|
"Closing the MacroButtons app" | Write-Verbose
|
||||||
Stop-Process -Name "VoicemeeterMacroButtons"
|
Stop-Process -Name "VoicemeeterMacroButtons"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
11
lib/inst.ps1
11
lib/inst.ps1
@ -1,8 +1,13 @@
|
|||||||
function Get_VMPath {
|
function Get_VMPath {
|
||||||
$reg_path = "Registry::HKEY_LOCAL_MACHINE\Software" + `
|
$REG_KEY = "Registry::HKEY_LOCAL_MACHINE\Software" + `
|
||||||
(& { if ([Environment]::Is64BitOperatingSystem) { "\WOW6432Node" } else { "" } }) + `
|
(& { if ([Environment]::Is64BitOperatingSystem) { "\WOW6432Node" } else { "" } }) + `
|
||||||
"\Microsoft\Windows\CurrentVersion\Uninstall"
|
"\Microsoft\Windows\CurrentVersion\Uninstall"
|
||||||
$vm_key = "\VB:Voicemeeter {17359A74-1236-5467}\"
|
$VM_KEY = "\VB:Voicemeeter {17359A74-1236-5467}\"
|
||||||
|
|
||||||
return $(Get-ItemPropertyValue -Path ($reg_path + $vm_key) -Name UninstallString | Split-Path -Parent)
|
try {
|
||||||
|
return $(Get-ItemPropertyValue -Path ($REG_KEY + $VM_KEY) -Name UninstallString | Split-Path -Parent)
|
||||||
|
}
|
||||||
|
catch {
|
||||||
|
throw [VMRemoteError]::new("Couldn't get Voicemeeter path")
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,3 +1,9 @@
|
|||||||
|
enum ButtonTypes {
|
||||||
|
State = 1
|
||||||
|
StateOnly = 2
|
||||||
|
Trigger = 3
|
||||||
|
}
|
||||||
|
|
||||||
class MacroButton {
|
class MacroButton {
|
||||||
[int32]$index
|
[int32]$index
|
||||||
|
|
||||||
@ -10,40 +16,42 @@ class MacroButton {
|
|||||||
}
|
}
|
||||||
|
|
||||||
[int] Getter ($mode) {
|
[int] Getter ($mode) {
|
||||||
|
"Button[$($this.index)].$([ButtonTypes].GetEnumName($mode))" | Write-Debug
|
||||||
return MB_Get -Id $this.index -Mode $mode
|
return MB_Get -Id $this.index -Mode $mode
|
||||||
}
|
}
|
||||||
|
|
||||||
[void] Setter ($set, $mode) {
|
[void] Setter ($val, $mode) {
|
||||||
MB_Set -Id $this.index -SET $set -Mode $mode
|
"Button[$($this.index)].$([ButtonTypes].GetEnumName($mode))=$val" | Write-Debug
|
||||||
|
MB_Set -Id $this.index -SET $val -Mode $mode
|
||||||
}
|
}
|
||||||
|
|
||||||
hidden $_state = $($this | Add-Member ScriptProperty 'state' `
|
hidden $_state = $($this | Add-Member ScriptProperty 'state' `
|
||||||
{
|
{
|
||||||
[bool]$this.Getter(1)
|
[bool]$this.Getter([ButtonTypes]::State)
|
||||||
} `
|
} `
|
||||||
{
|
{
|
||||||
param($arg)
|
param($arg)
|
||||||
$this._state = $this.Setter($arg, 1)
|
$this._state = $this.Setter($arg, [ButtonTypes]::State)
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
|
||||||
hidden $_stateonly = $($this | Add-Member ScriptProperty 'stateonly' `
|
hidden $_stateonly = $($this | Add-Member ScriptProperty 'stateonly' `
|
||||||
{
|
{
|
||||||
[bool]$this.Getter(2)
|
[bool]$this.Getter([ButtonTypes]::StateOnly)
|
||||||
} `
|
} `
|
||||||
{
|
{
|
||||||
param($arg)
|
param($arg)
|
||||||
$this._stateonly = $this.Setter($arg, 2)
|
$this._stateonly = $this.Setter($arg, [ButtonTypes]::StateOnly)
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
|
||||||
hidden $_trigger = $($this | Add-Member ScriptProperty 'trigger' `
|
hidden $_trigger = $($this | Add-Member ScriptProperty 'trigger' `
|
||||||
{
|
{
|
||||||
[bool]$this.Getter(3)
|
[bool]$this.Getter([ButtonTypes]::Trigger)
|
||||||
} `
|
} `
|
||||||
{
|
{
|
||||||
param($arg)
|
param($arg)
|
||||||
$this._trigger = $this.Setter($arg, 3)
|
$this._trigger = $this.Setter($arg, [ButtonTypes]::Trigger)
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
@ -1,5 +1,3 @@
|
|||||||
. $PSScriptRoot\meta.ps1
|
|
||||||
|
|
||||||
class IRecorder {
|
class IRecorder {
|
||||||
[Object]$remote
|
[Object]$remote
|
||||||
|
|
||||||
|
@ -1,5 +1,3 @@
|
|||||||
. $PSScriptRoot\meta.ps1
|
|
||||||
|
|
||||||
class IStrip {
|
class IStrip {
|
||||||
[int]$index
|
[int]$index
|
||||||
[Object]$remote
|
[Object]$remote
|
||||||
@ -14,15 +12,25 @@ class IStrip {
|
|||||||
}
|
}
|
||||||
|
|
||||||
[single] Getter ($param) {
|
[single] Getter ($param) {
|
||||||
return $this.remote.Getter("$($this.identifier()).$param")
|
$this.Cmd($param) | Write-Debug
|
||||||
|
return $this.remote.Getter($this.Cmd($param))
|
||||||
}
|
}
|
||||||
|
|
||||||
[string] Getter_String ($param) {
|
[string] Getter_String ($param) {
|
||||||
return $this.remote.Getter_String("$($this.identifier()).$param")
|
$this.Cmd($param) | Write-Debug
|
||||||
|
return $this.remote.Getter_String($this.Cmd($param))
|
||||||
}
|
}
|
||||||
|
|
||||||
[void] Setter ($param, $val) {
|
[void] Setter ($param, $val) {
|
||||||
$this.remote.Setter("$($this.identifier()).$param", $val)
|
"$($this.Cmd($param))=$val" | Write-Debug
|
||||||
|
$this.remote.Setter($this.Cmd($param), $val)
|
||||||
|
}
|
||||||
|
|
||||||
|
[string] Cmd ($param) {
|
||||||
|
if ([string]::IsNullOrEmpty($param)) {
|
||||||
|
return $this.identifier()
|
||||||
|
}
|
||||||
|
return "$($this.identifier()).$param"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
23
lib/vban.ps1
23
lib/vban.ps1
@ -13,20 +13,25 @@ class IVban {
|
|||||||
return "vban." + $this.direction + "stream[" + $this.index + "]"
|
return "vban." + $this.direction + "stream[" + $this.index + "]"
|
||||||
}
|
}
|
||||||
|
|
||||||
[string] ToString() {
|
|
||||||
return $this.GetType().Name + $this.index
|
|
||||||
}
|
|
||||||
|
|
||||||
[single] Getter ($param) {
|
[single] Getter ($param) {
|
||||||
return $this.remote.Getter("$($this.identifier()).$param")
|
return $this.remote.Getter($this.Cmd($param))
|
||||||
}
|
}
|
||||||
|
|
||||||
[string] Getter_String ($param) {
|
[string] Getter_String ($param) {
|
||||||
return $this.remote.Getter_String("$($this.identifier()).$param")
|
$this.Cmd($param) | Write-Debug
|
||||||
|
return $this.remote.Getter_String($this.Cmd($param))
|
||||||
}
|
}
|
||||||
|
|
||||||
[void] Setter ($param, $val) {
|
[void] Setter ($param, $val) {
|
||||||
$this.remote.Setter("$($this.identifier()).$param", $val)
|
"$($this.Cmd($param))=$val" | Write-Debug
|
||||||
|
$this.remote.Setter($this.Cmd($param), $val)
|
||||||
|
}
|
||||||
|
|
||||||
|
[string] Cmd ($param) {
|
||||||
|
if ([string]::IsNullOrEmpty($param)) {
|
||||||
|
return $this.identifier()
|
||||||
|
}
|
||||||
|
return "$($this.identifier()).$param"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -34,6 +39,10 @@ class Vban : IVban {
|
|||||||
Vban ([int]$index, [Object]$remote, [string]$direction) : base ($index, $remote, $direction) {
|
Vban ([int]$index, [Object]$remote, [string]$direction) : base ($index, $remote, $direction) {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[string] ToString() {
|
||||||
|
return $this.GetType().Name + $this.index
|
||||||
|
}
|
||||||
|
|
||||||
hidden $_on = $($this | Add-Member ScriptProperty 'on' `
|
hidden $_on = $($this | Add-Member ScriptProperty 'on' `
|
||||||
{
|
{
|
||||||
$this.Getter('on')
|
$this.Getter('on')
|
||||||
|
Loading…
Reference in New Issue
Block a user