2021-04-28 17:38:36 +01:00
|
|
|
class Strip {
|
|
|
|
[int32]$id
|
2021-05-16 00:14:51 +01:00
|
|
|
[Array]$string_params
|
|
|
|
[Array]$float_params
|
|
|
|
[Array]$bool_params
|
|
|
|
|
|
|
|
hidden AddPublicMembers() {
|
|
|
|
[HashTable]$Signatures = @{}
|
|
|
|
@($this.bool_params, $this.string_params, $this.float_params) | ForEach-Object {
|
|
|
|
ForEach($param in $_) {
|
|
|
|
if($this.bool_params.Contains($param)) {
|
|
|
|
# Define getter
|
|
|
|
$Signatures["Getter"] = "`$this.Getter(`$this.cmd('{0}'))" -f $param
|
|
|
|
# Define setter
|
|
|
|
$Signatures["Setter"] = "param ( [Single]`$arg )`n`$this.Setter(`$this.cmd('{0}'), `$arg)" `
|
|
|
|
-f $param
|
|
|
|
}
|
|
|
|
elseif($this.float_params.Contains($param)) {
|
|
|
|
# Define getter
|
|
|
|
if($param -eq "limit") {
|
|
|
|
$Signatures["Getter"] = "[Int]`$this.Getter(`$this.cmd('{0}'))" -f $param
|
|
|
|
} else {
|
|
|
|
$Signatures["Getter"] = "[math]::Round(`$this.Getter(`$this.cmd('{0}')), 1)" -f $param
|
|
|
|
}
|
|
|
|
# Define setter
|
|
|
|
$Signatures["Setter"] = "param ( [Single]`$arg )`n`$this.Setter(`$this.cmd('{0}'), `$arg)" `
|
|
|
|
-f $param
|
|
|
|
}
|
|
|
|
elseif($this.string_params.Contains($param)) {
|
|
|
|
# Define getter
|
|
|
|
$Signatures["Getter"] = "[String]`$this.Getter_String(`$this.cmd('{0}'))" -f $param
|
|
|
|
# Define setter
|
|
|
|
$Signatures["Setter"] = "param ( [String]`$arg )`n`$this.Setter(`$this.cmd('{0}'), `$arg)" `
|
|
|
|
-f $param
|
|
|
|
}
|
|
|
|
|
|
|
|
$GetterScriptBlock = [ScriptBlock]::Create($Signatures["Getter"])
|
|
|
|
$SetterScriptBlock = [ScriptBlock]::Create($Signatures["Setter"])
|
|
|
|
$AddMemberParams = @{
|
|
|
|
Name = $param
|
|
|
|
MemberType = 'ScriptProperty'
|
|
|
|
Value = $GetterScriptBlock
|
|
|
|
SecondValue = $SetterScriptBlock
|
|
|
|
}
|
|
|
|
$this | Add-Member @AddMemberParams
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2021-04-28 17:38:36 +01:00
|
|
|
|
|
|
|
# Constructor
|
|
|
|
Strip ([Int]$id)
|
|
|
|
{
|
|
|
|
$this.id = $id
|
2021-05-16 00:14:51 +01:00
|
|
|
$this.string_params = @('label')
|
|
|
|
$this.bool_params = @('mono', 'solo', 'mute',
|
|
|
|
'A1', 'A2', 'A3', 'A4', 'A5',
|
|
|
|
'B1', 'B2', 'B3')
|
|
|
|
$this.float_params = @('gain', 'comp', 'gate', 'limit')
|
|
|
|
$this.AddPublicMembers()
|
2021-04-28 17:38:36 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
[void] Setter($cmd, $set) {
|
2021-05-16 00:14:51 +01:00
|
|
|
if( $this.string_params.Contains($cmd.Split('.')[1]) ) {
|
|
|
|
Param_Set_String -PARAM $cmd -VALUE $set
|
2021-05-11 19:09:57 +01:00
|
|
|
}
|
|
|
|
else { Param_Set -PARAM $cmd -VALUE $set }
|
2021-04-28 17:38:36 +01:00
|
|
|
}
|
|
|
|
|
2021-04-28 18:21:32 +01:00
|
|
|
[Single] Getter($cmd) {
|
2021-04-28 17:38:36 +01:00
|
|
|
return Param_Get -PARAM $cmd
|
|
|
|
}
|
|
|
|
|
2021-05-11 19:09:57 +01:00
|
|
|
[String] Getter_String($cmd) {
|
|
|
|
return Param_Get_String -PARAM $cmd
|
|
|
|
}
|
|
|
|
|
|
|
|
[String] cmd ($arg) {
|
2021-04-28 17:38:36 +01:00
|
|
|
return "Strip[" + $this.id + "].$arg"
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
Function Strips {
|
|
|
|
[System.Collections.ArrayList]$strip = @()
|
|
|
|
0..$($layout.Strip-1) | ForEach-Object {
|
|
|
|
[void]$strip.Add([Strip]::new($_))
|
|
|
|
}
|
|
|
|
$strip
|
|
|
|
}
|