mirror of
https://github.com/onyx-and-iris/voicemeeter-api-powershell.git
synced 2026-04-18 13:33:31 +00:00
update to class getters/setters and meta module
rename factory functions. class getters now send is_string parameter. each property type for each class now has separate meta function.
This commit is contained in:
@@ -2,46 +2,30 @@
|
||||
|
||||
class Strip {
|
||||
[Int]$id
|
||||
[Array]$string_params
|
||||
[Array]$float_params
|
||||
[System.Collections.ArrayList]$bool_params
|
||||
[Array]$int_params
|
||||
|
||||
hidden SetChannelLayout($num_A, $num_B) {
|
||||
1..$num_A | ForEach-Object {
|
||||
$this.bool_params.Add("A{0}" -f $_)
|
||||
}
|
||||
1..$num_B | ForEach-Object {
|
||||
$this.bool_params.Add("B{0}" -f $_)
|
||||
}
|
||||
}
|
||||
|
||||
# Constructor
|
||||
Strip ([Int]$id, [Int]$num_A, [Int]$num_B)
|
||||
Strip ([Int]$id)
|
||||
{
|
||||
$this.id = $id
|
||||
$this.string_params = @('label')
|
||||
$this.float_params = @('gain', 'comp', 'gate')
|
||||
$this.int_params = @('limit')
|
||||
$this.bool_params = @('mono', 'solo', 'mute')
|
||||
$this.SetChannelLayout($num_A, $num_B)
|
||||
|
||||
AddPublicMembers($this)
|
||||
}
|
||||
AddBoolMembers -PARAMS @('mono', 'solo', 'mute')
|
||||
AddFloatMembers -PARAMS @('gain', 'comp', 'gate')
|
||||
AddIntMembers -PARAMS @('limit')
|
||||
AddStringMembers -PARAMS @('label')
|
||||
|
||||
[void] Setter($cmd, $set) {
|
||||
if( $this.string_params.Contains($cmd.Split('.')[1]) ) {
|
||||
Param_Set_String -PARAM $cmd -VALUE $set
|
||||
}
|
||||
else { Param_Set -PARAM $cmd -VALUE $set }
|
||||
AddChannelMembers
|
||||
}
|
||||
|
||||
[Single] Getter($cmd) {
|
||||
return Param_Get -PARAM $cmd
|
||||
return Param_Get -PARAM $cmd -IS_STRING $false
|
||||
}
|
||||
|
||||
[String] Getter_String($cmd) {
|
||||
return Param_Get_String -PARAM $cmd
|
||||
return Param_Get -PARAM $cmd -IS_STRING $true
|
||||
}
|
||||
|
||||
[void] Setter($cmd, $set) {
|
||||
Param_Set -PARAM $cmd -VALUE $set
|
||||
}
|
||||
|
||||
[String] cmd ($arg) {
|
||||
@@ -59,7 +43,7 @@ class Strip {
|
||||
|
||||
hidden $_sr = $($this | Add-Member ScriptProperty 'sr' `
|
||||
{
|
||||
$this.Getter_String($this.cmd('device.sr'))
|
||||
$this.Getter($this.cmd('device.sr'))
|
||||
}`
|
||||
{
|
||||
return Write-Warning("ERROR: " + $this.cmd('device.sr') + " is read only")
|
||||
@@ -68,23 +52,23 @@ class Strip {
|
||||
}
|
||||
|
||||
class PhysicalStrip : Strip {
|
||||
PhysicalStrip ([Int]$id, [Int]$num_A, [Int]$num_B) : base ($id, $num_A, $num_B) {
|
||||
PhysicalStrip ([Int]$id) : base ($id) {
|
||||
}
|
||||
}
|
||||
|
||||
class VirtualStrip : Strip {
|
||||
VirtualStrip ([Int]$id, [Int]$num_A, [Int]$num_B) : base ($id, $num_A, $num_B) {
|
||||
VirtualStrip ([Int]$id) : base ($id) {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Function Strips {
|
||||
Function Make_Strips {
|
||||
[System.Collections.ArrayList]$strip = @()
|
||||
0..$($layout.p_in + $layout.v_in - 1) | ForEach-Object {
|
||||
if ($_ -lt $layout.p_in) {
|
||||
[void]$strip.Add([PhysicalStrip]::new($_, $layout.p_out, $layout.v_out))
|
||||
[void]$strip.Add([PhysicalStrip]::new($_))
|
||||
}
|
||||
else { [void]$strip.Add([VirtualStrip]::new($_, $layout.p_out, $layout.v_out)) }
|
||||
else { [void]$strip.Add([VirtualStrip]::new($_)) }
|
||||
}
|
||||
$strip
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user