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

@ -18,7 +18,9 @@ class Remote {
}
[void] Setup() {
if (Setup_DLL) {
if (!(Setup_DLL)) {
Exit
}
Login -KIND $this.kind.name
$this.profiles = Get_Profiles($this.kind.name)
$this.strip = Make_Strips($this)
@ -28,13 +30,23 @@ class Remote {
$this.command = Make_Command
$this.recorder = Make_Recorder($this)
}
else { Exit }
[string] ToString() {
return "Voicemeeter " + $this.kind.name.substring(0,1).toupper() + $this.kind.name.substring(1)
}
[void] Logout() {
Logout
}
[void] GetType() {
VmType
}
[String] GetVersion() {
return Version
}
[void] Set_Profile([String]$config) {
Set_Profile -DATA $this.profiles -CONF $config
}
@ -55,6 +67,10 @@ class Remote {
Param_Set_Multi -HASH $hash
}
[void] SendText([String]$script) {
Set_By_Script -SCRIPT $script
}
[void] PDirty() { P_Dirty }
[void] MDirty() { M_Dirty }

View File

@ -9,73 +9,88 @@
. $PSScriptRoot\command.ps1
. $PSScriptRoot\recorder.ps1
Function Login {
function Login {
param(
[String]$KIND = $null
[string]$KIND = $null
)
try {
$retval = [Int][Voicemeeter.Remote]::VBVMR_Login()
if (-not $retval) { Write-Host("LOGGED IN") }
$retval = [int][Voicemeeter.Remote]::VBVMR_Login()
if (-not $retval) { "LOGGED IN" | Write-Verbose }
elseif ($retval -eq 1) {
Write-Host("VM NOT RUNNING")
"VM NOT RUNNING" | Write-Verbose
New-Variable -Name vm_exe -Value 0
Switch ($KIND) {
'basic' { $vm_exe = 1; Break }
'banana' { $vm_exe = 2; Break }
switch ($KIND) {
'basic' { $vm_exe = 1; break }
'banana' { $vm_exe = 2; break }
'potato' {
if ([Environment]::Is64BitOperatingSystem) {
$vm_exe = 6
}
else { $vm_exe = 3 }
Break
break
}
Default { throw [LoginError]::new('Unknown Voicemeeter type') }
default { throw [LoginError]::new('Unknown Voicemeeter type') }
}
$retval = [Int][Voicemeeter.Remote]::VBVMR_RunVoicemeeter([Int64]$vm_exe)
if (-not $retval) { Write-Host("STARTING VOICEMEETER") }
else { Throw [CAPIError]::new($retval, $MyInvocation.MyCommand) }
$retval = [int][Voicemeeter.Remote]::VBVMR_RunVoicemeeter([int64]$vm_exe)
if (-not $retval) { "STARTING VOICEMEETER" | Write-Verbose }
else { throw [CAPIError]::new($retval, $MyInvocation.MyCommand) }
Start-Sleep -s 1
}
elseif ($retval -eq -2) {
throw [LoginError]::new('Login may only be called once per session')
}
else { Exit }
else { exit }
}
catch [LoginError], [CAPIError] {
Write-Warning $_.Exception.ErrorMessage()
}
while (P_Dirty -or M_Dirty) { Start-Sleep -m 1 }
New-Variable -Name ptr -Value 0
$retval = [Int][Voicemeeter.Remote]::VBVMR_GetVoicemeeterType([ref]$ptr)
if (-not $retval) {
if ($ptr -eq 1) { Write-Host("VERSION:[BASIC]") }
elseif ($ptr -eq 2) { Write-Host("VERSION:[BANANA]") }
elseif ($ptr -eq 3) { Write-Host("VERSION:[POTATO]") }
}
"VERSION:[" + $(VmType).ToUpper() + "]" | Write-Verbose
}
Function Logout {
function Logout {
Start-Sleep -m 20
$retval = [Int][Voicemeeter.Remote]::VBVMR_Logout()
if (-not $retval) { Write-Host("LOGGED OUT") }
$retval = [int][Voicemeeter.Remote]::VBVMR_Logout()
if (-not $retval) { "LOGGED OUT" | Write-Verbose }
}
Function P_Dirty {
[Bool][Voicemeeter.Remote]::VBVMR_IsParametersDirty()
function P_Dirty {
[bool][Voicemeeter.Remote]::VBVMR_IsParametersDirty()
}
Function M_Dirty {
[Bool][Voicemeeter.Remote]::VBVMR_MacroButton_IsDirty()
function M_Dirty {
[bool][Voicemeeter.Remote]::VBVMR_MacroButton_IsDirty()
}
function VmType {
New-Variable -Name ptr -Value 0
$retval = [int][Voicemeeter.Remote]::VBVMR_GetVoicemeeterType([ref]$ptr)
if ($retval) { throw [CAPIError]::new($retval, $MyInvocation.MyCommand) }
switch ($ptr) {
1 { return "basic" }
2 { return "banana" }
3 { return "potato" }
}
}
function Version {
New-Variable -Name ptr -Value 0
$retval = [int][Voicemeeter.Remote]::VBVMR_GetVoicemeeterVersion([ref]$ptr)
if ($retval) { throw [CAPIError]::new($retval, $MyInvocation.MyCommand) }
$v1 = ($ptr -band 0xFF000000) -shr 24
$v2 = ($ptr -band 0x00FF0000) -shr 16
$v3 = ($ptr -band 0x0000FF00) -shr 8
$v4 = $ptr -band 0x000000FF
"$v1.$v2.$v3.$v4"
}
Function Param_Get {
function Param_Get {
param(
[String]$PARAM, [bool]$IS_STRING = $false
[string]$PARAM, [bool]$IS_STRING = $false
)
Start-Sleep -m 50
while (P_Dirty) { Start-Sleep -m 1 }
@ -83,8 +98,8 @@ Function Param_Get {
if ($IS_STRING) {
$BYTES = [System.Byte[]]::new(512)
try {
$retval = [Int][Voicemeeter.Remote]::VBVMR_GetParameterStringA($PARAM, $BYTES)
if ($retval) { Throw [CAPIError]::new($retval, $MyInvocation.MyCommand) }
$retval = [int][Voicemeeter.Remote]::VBVMR_GetParameterStringA($PARAM, $BYTES)
if ($retval) { throw [CAPIError]::new($retval, $MyInvocation.MyCommand) }
}
catch [CAPIError] {
Write-Warning $_.Exception.ErrorMessage()
@ -94,79 +109,79 @@ Function Param_Get {
else {
New-Variable -Name ptr -Value 0.0
try {
$retval = [Int][Voicemeeter.Remote]::VBVMR_GetParameterFloat($PARAM, [ref]$ptr)
if ($retval) { Throw [CAPIError]::new($retval, $MyInvocation.MyCommand) }
$retval = [int][Voicemeeter.Remote]::VBVMR_GetParameterFloat($PARAM, [ref]$ptr)
if ($retval) { throw [CAPIError]::new($retval, $MyInvocation.MyCommand) }
}
catch [CAPIError] {
Write-Warning $_.Exception.ErrorMessage()
}
[Single]$ptr
[single]$ptr
}
}
Function Param_Set {
function Param_Set {
param(
[String]$PARAM, [Object]$VALUE
[string]$PARAM, [Object]$VALUE
)
try {
if ($VALUE -is [String]) {
$retval = [Int][Voicemeeter.Remote]::VBVMR_SetParameterStringA($PARAM, $VALUE)
if ($VALUE -is [string]) {
$retval = [int][Voicemeeter.Remote]::VBVMR_SetParameterStringA($PARAM, $VALUE)
}
else {
$retval = [Int][Voicemeeter.Remote]::VBVMR_SetParameterFloat($PARAM, $VALUE)
$retval = [int][Voicemeeter.Remote]::VBVMR_SetParameterFloat($PARAM, $VALUE)
}
if ($retval) { Throw [CAPIError]::new($retval, $MyInvocation.MyCommand) }
if ($retval) { throw [CAPIError]::new($retval, $MyInvocation.MyCommand) }
}
catch [CAPIError] {
Write-Warning $_.Exception.ErrorMessage()
}
}
Function MB_Set {
function MB_Set {
param(
[Int64]$ID, [Single]$SET, [Int64]$MODE
[int64]$ID, [single]$SET, [int64]$MODE
)
try {
$retval = [Int][Voicemeeter.Remote]::VBVMR_MacroButton_SetStatus($ID, $SET, $MODE)
if ($retval) { Throw [CAPIError]::new($retval, $MyInvocation.MyCommand) }
$retval = [int][Voicemeeter.Remote]::VBVMR_MacroButton_SetStatus($ID, $SET, $MODE)
if ($retval) { throw [CAPIError]::new($retval, $MyInvocation.MyCommand) }
}
catch [CAPIError] {
Write-Warning $_.Exception.ErrorMessage()
}
}
Function MB_Get {
function MB_Get {
param(
[Int64]$ID, [Int64]$MODE
[int64]$ID, [int64]$MODE
)
Start-Sleep -m 50
while (M_Dirty) { Start-Sleep -m 1 }
New-Variable -Name ptr -Value 0.0
try {
$retval = [Int][Voicemeeter.Remote]::VBVMR_MacroButton_GetStatus($ID, [ref]$ptr, $MODE)
if ($retval) { Throw [CAPIError]::new($retval, $MyInvocation.MyCommand) }
$retval = [int][Voicemeeter.Remote]::VBVMR_MacroButton_GetStatus($ID, [ref]$ptr, $MODE)
if ($retval) { throw [CAPIError]::new($retval, $MyInvocation.MyCommand) }
}
catch [CAPIError] {
Write-Warning $_.Exception.ErrorMessage()
}
[Int]$ptr
[int]$ptr
}
Function Param_Set_Multi {
function Param_Set_Multi {
param(
[HashTable]$HASH
[hashtable]$HASH
)
ForEach ($key in $HASH.keys) {
foreach ($key in $HASH.keys) {
$classobj, $m2, $m3 = $key.Split("_")
if ($m2 -match "^\d+$") { $index = [int]$m2 } else { $index = [int]$m3 }
ForEach ($h in $HASH[$key].GetEnumerator()) {
foreach ($h in $HASH[$key].GetEnumerator()) {
$property = $h.Name
$value = $h.Value
if ($value -in ('False', 'True')) { [System.Convert]::ToBoolean($value) }
Switch ($classobj) {
switch ($classobj) {
'strip' { $this.strip[$index].$property = $value }
'bus' { $this.bus[$index].$property = $value }
{ ($_ -eq 'button') -or ($_ -eq 'mb') } { $this.button[$index].$property = $value }
@ -175,3 +190,16 @@ Function Param_Set_Multi {
}
}
}
function Set_By_Script {
param(
[string]$script
)
try {
$retval = [int][Voicemeeter.Remote]::VBVMR_SetParameters($script)
if ($retval) { throw [CAPIError]::new($retval, $MyInvocation.MyCommand) }
}
catch [CAPIError] {
Write-Warning $_.Exception.ErrorMessage()
}
}

View File

@ -1,4 +1,4 @@
Function Setup_DLL {
function Setup_DLL {
try {
$vb_path = Get_VBPath
@ -7,7 +7,7 @@ Function Setup_DLL {
}
else {
$dll = Join-Path -Path $vb_path -ChildPath ("VoicemeeterRemote" + `
(& { If ([Environment]::Is64BitOperatingSystem) { "64" } Else { "" } }) + `
(& { if ([Environment]::Is64BitOperatingSystem) { "64" } else { "" } }) + `
".dll")
}
}
@ -25,6 +25,8 @@ Function Setup_DLL {
public static extern int VBVMR_RunVoicemeeter(Int64 run);
[DllImport(@"$dll")]
public static extern int VBVMR_GetVoicemeeterType(ref int ptr);
[DllImport(@"$dll")]
public static extern int VBVMR_GetVoicemeeterVersion(ref int ptr);
[DllImport(@"$dll")]
public static extern int VBVMR_MacroButton_IsDirty();

View File

@ -1,36 +1,40 @@
. $PSScriptRoot\meta.ps1
class Bus {
[Int]$id
[int]$index
[Object]$remote
# Constructor
Bus ([Int]$id, [Object]$remote) {
$this.id = $id
Bus ([int]$index, [Object]$remote) {
$this.index = $index
$this.remote = $remote
AddBoolMembers -PARAMS @('mono', 'mute')
AddStringMembers -PARAMS @('label')
AddFloatMembers -PARAMS @('gain')
AddFloatMembers -PARAMS @('gain', 'returnreverb', 'returndelay', 'returnfx1', 'returnfx2')
AddBusModeMembers -PARAMS @('normal', 'amix', 'bmix', 'repeat', 'composite', 'tvmix', 'upmix21',
'upmix41', 'upmix61', 'centeronly', 'lfeonly', 'rearonly')
AddBusModeMembers -PARAMS @('normal', 'amix', 'bmix', 'repeat', 'composite', 'tvmix', 'upmix21')
AddBusModeMembers -PARAMS @('upmix41', 'upmix61', 'centeronly', 'lfeonly', 'rearonly')
}
[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
Param_Set -PARAM $cmd -Value $set
}
[string] cmd ($arg) {
return "Bus[" + $this.id + "].$arg"
return "Bus[" + $this.index + "].$arg"
}
hidden $_eq = $($this | Add-Member ScriptProperty 'eq' `
@ -53,17 +57,17 @@ class Bus {
}
)
[void] FadeTo([Single]$target, [int]$time) {
[void] FadeTo ([single]$target, [int]$time) {
$this.Setter($this.cmd('FadeTo'), "($target, $time)")
}
[void] FadeBy([Single]$target, [int]$time) {
[void] FadeBy ([single]$target, [int]$time) {
$this.Setter($this.cmd('FadeBy'), "($target, $time)")
}
}
class PhysicalBus : Bus {
PhysicalBus ([Int]$id, [Object]$remote) : base ($id, $remote) {
PhysicalBus ([int]$index, [Object]$remote) : base ($index, $remote) {
}
hidden $_device = $($this | Add-Member ScriptProperty 'device' `
{
@ -85,11 +89,11 @@ class PhysicalBus : Bus {
}
class VirtualBus : Bus {
VirtualBus ([Int]$id, [Object]$remote) : base ($id, $remote) {
VirtualBus ([int]$index, [Object]$remote) : base ($index, $remote) {
}
}
Function Make_Buses([Object]$remote) {
function Make_Buses ([Object]$remote) {
[System.Collections.ArrayList]$bus = @()
0..$($remote.kind.p_out + $remote.kind.v_out - 1) | ForEach-Object {
if ($_ -lt $remote.kind.p_out) { [void]$bus.Add([PhysicalBus]::new($_, $remote)) }

View File

@ -6,20 +6,24 @@ class Special {
AddActionMembers -PARAMS @('restart', 'shutdown', 'show')
}
[Single] Getter($cmd) {
[string] ToString() {
return $this.GetType().Name
}
[single] Getter ($cmd) {
return Param_Get -PARAM $cmd -IS_STRING $false
}
[void] Setter ($param, $val) {
if ($val -is [Boolean]) {
Param_Set -PARAM $param -VALUE $(if ($val) { 1 } else { 0 })
Param_Set -PARAM $param -Value $(if ($val) { 1 } else { 0 })
}
else {
Param_Set -PARAM $param -VALUE $val
Param_Set -PARAM $param -Value $val
}
}
[String] cmd ($arg) {
[string] cmd ($arg) {
return "Command.$arg"
}
@ -51,6 +55,6 @@ class Special {
)
}
Function Make_Command {
function Make_Command {
return [Special]::new()
}

View File

@ -1,30 +1,30 @@
class VMRemoteErrors : Exception {
[String]$msg
[string]$msg
VMRemoteErrors([String]$msg) {
VMRemoteErrors ([string]$msg) {
$this.msg = $msg
}
[String] ErrorMessage() {
[string] ErrorMessage () {
return $this.msg
}
}
class LoginError : VMRemoteErrors {
LoginError([String]$msg) : Base([String]$msg) {
LoginError ([string]$msg) : base ([string]$msg) {
}
}
class CAPIError : VMRemoteErrors {
[Int]$retval
[String]$caller
[int]$retval
[string]$caller
CAPIError([Int]$retval, [String]$caller) {
CAPIError ([int]$retval, [string]$caller) {
$this.retval = $retval
$this.caller = $caller
}
[String] ErrorMessage() {
[string] ErrorMessage () {
return "ERROR: CAPI return value: {0} in {1}" -f $this.retval, $this.caller
}
}

View File

@ -1,6 +1,6 @@
Function Get_VBPath {
function Get_VBPath {
$reg_path = "Registry::HKEY_LOCAL_MACHINE\Software" + `
(& { If ([Environment]::Is64BitOperatingSystem) { "\WOW6432Node" } Else { "" } }) + `
(& { if ([Environment]::Is64BitOperatingSystem) { "\WOW6432Node" } else { "" } }) + `
"\Microsoft\Windows\CurrentVersion\Uninstall"
$vm_key = "\VB:Voicemeeter {17359A74-1236-5467}\"

View File

@ -28,6 +28,6 @@ $KindMap = @{
};
}
Function GetKind([string]$kind_id) {
function GetKind ([string]$kind_id) {
$KindMap[$kind_id]
}

View File

@ -1,17 +1,21 @@
class MacroButton {
[int32]$id
[int32]$index
# Constructor
MacroButton ([Int]$id) {
$this.id = $id
MacroButton ([int]$index) {
$this.index = $index
}
[string] ToString() {
return $this.GetType().Name + $this.index
}
[int] Getter ($mode) {
return MB_Get -ID $this.id -MODE $mode
return MB_Get -Id $this.index -Mode $mode
}
[void] Setter ($set, $mode) {
MB_Set -ID $this.id -SET $set -MODE $mode
MB_Set -Id $this.index -SET $set -Mode $mode
}
hidden $_state = $($this | Add-Member ScriptProperty 'state' `
@ -45,7 +49,7 @@ class MacroButton {
)
}
Function Make_Buttons {
function Make_Buttons {
[System.Collections.ArrayList]$button = @()
0..79 | ForEach-Object {
[void]$button.Add([MacroButton]::new($_))

View File

@ -1,9 +1,9 @@
Function AddBoolMembers() {
function AddBoolMembers () {
param(
[String[]]$PARAMS
)
[HashTable]$Signatures = @{}
ForEach ($param in $PARAMS) {
[hashtable]$Signatures = @{}
foreach ($param in $PARAMS) {
# Define getter
$Signatures["Getter"] = "[bool]`$this.Getter(`$this.cmd('{0}'))" -f $param
# Define setter
@ -14,12 +14,12 @@ Function AddBoolMembers() {
}
}
Function AddFloatMembers() {
function AddFloatMembers () {
param(
[String[]]$PARAMS
)
[HashTable]$Signatures = @{}
ForEach ($param in $PARAMS) {
[hashtable]$Signatures = @{}
foreach ($param in $PARAMS) {
# Define getter
$Signatures["Getter"] = "[math]::Round(`$this.Getter(`$this.cmd('{0}')), 1)" -f $param
# Define setter
@ -30,12 +30,12 @@ Function AddFloatMembers() {
}
}
Function AddIntMembers() {
function AddIntMembers () {
param(
[String[]]$PARAMS
)
[HashTable]$Signatures = @{}
ForEach ($param in $PARAMS) {
[hashtable]$Signatures = @{}
foreach ($param in $PARAMS) {
# Define getter
$Signatures["Getter"] = "[Int]`$this.Getter(`$this.cmd('{0}'))" -f $param
# Define setter
@ -46,12 +46,12 @@ Function AddIntMembers() {
}
}
Function AddStringMembers() {
function AddStringMembers () {
param(
[String[]]$PARAMS
)
[HashTable]$Signatures = @{}
ForEach ($param in $PARAMS) {
[hashtable]$Signatures = @{}
foreach ($param in $PARAMS) {
# Define getter
$Signatures["Getter"] = "[String]`$this.Getter_String(`$this.cmd('{0}'))" -f $param
# Define setter
@ -62,12 +62,12 @@ Function AddStringMembers() {
}
}
Function AddActionMembers() {
function AddActionMembers () {
param(
[String[]]$PARAMS
)
[HashTable]$Signatures = @{}
ForEach ($param in $PARAMS) {
[hashtable]$Signatures = @{}
foreach ($param in $PARAMS) {
# Define getter
$Signatures["Getter"] = "`$this.Setter(`$this.cmd('{0}'), `$true)" -f $param
# Define setter
@ -77,7 +77,7 @@ Function AddActionMembers() {
}
}
Function AddChannelMembers() {
function AddChannelMembers () {
$num_A = $this.remote.kind.p_out
$num_B = $this.remote.kind.v_out
@ -89,8 +89,8 @@ Function AddChannelMembers() {
AddBoolMembers -PARAMS $channels
}
Function AddGainlayerMembers() {
[HashTable]$Signatures = @{}
function AddGainlayerMembers () {
[hashtable]$Signatures = @{}
0..7 | ForEach-Object {
# Define getter
$Signatures["Getter"] = "`$this.Getter(`$this.cmd('gainlayer[{0}]'))" -f $_
@ -98,17 +98,18 @@ Function AddGainlayerMembers() {
$Signatures["Setter"] = "param ( [Single]`$arg )`n`$this.Setter(`$this.cmd('gainlayer[{0}]'), `$arg)" `
-f $_
$param = "gainlayer{0}" -f $_
$null = $param
Addmember
}
}
Function AddBusModeMembers() {
function AddBusModeMembers () {
param(
[String[]]$PARAMS
)
[HashTable]$Signatures = @{}
ForEach ($param in $PARAMS) {
[hashtable]$Signatures = @{}
foreach ($param in $PARAMS) {
# Define getter
$Signatures["Getter"] = "[bool]`$this.Getter(`$this.cmd('mode.{0}'))" -f $param
# Define setter
@ -120,12 +121,12 @@ Function AddBusModeMembers() {
}
}
Function Addmember {
function Addmember {
$AddMemberParams = @{
Name = $param
MemberType = 'ScriptProperty'
Value = [ScriptBlock]::Create($Signatures["Getter"])
SecondValue = [ScriptBlock]::Create($Signatures["Setter"])
Value = [scriptblock]::Create($Signatures["Getter"])
SecondValue = [scriptblock]::Create($Signatures["Setter"])
}
$this | Add-Member @AddMemberParams
}

View File

@ -1,4 +1,4 @@
Function Get_Profiles([String]$kind_id) {
function Get_Profiles ([string]$kind_id) {
$basepath = Join-Path -Path $(Split-Path -Path $PSScriptRoot) -ChildPath "profiles"
if (Test-Path $basepath) {
$fullpath = Join-Path -Path $basepath -ChildPath $kind_id
@ -6,7 +6,7 @@ Function Get_Profiles([String]$kind_id) {
else { return $null }
$filenames = @(Get-ChildItem -Path $fullpath -Filter *.psd1 -Recurse -File)
[HashTable]$data = @{}
[hashtable]$data = @{}
if ($filenames) {
$filenames | ForEach-Object {
(Join-Path -Path $fullpath -ChildPath $_) | ForEach-Object {
@ -20,9 +20,9 @@ Function Get_Profiles([String]$kind_id) {
return $null
}
Function Set_Profile {
function Set_Profile {
param(
[Object]$DATA, [String]$CONF
[Object]$DATA, [string]$CONF
)
try {
if ($null -eq $DATA -or -not $DATA.$CONF) {

View File

@ -10,20 +10,24 @@ class Recorder {
AddChannelMembers
}
[Single] Getter($cmd) {
[string] ToString() {
return $this.GetType().Name
}
[single] Getter ($cmd) {
return Param_Get -PARAM $cmd -IS_STRING $false
}
[void] Setter ($param, $val) {
if ($val -is [Boolean]) {
Param_Set -PARAM $param -VALUE $(if ($val) { 1 } else { 0 })
Param_Set -PARAM $param -Value $(if ($val) { 1 } else { 0 })
}
else {
Param_Set -PARAM $param -VALUE $val
Param_Set -PARAM $param -Value $val
}
}
[String] cmd ($arg) {
[string] cmd ($arg) {
return "Recorder.$arg"
}
@ -37,11 +41,11 @@ class Recorder {
}
)
[void] Load([String]$filename) {
[void] Load ([string]$filename) {
$this.Setter($this.cmd('load'), $filename)
}
}
Function Make_Recorder([Object]$remote) {
function Make_Recorder ([Object]$remote) {
return [Recorder]::new($remote)
}

View File

@ -1,50 +1,56 @@
. $PSScriptRoot\meta.ps1
class Strip {
[Int]$id
[int]$index
[Object]$remote
Strip ([Int]$id, [Object]$remote) {
$this.id = $id
Strip ([int]$index, [Object]$remote) {
$this.index = $index
$this.remote = $remote
AddBoolMembers -PARAMS @('mono', 'solo', 'mute')
AddIntMembers -PARAMS @('limit')
AddFloatMembers -PARAMS @('gain')
AddFloatMembers -PARAMS @('gain', 'pan_x', 'pan_y')
AddStringMembers -PARAMS @('label')
AddChannelMembers
AddGainlayerMembers
}
[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, $val) {
Param_Set -PARAM $cmd -VALUE $val
Param_Set -PARAM $cmd -Value $val
}
[String] cmd ($arg) {
return "Strip[" + $this.id + "].$arg"
[string] cmd ($arg) {
return "Strip[" + $this.index + "].$arg"
}
[void] FadeTo([Single]$target, [int]$time) {
[void] FadeTo ([single]$target, [int]$time) {
$this.Setter($this.cmd('FadeTo'), "($target, $time)")
}
[void] FadeBy([Single]$target, [int]$time) {
[void] FadeBy ([single]$target, [int]$time) {
$this.Setter($this.cmd('FadeBy'), "($target, $time)")
}
}
class PhysicalStrip : Strip {
PhysicalStrip ([Int]$id, [Object]$remote) : base ($id, $remote) {
AddFloatMembers -PARAMS @('comp', 'gate')
PhysicalStrip ([int]$index, [Object]$remote) : base ($index, $remote) {
AddFloatMembers -PARAMS @('comp', 'gate', 'color_x', 'color_y', 'fx_x', 'fx_y')
AddFloatMembers -PARAMS @('reverb', 'delay', 'fx1', 'fx2')
AddBoolMembers -PARAMS @('postreverb', 'postdelay', 'postfx1', 'postfx2')
}
hidden $_device = $($this | Add-Member ScriptProperty 'device' `
@ -67,14 +73,14 @@ class PhysicalStrip : Strip {
}
class VirtualStrip : Strip {
VirtualStrip ([Int]$id, [Object]$remote) : base ($id, $remote) {
VirtualStrip ([int]$index, [Object]$remote) : base ($index, $remote) {
AddBoolMembers -PARAMS @('mc')
AddIntMembers -PARAMS @('k')
}
}
Function Make_Strips([Object]$remote) {
function Make_Strips ([Object]$remote) {
[System.Collections.ArrayList]$strip = @()
0..$($remote.kind.p_in + $remote.kind.v_in - 1) | ForEach-Object {
if ($_ -lt $remote.kind.p_in) {

View File

@ -1,26 +1,30 @@
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
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' `
@ -28,7 +32,7 @@ class Vban {
$this.Getter($this.cmd('on'))
} `
{
param ( [Bool]$arg )
param([bool]$arg)
$this._on = $this.Setter($this.cmd('on'), $arg)
}
)
@ -38,7 +42,7 @@ class Vban {
$this.Getter_String($this.cmd('name'))
} `
{
param ( [String]$arg )
param([string]$arg)
$this._name = $this.Setter($this.cmd('name'), $arg)
}
)
@ -48,7 +52,7 @@ class Vban {
$this.Getter_String($this.cmd('ip'))
} `
{
param ( [String]$arg )
param([string]$arg)
$this._ip = $this.Setter($this.cmd('ip'), $arg)
}
)
@ -58,8 +62,8 @@ class Vban {
$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 {
@ -73,7 +77,7 @@ class Vban {
$this.Getter($this.cmd('sr'))
} `
{
param ( [Int]$arg )
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)
@ -92,10 +96,10 @@ class Vban {
$this.Getter($this.cmd('channel'))
} `
{
param ( [Int]$arg )
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 {
@ -111,7 +115,7 @@ class Vban {
return $val
} `
{
param ( [Int]$arg )
param([int]$arg)
if ($this.direction -eq "in") { Write-Warning ('Error, read only value') }
else {
if (@(16, 24).Contains($arg)) {
@ -130,10 +134,10 @@ class Vban {
$this.Getter($this.cmd('quality'))
} `
{
param ( [Int]$arg )
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 {
@ -148,10 +152,10 @@ class Vban {
$this.Getter($this.cmd('route'))
} `
{
param ( [Int]$arg )
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 {
@ -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,7 +194,7 @@ Function Make_Vban([Object]$remote) {
[void]$outstream.Add([VbanOutstream]::new($_))
}
$CustomObject = [PSCustomObject]@{
$CustomObject = [pscustomobject]@{
instream = $instream
outstream = $outstream
}