mirror of
https://github.com/onyx-and-iris/voicemeeter-api-powershell.git
synced 2025-01-18 13:20:47 +00:00
Update bus.ps1
eq property added. addpublicmembers removed.
This commit is contained in:
parent
2527399da0
commit
3c978f1489
46
lib/bus.ps1
46
lib/bus.ps1
@ -1,47 +1,17 @@
|
|||||||
|
. $PSScriptRoot\meta.ps1
|
||||||
|
|
||||||
class Bus {
|
class Bus {
|
||||||
[int32]$id
|
[int32]$id
|
||||||
[Array]$bool_params
|
[Array]$bool_params
|
||||||
[Array]$float_params
|
[Array]$float_params
|
||||||
|
|
||||||
hidden AddPublicMembers() {
|
|
||||||
[HashTable]$Signatures = @{}
|
|
||||||
@($this.bool_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
|
|
||||||
$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
|
|
||||||
}
|
|
||||||
|
|
||||||
$GetterScriptBlock = [ScriptBlock]::Create($Signatures["Getter"])
|
|
||||||
$SetterScriptBlock = [ScriptBlock]::Create($Signatures["Setter"])
|
|
||||||
$AddMemberParams = @{
|
|
||||||
Name = $param
|
|
||||||
MemberType = 'ScriptProperty'
|
|
||||||
Value = $GetterScriptBlock
|
|
||||||
SecondValue = $SetterScriptBlock
|
|
||||||
}
|
|
||||||
$this | Add-Member @AddMemberParams
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
# Constructor
|
# Constructor
|
||||||
Bus ([Int]$id)
|
Bus ([Int]$id)
|
||||||
{
|
{
|
||||||
$this.id = $id
|
$this.id = $id
|
||||||
$this.bool_params = @('mono', 'mute')
|
$this.bool_params = @('mono', 'mute')
|
||||||
$this.float_params = @('gain')
|
$this.float_params = @('gain')
|
||||||
$this.AddPublicMembers()
|
AddPublicMembers($this)
|
||||||
}
|
}
|
||||||
|
|
||||||
[void] Setter($cmd, $set) {
|
[void] Setter($cmd, $set) {
|
||||||
@ -55,6 +25,16 @@ class Bus {
|
|||||||
[string] cmd ($arg) {
|
[string] cmd ($arg) {
|
||||||
return "Bus[" + $this.id + "].$arg"
|
return "Bus[" + $this.id + "].$arg"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
hidden $_eq = $($this | Add-Member ScriptProperty 'eq' `
|
||||||
|
{
|
||||||
|
$this.Getter($this.cmd('EQ.on'))
|
||||||
|
}`
|
||||||
|
{
|
||||||
|
param ( $arg )
|
||||||
|
$this._eq = $this.Setter($this.cmd('EQ.on'), $arg)
|
||||||
|
}
|
||||||
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
Function Buses {
|
Function Buses {
|
||||||
|
Loading…
Reference in New Issue
Block a user