mirror of
https://github.com/onyx-and-iris/voicemeeter-api-powershell.git
synced 2025-12-21 20:27:47 +00:00
implement io classes
prelim pester tests for potato pass
This commit is contained in:
parent
0c60c5e6c5
commit
126e6172cb
@ -4,8 +4,7 @@
|
|||||||
. $PSScriptRoot\kinds.ps1
|
. $PSScriptRoot\kinds.ps1
|
||||||
. $PSScriptRoot\iremote.ps1
|
. $PSScriptRoot\iremote.ps1
|
||||||
. $PSScriptRoot\arraymember.ps1
|
. $PSScriptRoot\arraymember.ps1
|
||||||
. $PSScriptRoot\device.ps1
|
. $PSScriptRoot\io.ps1
|
||||||
. $PSScriptRoot\eq.ps1
|
|
||||||
. $PSScriptRoot\strip.ps1
|
. $PSScriptRoot\strip.ps1
|
||||||
. $PSScriptRoot\bus.ps1
|
. $PSScriptRoot\bus.ps1
|
||||||
. $PSScriptRoot\macrobuttons.ps1
|
. $PSScriptRoot\macrobuttons.ps1
|
||||||
|
|||||||
38
lib/bus.ps1
38
lib/bus.ps1
@ -1,13 +1,12 @@
|
|||||||
class Bus : IRemote {
|
class Bus : IOControl {
|
||||||
[Object]$mode
|
[Object]$mode
|
||||||
[Object]$eq
|
[Object]$eq
|
||||||
[Object]$levels
|
[Object]$levels
|
||||||
|
|
||||||
Bus ([int]$index, [Object]$remote) : base ($index, $remote) {
|
Bus ([int]$index, [Object]$remote) : base ($index, $remote) {
|
||||||
AddBoolMembers -PARAMS @('mute', 'sel', 'monitor')
|
AddBoolMembers -PARAMS @('sel', 'monitor')
|
||||||
AddIntMembers -PARAMS @('mono')
|
AddIntMembers -PARAMS @('mono')
|
||||||
AddStringMembers -PARAMS @('label')
|
AddFloatMembers -PARAMS @('returnreverb', 'returndelay', 'returnfx1', 'returnfx2')
|
||||||
AddFloatMembers -PARAMS @('gain', 'returnreverb', 'returndelay', 'returnfx1', 'returnfx2')
|
|
||||||
|
|
||||||
$this.mode = [BusMode]::new($index, $remote)
|
$this.mode = [BusMode]::new($index, $remote)
|
||||||
$this.eq = [BusEq]::new($index, $remote)
|
$this.eq = [BusEq]::new($index, $remote)
|
||||||
@ -17,17 +16,9 @@ class Bus : IRemote {
|
|||||||
[string] identifier () {
|
[string] identifier () {
|
||||||
return 'Bus[' + $this.index + ']'
|
return 'Bus[' + $this.index + ']'
|
||||||
}
|
}
|
||||||
|
|
||||||
[void] FadeTo ([single]$target, [int]$time) {
|
|
||||||
$this.Setter('FadeTo', "($target, $time)")
|
|
||||||
}
|
}
|
||||||
|
|
||||||
[void] FadeBy ([single]$target, [int]$time) {
|
class BusLevels : IOLevels {
|
||||||
$this.Setter('FadeBy', "($target, $time)")
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
class BusLevels : IRemote {
|
|
||||||
[int]$init
|
[int]$init
|
||||||
[int]$offset
|
[int]$offset
|
||||||
|
|
||||||
@ -36,23 +27,6 @@ class BusLevels : IRemote {
|
|||||||
$this.offset = 8
|
$this.offset = 8
|
||||||
}
|
}
|
||||||
|
|
||||||
hidden [single] Convert([single]$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() {
|
[System.Collections.ArrayList] All() {
|
||||||
return $this.Getter(3)
|
return $this.Getter(3)
|
||||||
}
|
}
|
||||||
@ -93,7 +67,7 @@ class BusMode : IRemote {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
class BusEq : Eq {
|
class BusEq : IOEq {
|
||||||
BusEq ([int]$index, [Object]$remote) : base ($index, $remote, 'Bus') {
|
BusEq ([int]$index, [Object]$remote) : base ($index, $remote, 'Bus') {
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -122,7 +96,7 @@ class VirtualBus : Bus {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
class BusDevice : Device {
|
class BusDevice : IODevice {
|
||||||
BusDevice ([int]$index, [Object]$remote) : base ($index, $remote) {
|
BusDevice ([int]$index, [Object]$remote) : base ($index, $remote) {
|
||||||
if ($this.index -eq 0) {
|
if ($this.index -eq 0) {
|
||||||
$this.AddASIO()
|
$this.AddASIO()
|
||||||
|
|||||||
@ -1,52 +0,0 @@
|
|||||||
class Device : IRemote {
|
|
||||||
Device ([int]$index, [Object]$remote) : base ($index, $remote) {
|
|
||||||
}
|
|
||||||
|
|
||||||
hidden $_name = $($this | Add-Member ScriptProperty 'name' `
|
|
||||||
{
|
|
||||||
$this.Getter_String('name')
|
|
||||||
} `
|
|
||||||
{
|
|
||||||
return Write-Warning ("ERROR: $($this.identifier()).name is read only")
|
|
||||||
}
|
|
||||||
)
|
|
||||||
|
|
||||||
hidden $_sr = $($this | Add-Member ScriptProperty 'sr' `
|
|
||||||
{
|
|
||||||
[int]$this.Getter('sr')
|
|
||||||
} `
|
|
||||||
{
|
|
||||||
return Write-Warning ("ERROR: $($this.identifier()).sr is read only")
|
|
||||||
}
|
|
||||||
)
|
|
||||||
|
|
||||||
hidden $_wdm = $($this | Add-Member ScriptProperty 'wdm' `
|
|
||||||
{
|
|
||||||
return Write-Warning ("ERROR: $($this.identifier()).wdm is write only")
|
|
||||||
} `
|
|
||||||
{
|
|
||||||
param([string]$arg)
|
|
||||||
return $this.Setter('wdm', $arg)
|
|
||||||
}
|
|
||||||
)
|
|
||||||
|
|
||||||
hidden $_ks = $($this | Add-Member ScriptProperty 'ks' `
|
|
||||||
{
|
|
||||||
return Write-Warning ("ERROR: $($this.identifier()).ks is write only")
|
|
||||||
} `
|
|
||||||
{
|
|
||||||
param([string]$arg)
|
|
||||||
return $this.Setter('ks', $arg)
|
|
||||||
}
|
|
||||||
)
|
|
||||||
|
|
||||||
hidden $_mme = $($this | Add-Member ScriptProperty 'mme' `
|
|
||||||
{
|
|
||||||
return Write-Warning ("ERROR: $($this.identifier()).mme is write only")
|
|
||||||
} `
|
|
||||||
{
|
|
||||||
param([string]$arg)
|
|
||||||
return $this.Setter('mme', $arg)
|
|
||||||
}
|
|
||||||
)
|
|
||||||
}
|
|
||||||
60
lib/eq.ps1
60
lib/eq.ps1
@ -1,60 +0,0 @@
|
|||||||
class Eq : IRemote {
|
|
||||||
[System.Collections.ArrayList]$channel
|
|
||||||
[string]$kindOfEq
|
|
||||||
|
|
||||||
Eq ([int]$index, [Object]$remote, [string]$kindOfEq) : base ($index, $remote) {
|
|
||||||
$this.kindOfEq = $kindOfEq
|
|
||||||
|
|
||||||
AddBoolMembers -PARAMS @('on', 'ab')
|
|
||||||
|
|
||||||
$this.channel = @()
|
|
||||||
for ($ch = 0; $ch -lt $remote.kind.eq_ch[$this.kindOfEq]; $ch++) {
|
|
||||||
$this.channel.Add([EqChannel]::new($ch, $remote, $this.identifier()))
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
[void] Load ([string]$filename) {
|
|
||||||
$param = 'Command.Load{0}Eq[{1}]' -f $this.kindOfEq, $this.index
|
|
||||||
$this.remote.Setter($param, $filename)
|
|
||||||
}
|
|
||||||
|
|
||||||
[void] Save ([string]$filename) {
|
|
||||||
$param = 'Command.Save{0}Eq[{1}]' -f $this.kindOfEq, $this.index
|
|
||||||
$this.remote.Setter($param, $filename)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
class EqChannel : IRemote {
|
|
||||||
[System.Collections.ArrayList]$cell
|
|
||||||
[string]$eqId
|
|
||||||
|
|
||||||
EqChannel ([int]$index, [Object]$remote, [string]$eqId) : base ($index, $remote) {
|
|
||||||
$this.eqId = $eqId
|
|
||||||
|
|
||||||
$this.cell = @()
|
|
||||||
$cellCount = $this.remote.kind.cells
|
|
||||||
for ($c = 0; $c -lt $cellCount; $c++) {
|
|
||||||
$this.cell.Add([EqCell]::new($c, $remote, $this.identifier()))
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
[string] identifier () {
|
|
||||||
return '{0}.Channel[{1}]' -f $this.eqId, $this.index
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
class EqCell : IRemote {
|
|
||||||
[string]$channelId
|
|
||||||
|
|
||||||
EqCell ([int]$index, [Object]$remote, [string]$channelId) : base ($index, $remote) {
|
|
||||||
$this.channelId = $channelId
|
|
||||||
|
|
||||||
AddBoolMembers -PARAMS @('on')
|
|
||||||
AddIntMembers -PARAMS @('type')
|
|
||||||
AddFloatMembers -PARAMS @('f', 'gain', 'q')
|
|
||||||
}
|
|
||||||
|
|
||||||
[string] identifier () {
|
|
||||||
return '{0}.Cell[{1}]' -f $this.channelId, $this.index
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@ -1,11 +1,10 @@
|
|||||||
class Strip : IRemote {
|
class Strip : IOControl {
|
||||||
[System.Collections.ArrayList]$gainlayer
|
[System.Collections.ArrayList]$gainlayer
|
||||||
[Object]$levels
|
[Object]$levels
|
||||||
|
|
||||||
Strip ([int]$index, [Object]$remote) : base ($index, $remote) {
|
Strip ([int]$index, [Object]$remote) : base ($index, $remote) {
|
||||||
AddBoolMembers -PARAMS @('solo', 'mute')
|
AddBoolMembers -PARAMS @('solo')
|
||||||
AddFloatMembers -PARAMS @('gain', 'limit', 'pan_x', 'pan_y')
|
AddFloatMembers -PARAMS @('limit', 'pan_x', 'pan_y')
|
||||||
AddStringMembers -PARAMS @('label')
|
|
||||||
|
|
||||||
AddChannelMembers
|
AddChannelMembers
|
||||||
|
|
||||||
@ -20,17 +19,9 @@ class Strip : IRemote {
|
|||||||
[string] identifier () {
|
[string] identifier () {
|
||||||
return 'Strip[' + $this.index + ']'
|
return 'Strip[' + $this.index + ']'
|
||||||
}
|
}
|
||||||
|
|
||||||
[void] FadeTo ([single]$target, [int]$time) {
|
|
||||||
$this.Setter('FadeTo', "($target, $time)")
|
|
||||||
}
|
}
|
||||||
|
|
||||||
[void] FadeBy ([single]$target, [int]$time) {
|
class StripLevels : IOLevels {
|
||||||
$this.Setter('FadeBy', "($target, $time)")
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
class StripLevels : IRemote {
|
|
||||||
[int]$init
|
[int]$init
|
||||||
[int]$offset
|
[int]$offset
|
||||||
|
|
||||||
@ -46,23 +37,6 @@ class StripLevels : IRemote {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
hidden [single] Convert([single]$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] PreFader() {
|
[System.Collections.ArrayList] PreFader() {
|
||||||
return $this.Getter(0)
|
return $this.Getter(0)
|
||||||
}
|
}
|
||||||
@ -196,7 +170,7 @@ class StripAudibility : IRemote {
|
|||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
class StripEq : Eq {
|
class StripEq : IOEq {
|
||||||
StripEq ([int]$index, [Object]$remote) : base ($index, $remote, 'Strip') {
|
StripEq ([int]$index, [Object]$remote) : base ($index, $remote, 'Strip') {
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -205,7 +179,7 @@ class StripEq : Eq {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
class StripDevice : Device {
|
class StripDevice : IODevice {
|
||||||
StripDevice ([int]$index, [Object]$remote) : base ($index, $remote) {
|
StripDevice ([int]$index, [Object]$remote) : base ($index, $remote) {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user