xy and fx parameters added to strip/bus classes.

GetType, GetVersion, SendText added to Remote class.

Console output now written to Debug stream.

ToString() method overriden for higher classes.

formatter run through all files.
This commit is contained in:
onyx-and-iris
2022-10-27 21:20:03 +01:00
parent 7c60f564b2
commit 62c65e1c08
14 changed files with 331 additions and 258 deletions

View File

@@ -1,34 +1,38 @@
class Vban {
[int32]$id
[String]$direction
[int32]$index
[string]$direction
# Constructor
Vban([Int]$id) {
$this.id = $id
Vban ([int]$index) {
$this.index = $index
}
[Single] Getter($cmd) {
[string] ToString() {
return $this.GetType().Name + $this.index
}
[single] Getter ($cmd) {
return Param_Get -PARAM $cmd -IS_STRING $false
}
[String] Getter_String($cmd) {
[string] Getter_String ($cmd) {
return Param_Get -PARAM $cmd -IS_STRING $true
}
[void] Setter($cmd, $set) {
Param_Set -PARAM $cmd -VALUE $set
[void] Setter ($cmd, $set) {
Param_Set -PARAM $cmd -Value $set
}
[String] cmd ($arg) {
return "vban." + $this.direction + "stream[" + $this.id + "].$arg"
[string] cmd ($arg) {
return "vban." + $this.direction + "stream[" + $this.index + "].$arg"
}
hidden $_on = $($this | Add-Member ScriptProperty 'on' `
{
$this.Getter($this.cmd('on'))
}`
} `
{
param ( [Bool]$arg )
param([bool]$arg)
$this._on = $this.Setter($this.cmd('on'), $arg)
}
)
@@ -36,9 +40,9 @@ class Vban {
hidden $_name = $($this | Add-Member ScriptProperty 'name' `
{
$this.Getter_String($this.cmd('name'))
}`
} `
{
param ( [String]$arg )
param([string]$arg)
$this._name = $this.Setter($this.cmd('name'), $arg)
}
)
@@ -46,9 +50,9 @@ class Vban {
hidden $_ip = $($this | Add-Member ScriptProperty 'ip' `
{
$this.Getter_String($this.cmd('ip'))
}`
} `
{
param ( [String]$arg )
param([string]$arg)
$this._ip = $this.Setter($this.cmd('ip'), $arg)
}
)
@@ -56,14 +60,14 @@ class Vban {
hidden $_port = $($this | Add-Member ScriptProperty 'port' `
{
$this.Getter($this.cmd('port'))
}`
} `
{
param ( [String]$arg )
if ($arg -In 1024..65535) {
param([string]$arg)
if ($arg -in 1024..65535) {
$this._port = $this.Setter($this.cmd('port'), $arg)
}
else {
Write-Warning('Expected value from 1024 to 65535')
Write-Warning ('Expected value from 1024 to 65535')
}
}
)
@@ -71,17 +75,17 @@ class Vban {
hidden $_sr = $($this | Add-Member ScriptProperty 'sr' `
{
$this.Getter($this.cmd('sr'))
}`
} `
{
param ( [Int]$arg )
if ($this.direction -eq "in") { Write-Warning('Error, read only value') }
param([int]$arg)
if ($this.direction -eq "in") { Write-Warning ('Error, read only value') }
else {
$opts = @(11025, 16000, 22050, 24000, 32000, 44100, 48000, 64000, 88200, 96000)
if ($opts.Contains($arg)) {
$this._port = $this.Setter($this.cmd('sr'), $arg)
}
else {
Write-Warning('Expected one of', $opts)
Write-Warning ('Expected one of', $opts)
}
}
}
@@ -90,16 +94,16 @@ class Vban {
hidden $_channel = $($this | Add-Member ScriptProperty 'channel' `
{
$this.Getter($this.cmd('channel'))
}`
} `
{
param ( [Int]$arg )
if ($this.direction -eq "in") { Write-Warning('Error, read only value') }
param([int]$arg)
if ($this.direction -eq "in") { Write-Warning ('Error, read only value') }
else {
if ($arg -In 1..8) {
if ($arg -in 1..8) {
$this._channel = $this.Setter($this.cmd('channel'), $arg)
}
else {
Write-Warning('Expected value from 1 to 8')
Write-Warning ('Expected value from 1 to 8')
}
}
}
@@ -109,17 +113,17 @@ class Vban {
{
$val = if ($this.Getter($this.cmd('bit')) -eq 1) { 16 } else { 24 }
return $val
}`
} `
{
param ( [Int]$arg )
if ($this.direction -eq "in") { Write-Warning('Error, read only value') }
param([int]$arg)
if ($this.direction -eq "in") { Write-Warning ('Error, read only value') }
else {
if (@(16, 24).Contains($arg)) {
$val = if ($arg -eq 16) { 1 } else { 2 }
$this._bit = $this.Setter($this.cmd('bit'), $val)
}
else {
Write-Warning('Expected value 16 or 24')
Write-Warning ('Expected value 16 or 24')
}
}
}
@@ -128,16 +132,16 @@ class Vban {
hidden $_quality = $($this | Add-Member ScriptProperty 'quality' `
{
$this.Getter($this.cmd('quality'))
}`
} `
{
param ( [Int]$arg )
if ($this.direction -eq "in") { Write-Warning('Error, read only value') }
param([int]$arg)
if ($this.direction -eq "in") { Write-Warning ('Error, read only value') }
else {
if ($arg -In 0..4) {
if ($arg -in 0..4) {
$this._quality = $this.Setter($this.cmd('quality'), $arg)
}
else {
Write-Warning('Expected value from 0 to 4')
Write-Warning ('Expected value from 0 to 4')
}
}
}
@@ -146,16 +150,16 @@ class Vban {
hidden $_route = $($this | Add-Member ScriptProperty 'route' `
{
$this.Getter($this.cmd('route'))
}`
} `
{
param ( [Int]$arg )
if ($this.direction -eq "in") { Write-Warning('Error, read only value') }
param([int]$arg)
if ($this.direction -eq "in") { Write-Warning ('Error, read only value') }
else {
if ($arg -In 0..8) {
if ($arg -in 0..8) {
$this._route = $this.Setter($this.cmd('route'), $arg)
}
else {
Write-Warning('Expected value from 0 to 8')
Write-Warning ('Expected value from 0 to 8')
}
}
}
@@ -165,7 +169,7 @@ class Vban {
class VbanInstream : Vban {
# Constructor
VbanInstream ([Int]$id) : base ($id) {
VbanInstream ([int]$index) : base ($index) {
$this.direction = "in"
}
}
@@ -173,13 +177,13 @@ class VbanInstream : Vban {
class VbanOutstream : Vban {
# Constructor
VbanOutstream ([Int]$id) : base ($id) {
VbanOutstream ([int]$index) : base ($index) {
$this.direction = "out"
}
}
Function Make_Vban([Object]$remote) {
function Make_Vban ([Object]$remote) {
[System.Collections.ArrayList]$instream = @()
[System.Collections.ArrayList]$outstream = @()
@@ -190,17 +194,17 @@ Function Make_Vban([Object]$remote) {
[void]$outstream.Add([VbanOutstream]::new($_))
}
$CustomObject = [PSCustomObject]@{
$CustomObject = [pscustomobject]@{
instream = $instream
outstream = $outstream
}
}
$CustomObject | Add-Member ScriptProperty 'enable' `
{
return Write-Warning("ERROR: vban.enable is write only")
}`
return Write-Warning ("ERROR: vban.enable is write only")
} `
{
param( [bool]$arg )
param([bool]$arg)
Param_Set -PARAM 'vban.Enable' -Value $(if ($arg) { 1 } else { 0 })
}