add quick.ps1 to gitignore

run formatter on files
This commit is contained in:
onyx-and-iris 2022-06-25 15:20:36 +01:00
parent 4417075330
commit 8429fed8b4
12 changed files with 122 additions and 122 deletions

3
.gitignore vendored
View File

@ -1,2 +1,5 @@
# quick test
quick.ps1
lib/*.psd1 lib/*.psd1
**/*.log **/*.log

View File

@ -203,7 +203,7 @@ The following methods are available:
- pause - pause
- record - record
- ff - ff
- rw - rew
The following properties accept boolean values. The following properties accept boolean values.

View File

@ -11,14 +11,13 @@ class Remote {
[Object]$profiles [Object]$profiles
# Constructor # Constructor
Remote ([String]$kind) Remote ([String]$kind) {
{
$this.kind = $kind $this.kind = $kind
$this.Setup() $this.Setup()
} }
[void] Setup() { [void] Setup() {
if(Setup_DLL) { if (Setup_DLL) {
Login -KIND $this.kind Login -KIND $this.kind
$this.profiles = Get_Profiles $this.profiles = Get_Profiles

View File

@ -13,13 +13,13 @@ Function Setup_DLL {
try { try {
$vb_path = Get_VBPath $vb_path = Get_VBPath
if([string]::IsNullOrWhiteSpace($vb_path)) { if ([string]::IsNullOrWhiteSpace($vb_path)) {
throw [VMRemoteErrors]::new("ERROR: Couldn't get Voicemeeter path") throw [VMRemoteErrors]::new("ERROR: Couldn't get Voicemeeter path")
} }
else { else {
$dll = Join-Path -Path $vb_path -ChildPath ("VoicemeeterRemote" + ` $dll = Join-Path -Path $vb_path -ChildPath ("VoicemeeterRemote" + `
(&{If([Environment]::Is64BitOperatingSystem) {"64"} Else {""}}) + ` (& { If ([Environment]::Is64BitOperatingSystem) { "64" } Else { "" } }) + `
".dll") ".dll")
} }
} }
catch [VMRemoteErrors] { catch [VMRemoteErrors] {
@ -27,7 +27,7 @@ Function Setup_DLL {
return $false return $false
} }
$Signature = @" $Signature = @"
[DllImport(@"$dll")] [DllImport(@"$dll")]
public static extern int VBVMR_Login(); public static extern int VBVMR_Login();
[DllImport(@"$dll")] [DllImport(@"$dll")]
@ -66,16 +66,16 @@ $Signature = @"
Function Param_Get { Function Param_Get {
param( param(
[String]$PARAM, [bool]$IS_STRING=$false [String]$PARAM, [bool]$IS_STRING = $false
) )
Start-Sleep -m 50 Start-Sleep -m 50
while(P_Dirty) { Start-Sleep -m 1 } while (P_Dirty) { Start-Sleep -m 1 }
if($IS_STRING) { if ($IS_STRING) {
$BYTES = [System.Byte[]]::new(512) $BYTES = [System.Byte[]]::new(512)
try { try {
$retval = [Int][Voicemeeter.Remote]::VBVMR_GetParameterStringA($PARAM, $BYTES) $retval = [Int][Voicemeeter.Remote]::VBVMR_GetParameterStringA($PARAM, $BYTES)
if($retval) { Throw [CAPIError]::new($retval, $MyInvocation.MyCommand) } if ($retval) { Throw [CAPIError]::new($retval, $MyInvocation.MyCommand) }
} }
catch [CAPIError] { catch [CAPIError] {
Write-Warning $_.Exception.ErrorMessage() Write-Warning $_.Exception.ErrorMessage()
@ -86,7 +86,7 @@ Function Param_Get {
New-Variable -Name ptr -Value 0.0 New-Variable -Name ptr -Value 0.0
try { try {
$retval = [Int][Voicemeeter.Remote]::VBVMR_GetParameterFloat($PARAM, [ref]$ptr) $retval = [Int][Voicemeeter.Remote]::VBVMR_GetParameterFloat($PARAM, [ref]$ptr)
if($retval) { Throw [CAPIError]::new($retval, $MyInvocation.MyCommand) } if ($retval) { Throw [CAPIError]::new($retval, $MyInvocation.MyCommand) }
} }
catch [CAPIError] { catch [CAPIError] {
Write-Warning $_.Exception.ErrorMessage() Write-Warning $_.Exception.ErrorMessage()
@ -100,13 +100,13 @@ Function Param_Set {
[String]$PARAM, [Object]$VALUE [String]$PARAM, [Object]$VALUE
) )
try { try {
if($VALUE -is [String]) { if ($VALUE -is [String]) {
$retval = [Int][Voicemeeter.Remote]::VBVMR_SetParameterStringA($PARAM, $VALUE) $retval = [Int][Voicemeeter.Remote]::VBVMR_SetParameterStringA($PARAM, $VALUE)
} }
else { else {
$retval = [Int][Voicemeeter.Remote]::VBVMR_SetParameterFloat($PARAM, $VALUE) $retval = [Int][Voicemeeter.Remote]::VBVMR_SetParameterFloat($PARAM, $VALUE)
} }
if($retval) { Throw [CAPIError]::new($retval, $MyInvocation.MyCommand) } if ($retval) { Throw [CAPIError]::new($retval, $MyInvocation.MyCommand) }
} }
catch [CAPIError] { catch [CAPIError] {
Write-Warning $_.Exception.ErrorMessage() Write-Warning $_.Exception.ErrorMessage()
@ -119,7 +119,7 @@ Function MB_Set {
) )
try { try {
$retval = [Int][Voicemeeter.Remote]::VBVMR_MacroButton_SetStatus($ID, $SET, $MODE) $retval = [Int][Voicemeeter.Remote]::VBVMR_MacroButton_SetStatus($ID, $SET, $MODE)
if($retval) { Throw [CAPIError]::new($retval, $MyInvocation.MyCommand) } if ($retval) { Throw [CAPIError]::new($retval, $MyInvocation.MyCommand) }
} }
catch [CAPIError] { catch [CAPIError] {
Write-Warning $_.Exception.ErrorMessage() Write-Warning $_.Exception.ErrorMessage()
@ -131,12 +131,12 @@ Function MB_Get {
[Int64]$ID, [Int64]$MODE [Int64]$ID, [Int64]$MODE
) )
Start-Sleep -m 50 Start-Sleep -m 50
while(M_Dirty) { Start-Sleep -m 1 } while (M_Dirty) { Start-Sleep -m 1 }
New-Variable -Name ptr -Value 0.0 New-Variable -Name ptr -Value 0.0
try { try {
$retval = [Int][Voicemeeter.Remote]::VBVMR_MacroButton_GetStatus($ID, [ref]$ptr, $MODE) $retval = [Int][Voicemeeter.Remote]::VBVMR_MacroButton_GetStatus($ID, [ref]$ptr, $MODE)
if($retval) { Throw [CAPIError]::new($retval, $MyInvocation.MyCommand) } if ($retval) { Throw [CAPIError]::new($retval, $MyInvocation.MyCommand) }
} }
catch [CAPIError] { catch [CAPIError] {
Write-Warning $_.Exception.ErrorMessage() Write-Warning $_.Exception.ErrorMessage()
@ -150,17 +150,17 @@ Function Param_Set_Multi {
) )
ForEach ($key in $HASH.keys) { ForEach ($key in $HASH.keys) {
$classobj , $m2, $m3 = $key.Split("_") $classobj , $m2, $m3 = $key.Split("_")
if ($m2 -match "^\d+$") {$index = [int]$m2} else {$index = [int]$m3} if ($m2 -match "^\d+$") { $index = [int]$m2 } else { $index = [int]$m3 }
ForEach ($h in $HASH[$key].GetEnumerator()) { ForEach ($h in $HASH[$key].GetEnumerator()) {
$property = $h.Name $property = $h.Name
$value = $h.Value $value = $h.Value
if ($value -in ('False', 'True')) { [System.Convert]::ToBoolean($value) } if ($value -in ('False', 'True')) { [System.Convert]::ToBoolean($value) }
Switch($classobj) { Switch ($classobj) {
'strip' { $this.strip[$index].$property = $value } 'strip' { $this.strip[$index].$property = $value }
'bus' { $this.bus[$index].$property = $value } 'bus' { $this.bus[$index].$property = $value }
{($_ -eq 'button') -or ($_ -eq 'mb')} { $this.button[$index].$property = $value } { ($_ -eq 'button') -or ($_ -eq 'mb') } { $this.button[$index].$property = $value }
'vban' { $this.vban.$m2[$index].$property = $value } 'vban' { $this.vban.$m2[$index].$property = $value }
} }
} }
@ -173,36 +173,36 @@ Function DefineVersion {
) )
$layout = @{} $layout = @{}
if($TYPE -eq 1) { if ($TYPE -eq 1) {
$layout = @{ $layout = @{
"name" = "basic" "name" = "basic"
"p_in" = 2 "p_in" = 2
"v_in" = 1 "v_in" = 1
"p_out" = 1 "p_out" = 1
"v_out" = 1 "v_out" = 1
"vban_in" = 4 "vban_in" = 4
"vban_out" = 4 "vban_out" = 4
} }
} }
elseif($TYPE -eq 2) { elseif ($TYPE -eq 2) {
$layout = @{ $layout = @{
"name" = "banana" "name" = "banana"
"p_in" = 3 "p_in" = 3
"v_in" = 2 "v_in" = 2
"p_out" = 3 "p_out" = 3
"v_out" = 2 "v_out" = 2
"vban_in" = 8 "vban_in" = 8
"vban_out" = 8 "vban_out" = 8
} }
} }
elseif($TYPE -eq 3) { elseif ($TYPE -eq 3) {
$layout = @{ $layout = @{
"name" = "potato" "name" = "potato"
"p_in" = 5 "p_in" = 5
"v_in" = 3 "v_in" = 3
"p_out" = 5 "p_out" = 5
"v_out" = 3 "v_out" = 3
"vban_in" = 8 "vban_in" = 8
"vban_out" = 8 "vban_out" = 8
} }
} }
@ -213,10 +213,11 @@ Function Get_Profiles {
$basepath = Join-Path -Path $(Split-Path -Path $PSScriptRoot) -ChildPath "profiles" $basepath = Join-Path -Path $(Split-Path -Path $PSScriptRoot) -ChildPath "profiles"
if (Test-Path $basepath) { if (Test-Path $basepath) {
$fullpath = Join-Path -Path $basepath -ChildPath $layout.name $fullpath = Join-Path -Path $basepath -ChildPath $layout.name
} else {return $null} }
else { return $null }
$filenames = @(Get-ChildItem -Path $fullpath -Filter *.psd1 -Recurse -File) $filenames = @(Get-ChildItem -Path $fullpath -Filter *.psd1 -Recurse -File)
if($filenames) { if ($filenames) {
[System.Collections.ArrayList]$configfiles = @() [System.Collections.ArrayList]$configfiles = @()
$filenames | ForEach-Object { $filenames | ForEach-Object {
$file = (Join-Path -Path $fullpath -ChildPath $_) $file = (Join-Path -Path $fullpath -ChildPath $_)
@ -239,7 +240,7 @@ Function Set_Profile {
[Object]$DATA, [String]$CONF [Object]$DATA, [String]$CONF
) )
try { try {
if($null -eq $DATA -or -not $DATA.$CONF) { if ($null -eq $DATA -or -not $DATA.$CONF) {
throw [VMRemoteErrors]::new("No profile named $CONF was loaded") throw [VMRemoteErrors]::new("No profile named $CONF was loaded")
} }
Param_Set_Multi -HASH $DATA.$CONF Param_Set_Multi -HASH $DATA.$CONF
@ -252,47 +253,50 @@ Function Set_Profile {
Function Login { Function Login {
param( param(
[String]$KIND=$null [String]$KIND = $null
) )
try { try {
$retval = [Int][Voicemeeter.Remote]::VBVMR_Login() $retval = [Int][Voicemeeter.Remote]::VBVMR_Login()
if(-not $retval) { Write-Host("LOGGED IN") } if (-not $retval) { Write-Host("LOGGED IN") }
elseif($retval -eq 1) { elseif ($retval -eq 1) {
Write-Host("VM NOT RUNNING") Write-Host("VM NOT RUNNING")
New-Variable -Name vm_exe -Value 0 New-Variable -Name vm_exe -Value 0
Switch($KIND) { Switch ($KIND) {
'basic' { $vm_exe = 1; Break} 'basic' { $vm_exe = 1; Break }
'banana' { $vm_exe = 2; Break} 'banana' { $vm_exe = 2; Break }
'potato' { 'potato' {
if ([Environment]::Is64BitOperatingSystem) { if ([Environment]::Is64BitOperatingSystem) {
$vm_exe = 6 $vm_exe = 6
} else { $vm_exe = 3 } }
else { $vm_exe = 3 }
Break Break
} }
Default { throw [LoginError]::new('Unknown Voicemeeter type') } Default { throw [LoginError]::new('Unknown Voicemeeter type') }
} }
$retval = [Int][Voicemeeter.Remote]::VBVMR_RunVoicemeeter([Int64]$vm_exe) $retval = [Int][Voicemeeter.Remote]::VBVMR_RunVoicemeeter([Int64]$vm_exe)
if(-not $retval) { Write-Host("STARTING VOICEMEETER") } if (-not $retval) { Write-Host("STARTING VOICEMEETER") }
else { Throw [CAPIError]::new($retval, $MyInvocation.MyCommand) } else { Throw [CAPIError]::new($retval, $MyInvocation.MyCommand) }
Start-Sleep -s 1 Start-Sleep -s 1
} elseif ($retval -eq -2) { }
elseif ($retval -eq -2) {
throw [LoginError]::new('Login may only be called once per session') throw [LoginError]::new('Login may only be called once per session')
} else { Exit } }
else { Exit }
} }
catch [LoginError], [CAPIError] { catch [LoginError], [CAPIError] {
Write-Warning $_.Exception.ErrorMessage() Write-Warning $_.Exception.ErrorMessage()
} }
while(P_Dirty -or M_Dirty) { Start-Sleep -m 1 } while (P_Dirty -or M_Dirty) { Start-Sleep -m 1 }
New-Variable -Name ptr -Value 0 New-Variable -Name ptr -Value 0
$retval = [Int][Voicemeeter.Remote]::VBVMR_GetVoicemeeterType([ref]$ptr) $retval = [Int][Voicemeeter.Remote]::VBVMR_GetVoicemeeterType([ref]$ptr)
if(-not $retval) { if (-not $retval) {
if($ptr -eq 1) { Write-Host("VERSION:[BASIC]") } if ($ptr -eq 1) { Write-Host("VERSION:[BASIC]") }
elseif($ptr -eq 2) { Write-Host("VERSION:[BANANA]") } elseif ($ptr -eq 2) { Write-Host("VERSION:[BANANA]") }
elseif($ptr -eq 3) { Write-Host("VERSION:[POTATO]") } elseif ($ptr -eq 3) { Write-Host("VERSION:[POTATO]") }
} }
DefineVersion -TYPE $ptr DefineVersion -TYPE $ptr
@ -301,7 +305,7 @@ Function Login {
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) { Write-Host("LOGGED OUT") } if (-not $retval) { Write-Host("LOGGED OUT") }
} }
Function P_Dirty { Function P_Dirty {

View File

@ -4,8 +4,7 @@ class Bus {
[Int]$id [Int]$id
# Constructor # Constructor
Bus ([Int]$id) Bus ([Int]$id) {
{
$this.id = $id $this.id = $id
AddBoolMembers -PARAMS @('mono', 'mute') AddBoolMembers -PARAMS @('mono', 'mute')
@ -13,7 +12,7 @@ class Bus {
AddFloatMembers -PARAMS @('gain') AddFloatMembers -PARAMS @('gain')
AddBusModeMembers -PARAMS @('normal', 'amix', 'bmix', 'repeat', 'composite', 'tvmix', 'upmix21', AddBusModeMembers -PARAMS @('normal', 'amix', 'bmix', 'repeat', 'composite', 'tvmix', 'upmix21',
'upmix41', 'upmix61', 'centeronly', 'lfeonly', 'rearonly') 'upmix41', 'upmix61', 'centeronly', 'lfeonly', 'rearonly')
} }
[Single] Getter($cmd) { [Single] Getter($cmd) {
@ -61,7 +60,7 @@ class PhysicalBus : Bus {
$this.Getter_String($this.cmd('device.name')) $this.Getter_String($this.cmd('device.name'))
}` }`
{ {
return Write-Warning("ERROR: " + $this.cmd('device.name') + " is read only") return Write-Warning("ERROR: " + $this.cmd('device.name') + " is read only")
} }
) )
@ -70,7 +69,7 @@ class PhysicalBus : Bus {
$this.Getter($this.cmd('device.sr')) $this.Getter($this.cmd('device.sr'))
}` }`
{ {
return Write-Warning("ERROR: " + $this.cmd('device.sr') + " is read only") return Write-Warning("ERROR: " + $this.cmd('device.sr') + " is read only")
} }
) )
} }
@ -82,7 +81,7 @@ class VirtualBus : Bus {
Function Make_Buses { Function Make_Buses {
[System.Collections.ArrayList]$bus = @() [System.Collections.ArrayList]$bus = @()
0..$($layout.p_out + $layout.v_out -1) | ForEach-Object { 0..$($layout.p_out + $layout.v_out - 1) | ForEach-Object {
if ($_ -lt $layout.p_out) { [void]$bus.Add([PhysicalBus]::new($_)) } if ($_ -lt $layout.p_out) { [void]$bus.Add([PhysicalBus]::new($_)) }
else { [void]$bus.Add([VirtualBus]::new($_)) } else { [void]$bus.Add([VirtualBus]::new($_)) }
} }

View File

@ -2,8 +2,7 @@
class Special { class Special {
# Constructor # Constructor
Special() Special() {
{
AddActionMembers -PARAMS @('restart', 'shutdown', 'show') AddActionMembers -PARAMS @('restart', 'shutdown', 'show')
} }
@ -13,7 +12,7 @@ class Special {
[void] Setter($param, $val) { [void] Setter($param, $val) {
if ($val -is [Boolean]) { if ($val -is [Boolean]) {
Param_Set -PARAM $param -VALUE $(if ($val) {1} else {0}) Param_Set -PARAM $param -VALUE $(if ($val) { 1 } else { 0 })
} }
else { else {
Param_Set -PARAM $param -VALUE $val Param_Set -PARAM $param -VALUE $val

View File

@ -1,7 +1,7 @@
Function Get_VBPath { Function Get_VBPath {
$reg_path = "Registry::HKEY_LOCAL_MACHINE\Software" + ` $reg_path = "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) return $(Get-ItemPropertyValue -Path ($reg_path + $vm_key) -Name UninstallString | Split-Path -Parent)

View File

@ -2,8 +2,7 @@ class MacroButton {
[int32]$id [int32]$id
# Constructor # Constructor
MacroButton ([Int]$id) MacroButton ([Int]$id) {
{
$this.id = $id $this.id = $id
} }

View File

@ -3,12 +3,12 @@ Function AddBoolMembers() {
[String[]]$PARAMS [String[]]$PARAMS
) )
[HashTable]$Signatures = @{} [HashTable]$Signatures = @{}
ForEach($param in $PARAMS) { ForEach ($param in $PARAMS) {
# Define getter # Define getter
$Signatures["Getter"] = "[bool]`$this.Getter(`$this.cmd('{0}'))" -f $param $Signatures["Getter"] = "[bool]`$this.Getter(`$this.cmd('{0}'))" -f $param
# Define setter # Define setter
$Signatures["Setter"] = "param ( [Single]`$arg )`n`$this.Setter(`$this.cmd('{0}'), `$arg)" ` $Signatures["Setter"] = "param ( [Single]`$arg )`n`$this.Setter(`$this.cmd('{0}'), `$arg)" `
-f $param -f $param
Addmember Addmember
} }
@ -19,12 +19,12 @@ Function AddFloatMembers() {
[String[]]$PARAMS [String[]]$PARAMS
) )
[HashTable]$Signatures = @{} [HashTable]$Signatures = @{}
ForEach($param in $PARAMS) { ForEach ($param in $PARAMS) {
# Define getter # Define getter
$Signatures["Getter"] = "[math]::Round(`$this.Getter(`$this.cmd('{0}')), 1)" -f $param $Signatures["Getter"] = "[math]::Round(`$this.Getter(`$this.cmd('{0}')), 1)" -f $param
# Define setter # Define setter
$Signatures["Setter"] = "param ( [Single]`$arg )`n`$this.Setter(`$this.cmd('{0}'), `$arg)" ` $Signatures["Setter"] = "param ( [Single]`$arg )`n`$this.Setter(`$this.cmd('{0}'), `$arg)" `
-f $param -f $param
Addmember Addmember
} }
@ -35,12 +35,12 @@ Function AddIntMembers() {
[String[]]$PARAMS [String[]]$PARAMS
) )
[HashTable]$Signatures = @{} [HashTable]$Signatures = @{}
ForEach($param in $PARAMS) { ForEach ($param in $PARAMS) {
# Define getter # Define getter
$Signatures["Getter"] = "[Int]`$this.Getter(`$this.cmd('{0}'))" -f $param $Signatures["Getter"] = "[Int]`$this.Getter(`$this.cmd('{0}'))" -f $param
# Define setter # Define setter
$Signatures["Setter"] = "param ( [Single]`$arg )`n`$this.Setter(`$this.cmd('{0}'), `$arg)" ` $Signatures["Setter"] = "param ( [Single]`$arg )`n`$this.Setter(`$this.cmd('{0}'), `$arg)" `
-f $param -f $param
Addmember Addmember
} }
@ -51,12 +51,12 @@ Function AddStringMembers() {
[String[]]$PARAMS [String[]]$PARAMS
) )
[HashTable]$Signatures = @{} [HashTable]$Signatures = @{}
ForEach($param in $PARAMS) { ForEach ($param in $PARAMS) {
# Define getter # Define getter
$Signatures["Getter"] = "[String]`$this.Getter_String(`$this.cmd('{0}'))" -f $param $Signatures["Getter"] = "[String]`$this.Getter_String(`$this.cmd('{0}'))" -f $param
# Define setter # Define setter
$Signatures["Setter"] = "param ( [String]`$arg )`n`$this.Setter(`$this.cmd('{0}'), `$arg)" ` $Signatures["Setter"] = "param ( [String]`$arg )`n`$this.Setter(`$this.cmd('{0}'), `$arg)" `
-f $param -f $param
Addmember Addmember
} }
@ -67,7 +67,7 @@ Function AddActionMembers() {
[String[]]$PARAMS [String[]]$PARAMS
) )
[HashTable]$Signatures = @{} [HashTable]$Signatures = @{}
ForEach($param in $PARAMS) { ForEach ($param in $PARAMS) {
# Define getter # Define getter
$Signatures["Getter"] = "`$this.Setter(`$this.cmd('{0}'), `$true)" -f $param $Signatures["Getter"] = "`$this.Setter(`$this.cmd('{0}'), `$true)" -f $param
# Define setter # Define setter
@ -83,7 +83,7 @@ Function AddChannelMembers() {
[System.Collections.ArrayList]$channels = @() [System.Collections.ArrayList]$channels = @()
1..$($num_A + $num_B) | ForEach-Object { 1..$($num_A + $num_B) | ForEach-Object {
if($_ -le $num_A) {$channels.Add("A{0}" -f $_)} else {$channels.Add("B{0}" -f $($_ - $num_A))} if ($_ -le $num_A) { $channels.Add("A{0}" -f $_) } else { $channels.Add("B{0}" -f $($_ - $num_A)) }
} }
AddBoolMembers -PARAMS $channels AddBoolMembers -PARAMS $channels
@ -96,7 +96,7 @@ Function AddGainlayerMembers() {
$Signatures["Getter"] = "`$this.Getter(`$this.cmd('gainlayer[{0}]'))" -f $_ $Signatures["Getter"] = "`$this.Getter(`$this.cmd('gainlayer[{0}]'))" -f $_
# Define setter # Define setter
$Signatures["Setter"] = "param ( [Single]`$arg )`n`$this.Setter(`$this.cmd('gainlayer[{0}]'), `$arg)" ` $Signatures["Setter"] = "param ( [Single]`$arg )`n`$this.Setter(`$this.cmd('gainlayer[{0}]'), `$arg)" `
-f $_ -f $_
$param = "gainlayer{0}" -f $_ $param = "gainlayer{0}" -f $_
Addmember Addmember
@ -108,23 +108,23 @@ Function AddBusModeMembers() {
[String[]]$PARAMS [String[]]$PARAMS
) )
[HashTable]$Signatures = @{} [HashTable]$Signatures = @{}
ForEach($param in $PARAMS) { ForEach ($param in $PARAMS) {
# Define getter # Define getter
$Signatures["Getter"] = "[bool]`$this.Getter(`$this.cmd('mode.{0}'))" -f $param $Signatures["Getter"] = "[bool]`$this.Getter(`$this.cmd('mode.{0}'))" -f $param
# Define setter # Define setter
$Signatures["Setter"] = "param ( [Single]`$arg )`n`$this.Setter(`$this.cmd('mode.{0}'), `$arg)" ` $Signatures["Setter"] = "param ( [Single]`$arg )`n`$this.Setter(`$this.cmd('mode.{0}'), `$arg)" `
-f $param -f $param
$param = "mode_{0}" -f $param $param = "mode_{0}" -f $param
Addmember Addmember
} }
} }
Function Addmember{ Function Addmember {
$AddMemberParams = @{ $AddMemberParams = @{
Name = $param Name = $param
MemberType = 'ScriptProperty' MemberType = 'ScriptProperty'
Value = [ScriptBlock]::Create($Signatures["Getter"]) Value = [ScriptBlock]::Create($Signatures["Getter"])
SecondValue = [ScriptBlock]::Create($Signatures["Setter"]) SecondValue = [ScriptBlock]::Create($Signatures["Setter"])
} }
$this | Add-Member @AddMemberParams $this | Add-Member @AddMemberParams

View File

@ -2,9 +2,8 @@
class Recorder { class Recorder {
# Constructor # Constructor
Recorder() Recorder() {
{ AddActionMembers -PARAMS @('play', 'stop', 'pause', 'replay', 'record', 'ff', 'rew')
AddActionMembers -PARAMS @('play', 'stop', 'pause', 'replay', 'record', 'ff', 'rw')
AddChannelMembers AddChannelMembers
} }
@ -14,7 +13,7 @@ class Recorder {
[void] Setter($param, $val) { [void] Setter($param, $val) {
if ($val -is [Boolean]) { if ($val -is [Boolean]) {
Param_Set -PARAM $param -VALUE $(if ($val) {1} else {0}) Param_Set -PARAM $param -VALUE $(if ($val) { 1 } else { 0 })
} }
else { else {
Param_Set -PARAM $param -VALUE $val Param_Set -PARAM $param -VALUE $val
@ -27,7 +26,7 @@ class Recorder {
hidden $_loop = $($this | Add-Member ScriptProperty 'loop' ` hidden $_loop = $($this | Add-Member ScriptProperty 'loop' `
{ {
return Write-Warning("ERROR: " + $this.cmd('mode.loop') + " is write only") return Write-Warning("ERROR: " + $this.cmd('mode.loop') + " is write only")
}` }`
{ {
param( [bool]$arg ) param( [bool]$arg )

View File

@ -3,8 +3,7 @@
class Strip { class Strip {
[Int]$id [Int]$id
Strip ([Int]$id) Strip ([Int]$id) {
{
$this.id = $id $this.id = $id
AddBoolMembers -PARAMS @('mono', 'solo', 'mute') AddBoolMembers -PARAMS @('mono', 'solo', 'mute')
@ -43,7 +42,7 @@ class PhysicalStrip : Strip {
$this.Getter_String($this.cmd('device.name')) $this.Getter_String($this.cmd('device.name'))
}` }`
{ {
return Write-Warning("ERROR: " + $this.cmd('device.name') + " is read only") return Write-Warning("ERROR: " + $this.cmd('device.name') + " is read only")
} }
) )
@ -52,7 +51,7 @@ class PhysicalStrip : Strip {
$this.Getter($this.cmd('device.sr')) $this.Getter($this.cmd('device.sr'))
}` }`
{ {
return Write-Warning("ERROR: " + $this.cmd('device.sr') + " is read only") return Write-Warning("ERROR: " + $this.cmd('device.sr') + " is read only")
} }
) )
} }

View File

@ -3,8 +3,7 @@ class Vban {
[String]$direction [String]$direction
# Constructor # Constructor
Vban($id) Vban($id) {
{
$this.id = $id $this.id = $id
} }
@ -60,7 +59,7 @@ class Vban {
}` }`
{ {
param ( [String]$arg ) param ( [String]$arg )
if($arg -In 1024..65535) { if ($arg -In 1024..65535) {
$this._port = $this.Setter($this.cmd('port'), $arg) $this._port = $this.Setter($this.cmd('port'), $arg)
} }
else { else {
@ -75,10 +74,10 @@ class Vban {
}` }`
{ {
param ( [Int]$arg ) param ( [Int]$arg )
if($this.direction -eq "in") { Write-Warning('Error, read only value') } if ($this.direction -eq "in") { Write-Warning('Error, read only value') }
else { else {
$opts = @(11025, 16000, 22050, 24000, 32000, 44100, 48000, 64000, 88200, 96000) $opts = @(11025, 16000, 22050, 24000, 32000, 44100, 48000, 64000, 88200, 96000)
if($opts.Contains($arg)) { if ($opts.Contains($arg)) {
$this._port = $this.Setter($this.cmd('sr'), $arg) $this._port = $this.Setter($this.cmd('sr'), $arg)
} }
else { else {
@ -94,9 +93,9 @@ class Vban {
}` }`
{ {
param ( [Int]$arg ) param ( [Int]$arg )
if($this.direction -eq "in") { Write-Warning('Error, read only value') } if ($this.direction -eq "in") { Write-Warning('Error, read only value') }
else { else {
if($arg -In 1..8) { if ($arg -In 1..8) {
$this._channel = $this.Setter($this.cmd('channel'), $arg) $this._channel = $this.Setter($this.cmd('channel'), $arg)
} }
else { else {
@ -108,15 +107,15 @@ class Vban {
hidden $_bit = $($this | Add-Member ScriptProperty 'bit' ` hidden $_bit = $($this | Add-Member ScriptProperty 'bit' `
{ {
$val = if($this.Getter($this.cmd('bit')) -eq 1) {16} else {24} $val = if ($this.Getter($this.cmd('bit')) -eq 1) { 16 } else { 24 }
return $val return $val
}` }`
{ {
param ( [Int]$arg ) param ( [Int]$arg )
if($this.direction -eq "in") { Write-Warning('Error, read only value') } if ($this.direction -eq "in") { Write-Warning('Error, read only value') }
else { else {
if(@(16,24).Contains($arg)) { if (@(16, 24).Contains($arg)) {
$val = if($arg -eq 16) {1} else {2} $val = if ($arg -eq 16) { 1 } else { 2 }
$this._bit = $this.Setter($this.cmd('bit'), $val) $this._bit = $this.Setter($this.cmd('bit'), $val)
} }
else { else {
@ -132,9 +131,9 @@ class Vban {
}` }`
{ {
param ( [Int]$arg ) param ( [Int]$arg )
if($this.direction -eq "in") { Write-Warning('Error, read only value') } if ($this.direction -eq "in") { Write-Warning('Error, read only value') }
else { else {
if($arg -In 0..4) { if ($arg -In 0..4) {
$this._quality = $this.Setter($this.cmd('quality'), $arg) $this._quality = $this.Setter($this.cmd('quality'), $arg)
} }
else { else {
@ -150,9 +149,9 @@ class Vban {
}` }`
{ {
param ( [Int]$arg ) param ( [Int]$arg )
if($this.direction -eq "in") { Write-Warning('Error, read only value') } if ($this.direction -eq "in") { Write-Warning('Error, read only value') }
else { else {
if($arg -In 0..8) { if ($arg -In 0..8) {
$this._route = $this.Setter($this.cmd('route'), $arg) $this._route = $this.Setter($this.cmd('route'), $arg)
} }
else { else {
@ -166,7 +165,7 @@ class Vban {
class VbanInstream : Vban { class VbanInstream : Vban {
# Constructor # Constructor
VbanInstream ([int]$id) : base ($id){ VbanInstream ([int]$id) : base ($id) {
$this.direction = "in" $this.direction = "in"
} }
} }
@ -174,7 +173,7 @@ class VbanInstream : Vban {
class VbanOutstream : Vban { class VbanOutstream : Vban {
# Constructor # Constructor
VbanOutstream ([int]$id) : base ($id){ VbanOutstream ([int]$id) : base ($id) {
$this.direction = "out" $this.direction = "out"
} }
} }
@ -184,15 +183,15 @@ Function Make_Vban {
[System.Collections.ArrayList]$instream = @() [System.Collections.ArrayList]$instream = @()
[System.Collections.ArrayList]$outstream = @() [System.Collections.ArrayList]$outstream = @()
0..$($layout.vban_in-1) | ForEach-Object { 0..$($layout.vban_in - 1) | ForEach-Object {
[void]$instream.Add([VbanInstream]::new($_)) [void]$instream.Add([VbanInstream]::new($_))
} }
0..$($layout.vban_out-1) | ForEach-Object { 0..$($layout.vban_out - 1) | ForEach-Object {
[void]$outstream.Add([VbanOutstream]::new($_)) [void]$outstream.Add([VbanOutstream]::new($_))
} }
$CustomObject = [PSCustomObject]@{ $CustomObject = [PSCustomObject]@{
instream = $instream instream = $instream
outstream = $outstream outstream = $outstream
} }
@ -202,7 +201,7 @@ Function Make_Vban {
}` }`
{ {
param( [bool]$arg ) param( [bool]$arg )
Param_Set -PARAM 'vban.Enable' -VALUE $(if ($arg) {1} else {0}) Param_Set -PARAM 'vban.Enable' -VALUE $(if ($arg) { 1 } else { 0 })
} }
$CustomObject $CustomObject