meta.ps1

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
Function AddBoolMembers() {
    param(
        [String[]]$PARAMS
    )
    [HashTable]$Signatures = @{}
    ForEach($param in $PARAMS) {
        # Define getter
        $Signatures["Getter"] = "[bool]`$this.Getter(`$this.cmd('{0}'))" -f $param
        # Define setter
        $Signatures["Setter"] = "param ( [Single]`$arg )`n`$this.Setter(`$this.cmd('{0}'), `$arg)"  `
        -f $param

        Addmember
    }
}

Function AddFloatMembers() {
    param(
        [String[]]$PARAMS
    )
    [HashTable]$Signatures = @{}
    ForEach($param in $PARAMS) {
        # Define getter
        $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

        Addmember
    }
}

Function AddIntMembers() {
    param(
        [String[]]$PARAMS
    )
    [HashTable]$Signatures = @{}
    ForEach($param in $PARAMS) {
        # Define getter
        $Signatures["Getter"] = "[Int]`$this.Getter(`$this.cmd('{0}'))" -f $param
        # Define setter
        $Signatures["Setter"] = "param ( [Single]`$arg )`n`$this.Setter(`$this.cmd('{0}'), `$arg)" `
        -f $param

        Addmember
    }
}

Function AddStringMembers() {
    param(
        [String[]]$PARAMS
    )
    [HashTable]$Signatures = @{}
    ForEach($param in $PARAMS) {
        # 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

        Addmember
    }    
}

Function AddActionMembers() { 
    param(
        [String[]]$PARAMS
    )
    [HashTable]$Signatures = @{}
    ForEach($param in $PARAMS) {
        # Define getter
        $Signatures["Getter"] = "`$this.Setter(`$this.cmd('{0}'), `$true)" -f $param
        # Define setter
        $Signatures["Setter"] = ""

        Addmember
    }
}

Function AddChannelMembers() {
    $num_A = $layout.p_out
    $num_B = $layout.v_out

    [System.Collections.ArrayList]$channels = @()
    1..$($num_A + $num_B) | ForEach-Object {
        if($_ -le $num_A) {$channels.Add("A{0}" -f $_)} else {$channels.Add("B{0}" -f $($_ - $num_A))}
    }

    AddBoolMembers -PARAMS $channels
}

Function AddGainlayerMembers() {
    [HashTable]$Signatures = @{}
    0..7 | ForEach-Object {
        # Define getter
        $Signatures["Getter"] = "`$this.Getter(`$this.cmd('gainlayer[{0}]'))" -f $_
        # Define setter
        $Signatures["Setter"] = "param ( [Single]`$arg )`n`$this.Setter(`$this.cmd('gainlayer[{0}]'), `$arg)" `
        -f $_
        $param = "gainlayer{0}" -f $_

        Addmember
    }
}

Function AddBusModeMembers() {
    param(
        [String[]]$PARAMS
    )
    [HashTable]$Signatures = @{}
    ForEach($param in $PARAMS) {
        # Define getter
        $Signatures["Getter"] = "[bool]`$this.Getter(`$this.cmd('mode.{0}'))" -f $param
        # Define setter
        $Signatures["Setter"] = "param ( [Single]`$arg )`n`$this.Setter(`$this.cmd('mode.{0}'), `$arg)"  `
        -f $param
        $param = "mode_{0}" -f $param

        Addmember
    }
}

Function Addmember{
    $AddMemberParams = @{
        Name = $param
        MemberType = 'ScriptProperty'
        Value = [ScriptBlock]::Create($Signatures["Getter"])
        SecondValue = [ScriptBlock]::Create($Signatures["Setter"])
    }
    $this | Add-Member @AddMemberParams
}