mirror of
https://github.com/onyx-and-iris/voicemeeter-api-powershell.git
synced 2025-01-18 05:10:48 +00:00
add load profiles, examples, update readme
add Get_Profiles and Set_Profile functions. Now possible to load many parameters from a psd1 config file. example config added add Config Files section to readme
This commit is contained in:
parent
ff1839313f
commit
5b3a4e2b4f
2
.gitignore
vendored
2
.gitignore
vendored
@ -1,2 +1,2 @@
|
|||||||
**/*.psd1
|
lib/*.psd1
|
||||||
**/*.log
|
**/*.log
|
||||||
|
14
README.md
14
README.md
@ -190,6 +190,20 @@ $vmr.Setter('Strip[4].Label', 'stripname')
|
|||||||
$vmr.Setter('Strip[0].Gain', -3.6)
|
$vmr.Setter('Strip[0].Gain', -3.6)
|
||||||
```
|
```
|
||||||
|
|
||||||
|
### Config Files
|
||||||
|
`$vmr.Set_Profile('config')`
|
||||||
|
|
||||||
|
You may load config files in psd1 format. An example profile has been included with the package. Remember to save current settings before loading a profile. To test simply rename _profiles directory to profiles. It will be loaded into memory but not set. To set one you may do:
|
||||||
|
```powershell
|
||||||
|
Import-Module Voicemeeter
|
||||||
|
try {
|
||||||
|
$vmr = Get-RemoteBanana
|
||||||
|
$vmr.Set_Profile("config")
|
||||||
|
}
|
||||||
|
finally { $vmr.Logout() }
|
||||||
|
```
|
||||||
|
will load a config file at profiles/banana/config.psd1 for Voicemeeter Banana.
|
||||||
|
|
||||||
### Run tests
|
### Run tests
|
||||||
Run tests using .\runall.ps1 which accepts two parameters:
|
Run tests using .\runall.ps1 which accepts two parameters:
|
||||||
- tag Run tests of this type
|
- tag Run tests of this type
|
||||||
|
32
_profiles/banana/config.psd1
Normal file
32
_profiles/banana/config.psd1
Normal file
@ -0,0 +1,32 @@
|
|||||||
|
@{
|
||||||
|
strip_0 = @{
|
||||||
|
A1 = $false
|
||||||
|
A2 = $false
|
||||||
|
A3 = $false
|
||||||
|
B1 = $false
|
||||||
|
B2 = $false
|
||||||
|
mono = $false
|
||||||
|
solo = $false
|
||||||
|
mute = $false
|
||||||
|
}
|
||||||
|
strip_1 = @{
|
||||||
|
A1 = $true
|
||||||
|
A2 = $true
|
||||||
|
A3 = $true
|
||||||
|
B1 = $true
|
||||||
|
B2 = $true
|
||||||
|
mono = $true
|
||||||
|
solo = $true
|
||||||
|
mute = $true
|
||||||
|
}
|
||||||
|
strip_2 = @{
|
||||||
|
A1 = $false
|
||||||
|
A2 = $false
|
||||||
|
A3 = $false
|
||||||
|
B1 = $false
|
||||||
|
B2 = $false
|
||||||
|
mono = $false
|
||||||
|
solo = $false
|
||||||
|
mute = $false
|
||||||
|
}
|
||||||
|
}
|
@ -6,7 +6,8 @@ class Remote {
|
|||||||
[System.Collections.ArrayList]$bus
|
[System.Collections.ArrayList]$bus
|
||||||
[System.Collections.ArrayList]$button
|
[System.Collections.ArrayList]$button
|
||||||
[PSCustomObject]$vban
|
[PSCustomObject]$vban
|
||||||
$command
|
[Object]$command
|
||||||
|
[Object]$profiles
|
||||||
|
|
||||||
# Constructor
|
# Constructor
|
||||||
Remote ([String]$kind)
|
Remote ([String]$kind)
|
||||||
@ -19,6 +20,7 @@ class Remote {
|
|||||||
if(Setup_DLL) {
|
if(Setup_DLL) {
|
||||||
Login -KIND $this.kind
|
Login -KIND $this.kind
|
||||||
|
|
||||||
|
$this.profiles = Get_Profiles
|
||||||
$this.strip = Make_Strips
|
$this.strip = Make_Strips
|
||||||
$this.bus = Make_Buses
|
$this.bus = Make_Buses
|
||||||
$this.button = Make_Buttons
|
$this.button = Make_Buttons
|
||||||
@ -32,6 +34,10 @@ class Remote {
|
|||||||
Logout
|
Logout
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[void] Set_Profile([String]$config) {
|
||||||
|
Set_Profile -DATA $this.profiles -CONF $config
|
||||||
|
}
|
||||||
|
|
||||||
[Single] Getter([String]$param) {
|
[Single] Getter([String]$param) {
|
||||||
return Param_Get -PARAM $param
|
return Param_Get -PARAM $param
|
||||||
}
|
}
|
||||||
|
47
lib/base.ps1
47
lib/base.ps1
@ -174,7 +174,7 @@ Function DefineVersion {
|
|||||||
|
|
||||||
if($TYPE -eq 1) {
|
if($TYPE -eq 1) {
|
||||||
$layout = @{
|
$layout = @{
|
||||||
"version" = "basic"
|
"name" = "basic"
|
||||||
"p_in" = 2
|
"p_in" = 2
|
||||||
"v_in" = 1
|
"v_in" = 1
|
||||||
"p_out" = 1
|
"p_out" = 1
|
||||||
@ -185,7 +185,7 @@ Function DefineVersion {
|
|||||||
}
|
}
|
||||||
elseif($TYPE -eq 2) {
|
elseif($TYPE -eq 2) {
|
||||||
$layout = @{
|
$layout = @{
|
||||||
"version" = "banana"
|
"name" = "banana"
|
||||||
"p_in" = 3
|
"p_in" = 3
|
||||||
"v_in" = 2
|
"v_in" = 2
|
||||||
"p_out" = 3
|
"p_out" = 3
|
||||||
@ -196,7 +196,7 @@ Function DefineVersion {
|
|||||||
}
|
}
|
||||||
elseif($TYPE -eq 3) {
|
elseif($TYPE -eq 3) {
|
||||||
$layout = @{
|
$layout = @{
|
||||||
"version" = "potato"
|
"name" = "potato"
|
||||||
"p_in" = 5
|
"p_in" = 5
|
||||||
"v_in" = 3
|
"v_in" = 3
|
||||||
"p_out" = 5
|
"p_out" = 5
|
||||||
@ -208,6 +208,47 @@ Function DefineVersion {
|
|||||||
$global:layout = $layout
|
$global:layout = $layout
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Function Get_Profiles {
|
||||||
|
$basepath = Join-Path -Path $(Split-Path -Path $PSScriptRoot) -ChildPath "profiles"
|
||||||
|
if (Test-Path $basepath) {
|
||||||
|
$fullpath = Join-Path -Path $basepath -ChildPath $layout.name
|
||||||
|
} else {return $null}
|
||||||
|
$filenames = @(Get-ChildItem -Path $fullpath -Filter *.psd1 -Recurse -File)
|
||||||
|
|
||||||
|
if($filenames) {
|
||||||
|
[System.Collections.ArrayList]$configfiles = @()
|
||||||
|
$filenames | ForEach-Object {
|
||||||
|
$file = (Join-Path -Path $fullpath -ChildPath $_)
|
||||||
|
$configfiles.Add($file)
|
||||||
|
}
|
||||||
|
|
||||||
|
[HashTable]$data = @{}
|
||||||
|
$configfiles | ForEach-Object {
|
||||||
|
$filename = [System.IO.Path]::GetFileNameWithoutExtension($_)
|
||||||
|
Write-Host ("Importing profile " + $layout.name + "/" + $filename)
|
||||||
|
$data[$filename] = Import-PowerShellDataFile -Path $_
|
||||||
|
}
|
||||||
|
return $data
|
||||||
|
}
|
||||||
|
return $null
|
||||||
|
}
|
||||||
|
|
||||||
|
Function Set_Profile {
|
||||||
|
param(
|
||||||
|
[Object]$DATA, [String]$CONF
|
||||||
|
)
|
||||||
|
try {
|
||||||
|
if($null -eq $DATA -or -not $DATA.$CONF) {
|
||||||
|
throw [VMRemoteErrors]::new("No profile named $CONF was loaded")
|
||||||
|
}
|
||||||
|
Param_Set_Multi -HASH $DATA.$CONF
|
||||||
|
Start-Sleep -m 1
|
||||||
|
}
|
||||||
|
catch [VMRemoteErrors] {
|
||||||
|
Write-Warning $_.Exception.ErrorMessage()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
Function Login {
|
Function Login {
|
||||||
param(
|
param(
|
||||||
[String]$KIND=$null
|
[String]$KIND=$null
|
||||||
|
Loading…
Reference in New Issue
Block a user