2022-01-06 15:26:38 +00:00
|
|
|
. $PSScriptRoot\meta.ps1
|
|
|
|
|
2022-12-16 17:18:51 +00:00
|
|
|
class IBus {
|
2022-10-27 21:20:03 +01:00
|
|
|
[int]$index
|
2022-06-25 23:12:02 +01:00
|
|
|
[Object]$remote
|
2022-12-16 17:18:51 +00:00
|
|
|
|
|
|
|
IBus ([int]$index, [Object]$remote) {
|
2022-10-27 21:20:03 +01:00
|
|
|
$this.index = $index
|
2022-06-25 23:12:02 +01:00
|
|
|
$this.remote = $remote
|
2022-12-16 17:18:51 +00:00
|
|
|
}
|
2021-04-28 17:38:36 +01:00
|
|
|
|
2022-12-16 17:18:51 +00:00
|
|
|
[string] identifier () {
|
|
|
|
return "Bus[" + $this.index + "]"
|
2021-04-28 17:38:36 +01:00
|
|
|
}
|
|
|
|
|
2022-10-27 21:20:03 +01:00
|
|
|
[string] ToString() {
|
|
|
|
return $this.GetType().Name + $this.index
|
|
|
|
}
|
|
|
|
|
2022-12-16 17:18:51 +00:00
|
|
|
[single] Getter ($param) {
|
|
|
|
return Param_Get -PARAM "$($this.identifier()).$param" -IS_STRING $false
|
2022-01-19 21:52:59 +00:00
|
|
|
}
|
|
|
|
|
2022-12-16 17:18:51 +00:00
|
|
|
[string] Getter_String ($param) {
|
|
|
|
return Param_Get -PARAM "$($this.identifier()).$param" -IS_STRING $true
|
2022-01-19 21:52:59 +00:00
|
|
|
}
|
|
|
|
|
2022-12-16 17:18:51 +00:00
|
|
|
[void] Setter ($param, $set) {
|
|
|
|
Param_Set -PARAM "$($this.identifier()).$param" -Value $set
|
2021-04-28 17:38:36 +01:00
|
|
|
}
|
2022-12-16 17:18:51 +00:00
|
|
|
}
|
2021-04-28 17:38:36 +01:00
|
|
|
|
2022-12-16 17:18:51 +00:00
|
|
|
class Bus : IBus {
|
2022-12-17 15:40:07 +00:00
|
|
|
[Object]$mode
|
2022-12-16 17:18:51 +00:00
|
|
|
[Object]$eq
|
2023-08-09 14:16:27 +01:00
|
|
|
[Object]$levels
|
2022-01-06 15:26:38 +00:00
|
|
|
|
2022-12-16 17:18:51 +00:00
|
|
|
Bus ([int]$index, [Object]$remote) : base ($index, $remote) {
|
|
|
|
AddBoolMembers -PARAMS @('mono', 'mute')
|
|
|
|
AddStringMembers -PARAMS @('label')
|
|
|
|
AddFloatMembers -PARAMS @('gain', 'returnreverb', 'returndelay', 'returnfx1', 'returnfx2')
|
2022-03-08 22:55:11 +00:00
|
|
|
|
2022-12-17 15:40:07 +00:00
|
|
|
$this.mode = [Mode]::new($index, $remote)
|
2022-12-16 17:18:51 +00:00
|
|
|
$this.eq = [Eq]::new($index, $remote)
|
2023-08-09 14:16:27 +01:00
|
|
|
$this.levels = [Levels]::new($index, $remote)
|
2022-12-16 17:18:51 +00:00
|
|
|
}
|
2022-06-25 23:12:02 +01:00
|
|
|
|
2022-10-27 21:20:03 +01:00
|
|
|
[void] FadeTo ([single]$target, [int]$time) {
|
2022-12-16 17:18:51 +00:00
|
|
|
$this.Setter('FadeTo', "($target, $time)")
|
2022-06-25 23:12:02 +01:00
|
|
|
}
|
|
|
|
|
2022-10-27 21:20:03 +01:00
|
|
|
[void] FadeBy ([single]$target, [int]$time) {
|
2022-12-16 17:18:51 +00:00
|
|
|
$this.Setter('FadeBy', "($target, $time)")
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2023-08-09 14:16:27 +01:00
|
|
|
class Levels : IBus {
|
|
|
|
[int]$init
|
|
|
|
[int]$offset
|
|
|
|
|
|
|
|
Levels ([int]$index, [Object]$remote) : base ($index, $remote) {
|
|
|
|
$this.init = $index * 8
|
|
|
|
$this.offset = 8
|
|
|
|
}
|
|
|
|
|
|
|
|
[float] Convert([float]$val) {
|
|
|
|
if ($val -gt 0) {
|
|
|
|
return [math]::Round(20 * [math]::Log10($val), 1)
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
return -200.0
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
[System.Collections.ArrayList] Getter([int]$mode) {
|
|
|
|
[System.Collections.ArrayList]$vals = @()
|
|
|
|
$this.init..$($this.init + $this.offset - 1) | ForEach-Object {
|
|
|
|
$vals.Add($this.Convert($(Get_Level -MODE $mode -INDEX $_)))
|
|
|
|
}
|
|
|
|
return $vals
|
|
|
|
}
|
|
|
|
|
|
|
|
[System.Collections.ArrayList] All() {
|
|
|
|
return $this.Getter(3)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-12-17 15:40:07 +00:00
|
|
|
class Mode : IBus {
|
|
|
|
[System.Collections.ArrayList]$modes
|
|
|
|
|
|
|
|
Mode ([int]$index, [Object]$remote) : base ($index, $remote) {
|
|
|
|
$this.modes = @(
|
|
|
|
'normal', 'amix', 'bmix', 'repeat', 'composite', 'tvmix', 'upmix21', 'upmix41', 'upmix61',
|
|
|
|
'centeronly', 'lfeonly', 'rearonly'
|
|
|
|
)
|
|
|
|
|
|
|
|
AddBoolMembers -PARAMS $this.modes
|
|
|
|
}
|
|
|
|
|
|
|
|
[string] identifier () {
|
|
|
|
return "Bus[" + $this.index + "].mode"
|
|
|
|
}
|
|
|
|
|
|
|
|
[string] Get () {
|
|
|
|
foreach ($mode in $this.modes) {
|
|
|
|
if ($this.$mode) {
|
|
|
|
break
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return $mode
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-12-16 17:18:51 +00:00
|
|
|
class Eq : IBus {
|
|
|
|
Eq ([int]$index, [Object]$remote) : base ($index, $remote) {
|
|
|
|
AddBoolMembers -PARAMS @('on', 'ab')
|
|
|
|
}
|
|
|
|
|
|
|
|
[string] identifier () {
|
|
|
|
return "Bus[" + $this.index + "].EQ"
|
2022-06-25 23:12:02 +01:00
|
|
|
}
|
2021-04-28 17:38:36 +01:00
|
|
|
}
|
|
|
|
|
2022-01-10 20:56:17 +00:00
|
|
|
class PhysicalBus : Bus {
|
2022-12-16 17:18:51 +00:00
|
|
|
[Object]$device
|
|
|
|
|
2022-10-27 21:20:03 +01:00
|
|
|
PhysicalBus ([int]$index, [Object]$remote) : base ($index, $remote) {
|
2022-12-16 17:18:51 +00:00
|
|
|
$this.device = [Device]::new($index, $remote)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
class Device : IBus {
|
|
|
|
Device ([int]$index, [Object]$remote) : base ($index, $remote) {
|
2022-01-10 20:56:17 +00:00
|
|
|
}
|
2022-12-16 17:18:51 +00:00
|
|
|
|
|
|
|
[string] identifier () {
|
|
|
|
return "Bus[" + $this.index + "].Device"
|
|
|
|
}
|
|
|
|
|
|
|
|
hidden $_name = $($this | Add-Member ScriptProperty 'name' `
|
2022-01-24 20:01:55 +00:00
|
|
|
{
|
2022-12-16 17:18:51 +00:00
|
|
|
$this.Getter_String('name')
|
2022-10-27 21:20:03 +01:00
|
|
|
} `
|
2022-01-24 20:01:55 +00:00
|
|
|
{
|
2022-12-16 17:18:51 +00:00
|
|
|
return Write-Warning ("ERROR: $($this.identifier()).name is read only")
|
2022-01-24 20:01:55 +00:00
|
|
|
}
|
|
|
|
)
|
|
|
|
|
|
|
|
hidden $_sr = $($this | Add-Member ScriptProperty 'sr' `
|
|
|
|
{
|
2022-12-16 17:18:51 +00:00
|
|
|
$this.Getter('sr')
|
2022-10-27 21:20:03 +01:00
|
|
|
} `
|
2022-01-24 20:01:55 +00:00
|
|
|
{
|
2022-12-16 17:18:51 +00:00
|
|
|
return Write-Warning ("ERROR: $($this.identifier()).sr is read only")
|
2022-01-24 20:01:55 +00:00
|
|
|
}
|
|
|
|
)
|
2022-12-17 15:40:07 +00:00
|
|
|
|
|
|
|
hidden $_wdm = $($this | Add-Member ScriptProperty 'wdm' `
|
|
|
|
{
|
|
|
|
return Write-Warning ("ERROR: $($this.identifier()).wdm is write only")
|
|
|
|
} `
|
|
|
|
{
|
|
|
|
param($arg)
|
|
|
|
return $this.Setter('wdm', $arg)
|
|
|
|
}
|
|
|
|
)
|
|
|
|
|
|
|
|
hidden $_ks = $($this | Add-Member ScriptProperty 'ks' `
|
|
|
|
{
|
|
|
|
return Write-Warning ("ERROR: $($this.identifier()).ks is write only")
|
|
|
|
} `
|
|
|
|
{
|
|
|
|
param($arg)
|
|
|
|
return $this.Setter('ks', $arg)
|
|
|
|
}
|
|
|
|
)
|
|
|
|
|
|
|
|
hidden $_mme = $($this | Add-Member ScriptProperty 'mme' `
|
|
|
|
{
|
|
|
|
return Write-Warning ("ERROR: $($this.identifier()).mme is write only")
|
|
|
|
} `
|
|
|
|
{
|
|
|
|
param($arg)
|
|
|
|
return $this.Setter('mme', $arg)
|
|
|
|
}
|
|
|
|
)
|
|
|
|
|
|
|
|
hidden $_asio = $($this | Add-Member ScriptProperty 'asio' `
|
|
|
|
{
|
|
|
|
return Write-Warning ("ERROR: $($this.identifier()).asio is write only")
|
|
|
|
} `
|
|
|
|
{
|
|
|
|
param($arg)
|
|
|
|
return $this.Setter('asio', $arg)
|
|
|
|
}
|
|
|
|
)
|
2022-01-10 20:56:17 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
class VirtualBus : Bus {
|
2022-10-27 21:20:03 +01:00
|
|
|
VirtualBus ([int]$index, [Object]$remote) : base ($index, $remote) {
|
2022-01-10 20:56:17 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-10-27 21:20:03 +01:00
|
|
|
function Make_Buses ([Object]$remote) {
|
2021-04-28 17:38:36 +01:00
|
|
|
[System.Collections.ArrayList]$bus = @()
|
2022-06-25 23:12:02 +01:00
|
|
|
0..$($remote.kind.p_out + $remote.kind.v_out - 1) | ForEach-Object {
|
|
|
|
if ($_ -lt $remote.kind.p_out) { [void]$bus.Add([PhysicalBus]::new($_, $remote)) }
|
|
|
|
else { [void]$bus.Add([VirtualBus]::new($_, $remote)) }
|
2021-04-28 17:38:36 +01:00
|
|
|
}
|
|
|
|
$bus
|
|
|
|
}
|