mirror of
https://github.com/onyx-and-iris/voicemeeter-api-powershell.git
synced 2026-09-14 06:32:26 +00:00
Compare commits
5
Commits
dev
...
7a6150bf6e
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
7a6150bf6e | ||
|
|
d05b46b899 | ||
|
|
b978f5aa3f | ||
|
|
5c5932e7d3 | ||
|
|
3e5a61eff3 |
+34
-1
@@ -40,6 +40,15 @@ class Remote {
|
|||||||
Logout
|
Logout
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[Remote] RunVoicemeeter([String]$kindId) {
|
||||||
|
RunVm -kindId $kindId
|
||||||
|
return Make_Remote -kindId $kindId
|
||||||
|
}
|
||||||
|
|
||||||
|
[void] RunApplication([String]$appId) {
|
||||||
|
RunApp -appId $appId
|
||||||
|
}
|
||||||
|
|
||||||
[string] GetType() {
|
[string] GetType() {
|
||||||
return VmType
|
return VmType
|
||||||
}
|
}
|
||||||
@@ -159,6 +168,30 @@ class RemotePotato : Remote {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function Make_Remote {
|
||||||
|
param(
|
||||||
|
[String]$kindId
|
||||||
|
)
|
||||||
|
switch ($kindId) {
|
||||||
|
'basic' {
|
||||||
|
[RemoteBasic]::new()
|
||||||
|
}
|
||||||
|
'banana' {
|
||||||
|
[RemoteBanana]::new()
|
||||||
|
}
|
||||||
|
'potato' {
|
||||||
|
[RemotePotato]::new()
|
||||||
|
}
|
||||||
|
default {
|
||||||
|
throw [VMRemoteError]::new("Unknown Voicemeeter kind `"$kindId`"")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Function Get-Remote {
|
||||||
|
[Remote]::new('none').Login()
|
||||||
|
}
|
||||||
|
|
||||||
Function Get-RemoteBasic {
|
Function Get-RemoteBasic {
|
||||||
[RemoteBasic]::new().Login()
|
[RemoteBasic]::new().Login()
|
||||||
}
|
}
|
||||||
@@ -193,4 +226,4 @@ Function Disconnect-Voicemeeter {
|
|||||||
Logout
|
Logout
|
||||||
}
|
}
|
||||||
|
|
||||||
Export-ModuleMember -Function Get-RemoteBasic, Get-RemoteBanana, Get-RemotePotato, Connect-Voicemeeter, Disconnect-Voicemeeter
|
Export-ModuleMember -Function Get-Remote, Get-RemoteBasic, Get-RemoteBanana, Get-RemotePotato, Connect-Voicemeeter, Disconnect-Voicemeeter
|
||||||
|
|||||||
+44
-8
@@ -11,22 +11,32 @@ function Login {
|
|||||||
}
|
}
|
||||||
|
|
||||||
switch ($retval) {
|
switch ($retval) {
|
||||||
|
0 {
|
||||||
|
WaitForConnection
|
||||||
|
}
|
||||||
1 {
|
1 {
|
||||||
'Voicemeeter Engine running but GUI not launched. Launching GUI now.' | Write-Verbose
|
if ($kindId -eq 'none') {
|
||||||
RunVoicemeeter -kindId $kindId
|
'Logged in to Voicemeeter Remote.' | Write-Verbose
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
'Logged in to Voicemeeter Remote but audio engine and GUI not launched. Launching engine now.' | Write-Verbose
|
||||||
|
RunVm -kindId $kindId
|
||||||
|
}
|
||||||
}
|
}
|
||||||
-2 {
|
-2 {
|
||||||
throw [LoginError]::new('Login may only be called once per session.')
|
throw [LoginError]::new('Login may only be called once per session.')
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function WaitForConnection {
|
||||||
$timeout = New-TimeSpan -Seconds 2
|
$timeout = New-TimeSpan -Seconds 2
|
||||||
$sw = [diagnostics.stopwatch]::StartNew()
|
$sw = [diagnostics.stopwatch]::StartNew()
|
||||||
$exception = $null
|
$exception = $null
|
||||||
do {
|
do {
|
||||||
Start-Sleep -m 100
|
Start-Sleep -m 100
|
||||||
try {
|
try {
|
||||||
'Successfully logged into Voicemeeter [' + $(VmType).ToUpper() + '] Version ' + $(VmVersion) | Write-Verbose
|
'Successfully connected to Voicemeeter [' + $(VmType).ToUpper() + '] Version ' + $(VmVersion) | Write-Verbose
|
||||||
$exception = $null
|
$exception = $null
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
@@ -37,7 +47,7 @@ function Login {
|
|||||||
} while ($sw.elapsed -lt $timeout)
|
} while ($sw.elapsed -lt $timeout)
|
||||||
|
|
||||||
if ($null -ne $exception) {
|
if ($null -ne $exception) {
|
||||||
throw [VMRemoteError]::new('Timeout logging into the API.')
|
throw [VMRemoteError]::new('Timeout waiting to connect to Voicemeeter.')
|
||||||
}
|
}
|
||||||
|
|
||||||
while (P_Dirty -or M_Dirty) { Start-Sleep -m 1 }
|
while (P_Dirty -or M_Dirty) { Start-Sleep -m 1 }
|
||||||
@@ -52,7 +62,17 @@ function Logout {
|
|||||||
if ($retval -eq 0) { 'Sucessfully logged out' | Write-Verbose }
|
if ($retval -eq 0) { 'Sucessfully logged out' | Write-Verbose }
|
||||||
}
|
}
|
||||||
|
|
||||||
function RunVoicemeeter {
|
function Run {
|
||||||
|
param(
|
||||||
|
[int]$id
|
||||||
|
)
|
||||||
|
$retval = [int][Voicemeeter.Remote]::VBVMR_RunVoicemeeter([Int64]$id)
|
||||||
|
if ($retval -notin @(0)) {
|
||||||
|
throw [CAPIError]::new($retval, 'VBVMR_RunVoicemeeter')
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function RunVm {
|
||||||
param(
|
param(
|
||||||
[string]$kindId
|
[string]$kindId
|
||||||
)
|
)
|
||||||
@@ -61,11 +81,27 @@ function RunVoicemeeter {
|
|||||||
'banana' = $(if ([Environment]::Is64BitOperatingSystem) { 5 } else { 2 })
|
'banana' = $(if ([Environment]::Is64BitOperatingSystem) { 5 } else { 2 })
|
||||||
'potato' = $(if ([Environment]::Is64BitOperatingSystem) { 6 } else { 3 })
|
'potato' = $(if ([Environment]::Is64BitOperatingSystem) { 6 } else { 3 })
|
||||||
}
|
}
|
||||||
|
Run -id $kinds[$kindId]
|
||||||
|
WaitForConnection
|
||||||
|
}
|
||||||
|
|
||||||
$retval = [int][Voicemeeter.Remote]::VBVMR_RunVoicemeeter([int64]$kinds[$kindId])
|
function RunApp {
|
||||||
if ($retval -notin @(0)) {
|
param(
|
||||||
throw [CAPIError]::new($retval, 'VBVMR_RunVoicemeeter')
|
[string]$appId
|
||||||
|
)
|
||||||
|
$apps = @{
|
||||||
|
'devicecheck' = 10
|
||||||
|
'macrobuttons' = 11
|
||||||
|
'streamerview' = 12
|
||||||
|
'busmatrix8' = 13
|
||||||
|
'busgeq15' = 14
|
||||||
|
'vban2midi' = 15
|
||||||
|
'cablecontrolpanel' = 20
|
||||||
|
'auxcontrolpanel' = 21
|
||||||
|
'vaio3controlpanel' = 22
|
||||||
|
'vaiocontrolpanel' = 23
|
||||||
}
|
}
|
||||||
|
Run -id $apps[$appId]
|
||||||
}
|
}
|
||||||
|
|
||||||
function P_Dirty {
|
function P_Dirty {
|
||||||
|
|||||||
@@ -7,6 +7,11 @@ class Special : IRemote {
|
|||||||
return 'Command'
|
return 'Command'
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[void] Launch() {
|
||||||
|
'Launching Voicemeeter audio engine and GUI' | Write-Verbose
|
||||||
|
RunVm -kindId $this.kind.name
|
||||||
|
}
|
||||||
|
|
||||||
[void] RunMacrobuttons() {
|
[void] RunMacrobuttons() {
|
||||||
'Launching the MacroButtons app' | Write-Verbose
|
'Launching the MacroButtons app' | Write-Verbose
|
||||||
Start-Process -FilePath $(Join-Path -Path $this.remote.vmpath -ChildPath 'VoicemeeterMacroButtons.exe')
|
Start-Process -FilePath $(Join-Path -Path $this.remote.vmpath -ChildPath 'VoicemeeterMacroButtons.exe')
|
||||||
|
|||||||
@@ -1,4 +1,7 @@
|
|||||||
$KindMap = @{
|
$KindMap = @{
|
||||||
|
'none' = @{
|
||||||
|
'name' = 'none'
|
||||||
|
}
|
||||||
'basic' = @{
|
'basic' = @{
|
||||||
'name' = 'basic'
|
'name' = 'basic'
|
||||||
'p_in' = 2
|
'p_in' = 2
|
||||||
|
|||||||
Reference in New Issue
Block a user