mirror of
https://github.com/onyx-and-iris/voicemeeter-api-powershell.git
synced 2026-09-09 12:28:56 +00:00
Compare commits
10 Commits
dev
...
runvoiceme
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
90c09092b6 | ||
|
|
0fb26b9e72 | ||
|
|
c3aa47e7d0 | ||
|
|
21fce98eef | ||
|
|
36e4e16843 | ||
|
|
7a6150bf6e | ||
|
|
d05b46b899 | ||
|
|
b978f5aa3f | ||
|
|
5c5932e7d3 | ||
|
|
3e5a61eff3 |
@@ -9,6 +9,15 @@ Before any major/minor/patch is released all unit tests will be run to verify th
|
||||
|
||||
## [Unreleased] These changes have not been added to PSGallery yet
|
||||
|
||||
### Added
|
||||
|
||||
- Get-Remote factory function to log in and return a base Remote instance without launching Voicemeeter
|
||||
- Command.Launch() method to launch Voicemeeter based on `$this.kind.name`, useful for re-launch after Command.Shutdown()
|
||||
- Remote.GetVoicemeeter($kindId) to confirm a connection to Voicemeeter and return the requested Remote instance
|
||||
- Remote.RunVoicemeeter($kindId) to launch Voicemeeter and return an appropriate Remote instance
|
||||
- Remote.RunApplication($appId) to launch VB-Audio applications
|
||||
- Remote.GetType(), Remote.GetVersion() to README
|
||||
|
||||
## [4.2.0] - 2026-03-15
|
||||
|
||||
### Added
|
||||
|
||||
74
README.md
74
README.md
@@ -78,6 +78,7 @@ Voicemeeter factory function can be:
|
||||
- Get-RemoteBasic
|
||||
- Get-RemoteBanana
|
||||
- Get-RemotePotato
|
||||
- Get-Remote : if only lower-level Remote methods are needed
|
||||
|
||||
Added in `v3` you may also use the following entry/exit points:
|
||||
|
||||
@@ -551,6 +552,7 @@ The following Command methods are available:
|
||||
- HideVBANChat()
|
||||
- Restart()
|
||||
- Shutdown()
|
||||
- Launch() : launches the current Voicemeeter kind
|
||||
- Reset() : Reset all config
|
||||
- Save($filepath) : string
|
||||
- Load($filepath) : string
|
||||
@@ -575,6 +577,21 @@ $vmr.command.StorePreset() # same as StorePreset(''), overwrite
|
||||
$vmr.command.RecallPreset('example')
|
||||
$vmr.command.RecallPreset(63)
|
||||
$vmr.command.RecallPreset() # same as RecallPreset(''), recalls last recalled
|
||||
|
||||
try {
|
||||
$vmr = Connect-Voicemeeter -Kind 'potato'
|
||||
|
||||
if ($vmr.GetType() -ne 'potato') {
|
||||
$vmr.command.Shutdown() # shuts down whatever was running
|
||||
Start-Sleep -Seconds 3
|
||||
$vmr.command.Launch() # launches Voicemeeter Potato
|
||||
}
|
||||
|
||||
# perform operations with Voicemeeter Potato
|
||||
}
|
||||
finally {
|
||||
Disconnect-Voicemeeter
|
||||
}
|
||||
```
|
||||
|
||||
StorePreset('') and RecallPreset('') interact with the 'selected' preset. This is highlighted green in the GUI. Recalling a preset selects it. Storing a preset via GUI also selects it. Storing a preset with StorePreset does not select it.
|
||||
@@ -781,6 +798,63 @@ will load a config file at profiles/banana/config.psd1 for Voicemeeter Banana.
|
||||
|
||||
### Remote class
|
||||
|
||||
`$vmr.GetType()` : returns current Voicemeeter kind ('basic', 'banana', 'potato')
|
||||
`$vmr.GetVersion()` : returns current Voicemeeter version string (e.g. '2.1.2.2')
|
||||
`$vmr.GetVoicemeeter($kindId)` : string, ('basic', 'banana', 'potato'), confirms connection and returns requested Remote instance
|
||||
`$vmr.RunVoicemeeter($kindId)` : string, ('basic', 'banana', 'potato'), launches Voicemeeter and returns appropriate Remote instance
|
||||
|
||||
example:
|
||||
|
||||
```powershell
|
||||
try {
|
||||
$vmr = Get-Remote
|
||||
|
||||
$kind = 'none'
|
||||
try {
|
||||
$kind = $vmr.GetType()
|
||||
$vmr = $vmr.GetVoicemeeter($kind)
|
||||
}
|
||||
catch { }
|
||||
|
||||
switch ($kind) {
|
||||
'potato' {
|
||||
break
|
||||
}
|
||||
'basic' {
|
||||
# perform final operations with Voicemeeter Basic
|
||||
}
|
||||
'banana' {
|
||||
# perform final operations with Voicemeeter Banana
|
||||
}
|
||||
{ $_ -in 'basic', 'banana'} {
|
||||
$vmr.Command.Shutdown()
|
||||
Start-Sleep -Seconds 3
|
||||
}
|
||||
{ $_ -ne 'potato' } {
|
||||
$vmr = $vmr.RunVoicemeeter('potato')
|
||||
}
|
||||
}
|
||||
|
||||
# perform operations with Voicemeeter Potato
|
||||
}
|
||||
finally {
|
||||
Disconnect-Voicemeeter
|
||||
}
|
||||
```
|
||||
|
||||
`$vmr.RunApplication($appId)` : string, launches VB-Audio applications
|
||||
|
||||
- 'devicecheck'
|
||||
- 'macrobuttons'
|
||||
- 'streamerview'
|
||||
- 'busmatrix8'
|
||||
- 'busgeq15'
|
||||
- 'vban2midi'
|
||||
- 'cablecontrolpanel'
|
||||
- 'auxcontrolpanel'
|
||||
- 'vaio3controlpanel'
|
||||
- 'vaiocontrolpanel'
|
||||
|
||||
Access to lower level Getters and Setters are provided with these functions:
|
||||
|
||||
- `$vmr.Getter(param)`: For getting the value of a parameter expected to return a value other than string.
|
||||
|
||||
@@ -40,6 +40,20 @@ class Remote {
|
||||
Logout
|
||||
}
|
||||
|
||||
[Remote] GetVoicemeeter([String]$kindId) {
|
||||
WaitForConnection
|
||||
return Make_Remote -kindId $kindId
|
||||
}
|
||||
|
||||
[Remote] RunVoicemeeter([String]$kindId) {
|
||||
RunVm -kindId $kindId
|
||||
return Make_Remote -kindId $kindId
|
||||
}
|
||||
|
||||
[void] RunApplication([String]$appId) {
|
||||
RunApp -appId $appId
|
||||
}
|
||||
|
||||
[string] GetType() {
|
||||
return VmType
|
||||
}
|
||||
@@ -159,6 +173,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 {
|
||||
[RemoteBasic]::new().Login()
|
||||
}
|
||||
@@ -193,4 +231,4 @@ Function Disconnect-Voicemeeter {
|
||||
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
|
||||
|
||||
52
lib/base.ps1
52
lib/base.ps1
@@ -11,22 +11,32 @@ function Login {
|
||||
}
|
||||
|
||||
switch ($retval) {
|
||||
0 {
|
||||
WaitForConnection
|
||||
}
|
||||
1 {
|
||||
'Voicemeeter Engine running but GUI not launched. Launching GUI now.' | Write-Verbose
|
||||
RunVoicemeeter -kindId $kindId
|
||||
if ($kindId -eq 'none') {
|
||||
'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 {
|
||||
throw [LoginError]::new('Login may only be called once per session.')
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function WaitForConnection {
|
||||
$timeout = New-TimeSpan -Seconds 2
|
||||
$sw = [diagnostics.stopwatch]::StartNew()
|
||||
$exception = $null
|
||||
do {
|
||||
Start-Sleep -m 100
|
||||
try {
|
||||
'Successfully logged into Voicemeeter [' + $(VmType).ToUpper() + '] Version ' + $(VmVersion) | Write-Verbose
|
||||
'Successfully connected to Voicemeeter [' + $(VmType).ToUpper() + '] Version ' + $(VmVersion) | Write-Verbose
|
||||
$exception = $null
|
||||
break
|
||||
}
|
||||
@@ -37,7 +47,7 @@ function Login {
|
||||
} while ($sw.elapsed -lt $timeout)
|
||||
|
||||
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 }
|
||||
@@ -52,7 +62,17 @@ function Logout {
|
||||
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(
|
||||
[string]$kindId
|
||||
)
|
||||
@@ -61,11 +81,27 @@ function RunVoicemeeter {
|
||||
'banana' = $(if ([Environment]::Is64BitOperatingSystem) { 5 } else { 2 })
|
||||
'potato' = $(if ([Environment]::Is64BitOperatingSystem) { 6 } else { 3 })
|
||||
}
|
||||
Run -id $kinds[$kindId]
|
||||
WaitForConnection
|
||||
}
|
||||
|
||||
$retval = [int][Voicemeeter.Remote]::VBVMR_RunVoicemeeter([int64]$kinds[$kindId])
|
||||
if ($retval -notin @(0)) {
|
||||
throw [CAPIError]::new($retval, 'VBVMR_RunVoicemeeter')
|
||||
function RunApp {
|
||||
param(
|
||||
[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 {
|
||||
|
||||
@@ -7,6 +7,11 @@ class Special : IRemote {
|
||||
return 'Command'
|
||||
}
|
||||
|
||||
[void] Launch() {
|
||||
'Launching Voicemeeter audio engine and GUI' | Write-Verbose
|
||||
RunVm -kindId $this.remote.kind.name
|
||||
}
|
||||
|
||||
[void] RunMacrobuttons() {
|
||||
'Launching the MacroButtons app' | Write-Verbose
|
||||
Start-Process -FilePath $(Join-Path -Path $this.remote.vmpath -ChildPath 'VoicemeeterMacroButtons.exe')
|
||||
|
||||
@@ -1,4 +1,7 @@
|
||||
$KindMap = @{
|
||||
'none' = @{
|
||||
'name' = 'none'
|
||||
}
|
||||
'basic' = @{
|
||||
'name' = 'basic'
|
||||
'p_in' = 2
|
||||
|
||||
Reference in New Issue
Block a user