general updates, added fadeto/fadeby

fadeto, fadeby added to strip|bus

kind maps reworked.

bindings/profiles/kinds moved into their own files.

changelog/readme updated

version bump
This commit is contained in:
onyx-and-iris 2022-06-25 23:12:02 +01:00
parent 8429fed8b4
commit 095a9362cb
12 changed files with 274 additions and 239 deletions

View File

@ -9,9 +9,25 @@ Before any major/minor/patch is released all test units will be run to verify th
## [Unreleased] These changes have not been added to PSGallery yet
- [x] fix number of macrobuttons
- [ ] Add fadeto, fadeby methods for strips/buses
- [ ] Move kinds, profiles into their own modules.
- [x]
## [2.4.0] - 2022-06-25
### Added
- fadeto, fadeby methods for strips/buses
- README and CHANGELOG updated to reflect latest changes.
- Version 2.4 added to PSGAllery
### Changed
- Move kinds, profiles into their own modules.
- remove global variable layout. added GetKind() to kinds.
- link to official documentation in readme now points to SDK repo.
### Fixed
- number of macrobuttons
## [2.3.0] - 2022-03-08

View File

@ -125,6 +125,18 @@ for example:
$vmr.bus[3].mode_repeat = $true
```
### Strip|Bus
- `FadeTo(amount, time)` : float, int
- `FadeBy(amount, time)` : float, int
Modify gain to or by the selected amount in db over a time interval in ms.
for example:
```
$vmr.strip[3].FadeTo(-18.7, 1000)
$vmr.bus[0].FadeBy(-10, 500)
```
### Macrobuttons
Three modes defined: state, stateonly and trigger.
@ -301,4 +313,4 @@ Results will be logged and summary file written.
### Official Documentation
- [Voicemeeter Remote C API](https://forum.vb-audio.com/viewtopic.php?f=8&t=346)
- [Voicemeeter Remote C API](https://github.com/onyx-and-iris/Voicemeeter-SDK/blob/main/VoicemeeterRemoteAPI.pdf)

View File

@ -1,7 +1,8 @@
. $PSScriptRoot\kinds.ps1
. $PSScriptRoot\base.ps1
class Remote {
[String]$kind
[Hashtable]$kind
[System.Collections.ArrayList]$strip
[System.Collections.ArrayList]$bus
[System.Collections.ArrayList]$button
@ -11,22 +12,21 @@ class Remote {
[Object]$profiles
# Constructor
Remote ([String]$kind) {
$this.kind = $kind
Remote ([String]$kind_id) {
$this.kind = GetKind($kind_id)
$this.Setup()
}
[void] Setup() {
if (Setup_DLL) {
Login -KIND $this.kind
$this.profiles = Get_Profiles
$this.strip = Make_Strips
$this.bus = Make_Buses
Login -KIND $this.kind.name
$this.profiles = Get_Profiles($this.kind.name)
$this.strip = Make_Strips($this)
$this.bus = Make_Buses($this)
$this.button = Make_Buttons
$this.vban = Make_Vban
$this.vban = Make_Vban($this)
$this.command = Make_Command
$this.recorder = Make_Recorder
$this.recorder = Make_Recorder($this)
}
else { Exit }
}

View File

@ -1,4 +1,6 @@
. $PSScriptRoot\errors.ps1
. $PSScriptRoot\binding.ps1
. $PSScriptRoot\profiles.ps1
. $PSScriptRoot\inst.ps1
. $PSScriptRoot\strip.ps1
. $PSScriptRoot\bus.ps1
@ -7,62 +9,69 @@
. $PSScriptRoot\command.ps1
. $PSScriptRoot\recorder.ps1
$global:layout = $null
Function Setup_DLL {
Function Login {
param(
[String]$KIND = $null
)
try {
$vb_path = Get_VBPath
$retval = [Int][Voicemeeter.Remote]::VBVMR_Login()
if (-not $retval) { Write-Host("LOGGED IN") }
elseif ($retval -eq 1) {
Write-Host("VM NOT RUNNING")
New-Variable -Name vm_exe -Value 0
if ([string]::IsNullOrWhiteSpace($vb_path)) {
throw [VMRemoteErrors]::new("ERROR: Couldn't get Voicemeeter path")
Switch ($KIND) {
'basic' { $vm_exe = 1; Break }
'banana' { $vm_exe = 2; Break }
'potato' {
if ([Environment]::Is64BitOperatingSystem) {
$vm_exe = 6
}
else {
$dll = Join-Path -Path $vb_path -ChildPath ("VoicemeeterRemote" + `
(& { If ([Environment]::Is64BitOperatingSystem) { "64" } Else { "" } }) + `
".dll")
else { $vm_exe = 3 }
Break
}
Default { throw [LoginError]::new('Unknown Voicemeeter type') }
}
catch [VMRemoteErrors] {
$retval = [Int][Voicemeeter.Remote]::VBVMR_RunVoicemeeter([Int64]$vm_exe)
if (-not $retval) { Write-Host("STARTING VOICEMEETER") }
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 }
}
catch [LoginError], [CAPIError] {
Write-Warning $_.Exception.ErrorMessage()
return $false
}
$Signature = @"
[DllImport(@"$dll")]
public static extern int VBVMR_Login();
[DllImport(@"$dll")]
public static extern int VBVMR_Logout();
[DllImport(@"$dll")]
public static extern int VBVMR_RunVoicemeeter(Int64 run);
[DllImport(@"$dll")]
public static extern int VBVMR_GetVoicemeeterType(ref int ptr);
while (P_Dirty -or M_Dirty) { Start-Sleep -m 1 }
[DllImport(@"$dll")]
public static extern int VBVMR_MacroButton_IsDirty();
[DllImport(@"$dll")]
public static extern int VBVMR_MacroButton_SetStatus(Int64 id, Single state, Int64 mode);
[DllImport(@"$dll")]
public static extern int VBVMR_MacroButton_GetStatus(Int64 id, ref float ptr, Int64 mode);
[DllImport(@"$dll")]
public static extern int VBVMR_IsParametersDirty();
[DllImport(@"$dll")]
public static extern int VBVMR_SetParameterFloat(String param, Single value);
[DllImport(@"$dll")]
public static extern int VBVMR_GetParameterFloat(String param, ref float ptr);
[DllImport(@"$dll")]
public static extern int VBVMR_SetParameterStringA(String param, String value);
[DllImport(@"$dll")]
public static extern int VBVMR_GetParameterStringA(String param, byte[] buff);
[DllImport(@"$dll")]
public static extern int VBVMR_SetParameters(String param);
"@
Add-Type -MemberDefinition $Signature -Name Remote -Namespace Voicemeeter -PassThru | Out-Null
return $true
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]") }
}
}
Function Logout {
Start-Sleep -m 20
$retval = [Int][Voicemeeter.Remote]::VBVMR_Logout()
if (-not $retval) { Write-Host("LOGGED OUT") }
}
Function P_Dirty {
[Bool][Voicemeeter.Remote]::VBVMR_IsParametersDirty()
}
Function M_Dirty {
[Bool][Voicemeeter.Remote]::VBVMR_MacroButton_IsDirty()
}
Function Param_Get {
param(
@ -166,152 +175,3 @@ Function Param_Set_Multi {
}
}
}
Function DefineVersion {
param(
[Int]$TYPE
)
$layout = @{}
if ($TYPE -eq 1) {
$layout = @{
"name" = "basic"
"p_in" = 2
"v_in" = 1
"p_out" = 1
"v_out" = 1
"vban_in" = 4
"vban_out" = 4
}
}
elseif ($TYPE -eq 2) {
$layout = @{
"name" = "banana"
"p_in" = 3
"v_in" = 2
"p_out" = 3
"v_out" = 2
"vban_in" = 8
"vban_out" = 8
}
}
elseif ($TYPE -eq 3) {
$layout = @{
"name" = "potato"
"p_in" = 5
"v_in" = 3
"p_out" = 5
"v_out" = 3
"vban_in" = 8
"vban_out" = 8
}
}
$global:layout = $layout
}
Function Get_Profiles {
$basepath = Join-Path -Path $(Split-Path -Path $PSScriptRoot) -ChildPath "profiles"
if (Test-Path $basepath) {
$fullpath = Join-Path -Path $basepath -ChildPath $layout.name
}
else { return $null }
$filenames = @(Get-ChildItem -Path $fullpath -Filter *.psd1 -Recurse -File)
if ($filenames) {
[System.Collections.ArrayList]$configfiles = @()
$filenames | ForEach-Object {
$file = (Join-Path -Path $fullpath -ChildPath $_)
$configfiles.Add($file)
}
[HashTable]$data = @{}
$configfiles | ForEach-Object {
$filename = [System.IO.Path]::GetFileNameWithoutExtension($_)
Write-Host ("Importing profile " + $layout.name + "/" + $filename)
$data[$filename] = Import-PowerShellDataFile -Path $_
}
return $data
}
return $null
}
Function Set_Profile {
param(
[Object]$DATA, [String]$CONF
)
try {
if ($null -eq $DATA -or -not $DATA.$CONF) {
throw [VMRemoteErrors]::new("No profile named $CONF was loaded")
}
Param_Set_Multi -HASH $DATA.$CONF
Start-Sleep -m 1
}
catch [VMRemoteErrors] {
Write-Warning $_.Exception.ErrorMessage()
}
}
Function Login {
param(
[String]$KIND = $null
)
try {
$retval = [Int][Voicemeeter.Remote]::VBVMR_Login()
if (-not $retval) { Write-Host("LOGGED IN") }
elseif ($retval -eq 1) {
Write-Host("VM NOT RUNNING")
New-Variable -Name vm_exe -Value 0
Switch ($KIND) {
'basic' { $vm_exe = 1; Break }
'banana' { $vm_exe = 2; Break }
'potato' {
if ([Environment]::Is64BitOperatingSystem) {
$vm_exe = 6
}
else { $vm_exe = 3 }
Break
}
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) }
Start-Sleep -s 1
}
elseif ($retval -eq -2) {
throw [LoginError]::new('Login may only be called once per session')
}
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]") }
}
DefineVersion -TYPE $ptr
}
Function Logout {
Start-Sleep -m 20
$retval = [Int][Voicemeeter.Remote]::VBVMR_Logout()
if (-not $retval) { Write-Host("LOGGED OUT") }
}
Function P_Dirty {
[Bool][Voicemeeter.Remote]::VBVMR_IsParametersDirty()
}
Function M_Dirty {
[Bool][Voicemeeter.Remote]::VBVMR_MacroButton_IsDirty()
}

54
lib/binding.ps1 Normal file
View File

@ -0,0 +1,54 @@
Function Setup_DLL {
try {
$vb_path = Get_VBPath
if ([string]::IsNullOrWhiteSpace($vb_path)) {
throw [VMRemoteErrors]::new("ERROR: Couldn't get Voicemeeter path")
}
else {
$dll = Join-Path -Path $vb_path -ChildPath ("VoicemeeterRemote" + `
(& { If ([Environment]::Is64BitOperatingSystem) { "64" } Else { "" } }) + `
".dll")
}
}
catch [VMRemoteErrors] {
Write-Warning $_.Exception.ErrorMessage()
return $false
}
$Signature = @"
[DllImport(@"$dll")]
public static extern int VBVMR_Login();
[DllImport(@"$dll")]
public static extern int VBVMR_Logout();
[DllImport(@"$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_MacroButton_IsDirty();
[DllImport(@"$dll")]
public static extern int VBVMR_MacroButton_SetStatus(Int64 id, Single state, Int64 mode);
[DllImport(@"$dll")]
public static extern int VBVMR_MacroButton_GetStatus(Int64 id, ref float ptr, Int64 mode);
[DllImport(@"$dll")]
public static extern int VBVMR_IsParametersDirty();
[DllImport(@"$dll")]
public static extern int VBVMR_SetParameterFloat(String param, Single value);
[DllImport(@"$dll")]
public static extern int VBVMR_GetParameterFloat(String param, ref float ptr);
[DllImport(@"$dll")]
public static extern int VBVMR_SetParameterStringA(String param, String value);
[DllImport(@"$dll")]
public static extern int VBVMR_GetParameterStringA(String param, byte[] buff);
[DllImport(@"$dll")]
public static extern int VBVMR_SetParameters(String param);
"@
Add-Type -MemberDefinition $Signature -Name Remote -Namespace Voicemeeter -PassThru | Out-Null
return $true
}

View File

@ -2,10 +2,12 @@
class Bus {
[Int]$id
[Object]$remote
# Constructor
Bus ([Int]$id) {
Bus ([Int]$id, [Object]$remote) {
$this.id = $id
$this.remote = $remote
AddBoolMembers -PARAMS @('mono', 'mute')
AddStringMembers -PARAMS @('label')
@ -50,10 +52,18 @@ class Bus {
$this._eq = $this.Setter($this.cmd('eq.ab'), $arg)
}
)
[void] FadeTo([Single]$target, [int]$time) {
$this.Setter($this.cmd('FadeTo'), "($target, $time)")
}
[void] FadeBy([Single]$target, [int]$time) {
$this.Setter($this.cmd('FadeBy'), "($target, $time)")
}
}
class PhysicalBus : Bus {
PhysicalBus ([Int]$id) : base ($id) {
PhysicalBus ([Int]$id, [Object]$remote) : base ($id, $remote) {
}
hidden $_device = $($this | Add-Member ScriptProperty 'device' `
{
@ -75,15 +85,15 @@ class PhysicalBus : Bus {
}
class VirtualBus : Bus {
VirtualBus ([Int]$id) : base ($id) {
VirtualBus ([Int]$id, [Object]$remote) : base ($id, $remote) {
}
}
Function Make_Buses {
Function Make_Buses([Object]$remote) {
[System.Collections.ArrayList]$bus = @()
0..$($layout.p_out + $layout.v_out - 1) | ForEach-Object {
if ($_ -lt $layout.p_out) { [void]$bus.Add([PhysicalBus]::new($_)) }
else { [void]$bus.Add([VirtualBus]::new($_)) }
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)) }
}
$bus
}

33
lib/kinds.ps1 Normal file
View File

@ -0,0 +1,33 @@
$KindMap = @{
"basic" = @{
"name" = "basic"
"p_in" = 2
"v_in" = 1
"p_out" = 1
"v_out" = 1
"vban_in" = 4
"vban_out" = 4
};
"banana" = @{
"name" = "banana"
"p_in" = 3
"v_in" = 2
"p_out" = 3
"v_out" = 2
"vban_in" = 8
"vban_out" = 8
};
"potato" = @{
"name" = "potato"
"p_in" = 5
"v_in" = 3
"p_out" = 5
"v_out" = 3
"vban_in" = 8
"vban_out" = 8
};
}
Function GetKind([string]$kind_id) {
$KindMap[$kind_id]
}

View File

@ -78,8 +78,8 @@ Function AddActionMembers() {
}
Function AddChannelMembers() {
$num_A = $layout.p_out
$num_B = $layout.v_out
$num_A = $this.remote.kind.p_out
$num_B = $this.remote.kind.v_out
[System.Collections.ArrayList]$channels = @()
1..$($num_A + $num_B) | ForEach-Object {

37
lib/profiles.ps1 Normal file
View File

@ -0,0 +1,37 @@
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
}
else { return $null }
$filenames = @(Get-ChildItem -Path $fullpath -Filter *.psd1 -Recurse -File)
[HashTable]$data = @{}
if ($filenames) {
$filenames | ForEach-Object {
(Join-Path -Path $fullpath -ChildPath $_) | ForEach-Object {
$filename = [System.IO.Path]::GetFileNameWithoutExtension($_)
Write-Host ("Importing profile " + $kind_id + "/" + $filename)
$data[$filename] = Import-PowerShellDataFile -Path $_
}
}
return $data
}
return $null
}
Function Set_Profile {
param(
[Object]$DATA, [String]$CONF
)
try {
if ($null -eq $DATA -or -not $DATA.$CONF) {
throw [VMRemoteErrors]::new("No profile named $CONF was loaded")
}
Param_Set_Multi -HASH $DATA.$CONF
Start-Sleep -m 1
}
catch [VMRemoteErrors] {
Write-Warning $_.Exception.ErrorMessage()
}
}

View File

@ -1,8 +1,11 @@
. $PSScriptRoot\meta.ps1
class Recorder {
[Object]$remote
# Constructor
Recorder() {
Recorder([Object]$remote) {
$this.remote = $remote
AddActionMembers -PARAMS @('play', 'stop', 'pause', 'replay', 'record', 'ff', 'rew')
AddChannelMembers
}
@ -34,11 +37,11 @@ class Recorder {
}
)
[void] load([String]$filename) {
[void] Load([String]$filename) {
$this.Setter($this.cmd('load'), $filename)
}
}
Function Make_Recorder {
return [Recorder]::new()
Function Make_Recorder([Object]$remote) {
return [Recorder]::new($remote)
}

View File

@ -2,9 +2,11 @@
class Strip {
[Int]$id
[Object]$remote
Strip ([Int]$id) {
Strip ([Int]$id, [Object]$remote) {
$this.id = $id
$this.remote = $remote
AddBoolMembers -PARAMS @('mono', 'solo', 'mute')
AddIntMembers -PARAMS @('limit')
@ -23,17 +25,25 @@ class Strip {
return Param_Get -PARAM $cmd -IS_STRING $true
}
[void] Setter($cmd, $set) {
Param_Set -PARAM $cmd -VALUE $set
[void] Setter($cmd, $val) {
Param_Set -PARAM $cmd -VALUE $val
}
[String] cmd ($arg) {
return "Strip[" + $this.id + "].$arg"
}
[void] FadeTo([Single]$target, [int]$time) {
$this.Setter($this.cmd('FadeTo'), "($target, $time)")
}
[void] FadeBy([Single]$target, [int]$time) {
$this.Setter($this.cmd('FadeBy'), "($target, $time)")
}
}
class PhysicalStrip : Strip {
PhysicalStrip ([Int]$id) : base ($id) {
PhysicalStrip ([Int]$id, [Object]$remote) : base ($id, $remote) {
AddFloatMembers -PARAMS @('comp', 'gate')
}
@ -57,20 +67,20 @@ class PhysicalStrip : Strip {
}
class VirtualStrip : Strip {
VirtualStrip ([Int]$id) : base ($id) {
VirtualStrip ([Int]$id, [Object]$remote) : base ($id, $remote) {
AddBoolMembers -PARAMS @('mc')
AddIntMembers -PARAMS @('k')
}
}
Function Make_Strips {
Function Make_Strips([Object]$remote) {
[System.Collections.ArrayList]$strip = @()
0..$($layout.p_in + $layout.v_in - 1) | ForEach-Object {
if ($_ -lt $layout.p_in) {
[void]$strip.Add([PhysicalStrip]::new($_))
0..$($remote.kind.p_in + $remote.kind.v_in - 1) | ForEach-Object {
if ($_ -lt $remote.kind.p_in) {
[void]$strip.Add([PhysicalStrip]::new($_, $remote))
}
else { [void]$strip.Add([VirtualStrip]::new($_)) }
else { [void]$strip.Add([VirtualStrip]::new($_, $remote)) }
}
$strip
}

View File

@ -3,7 +3,7 @@ class Vban {
[String]$direction
# Constructor
Vban($id) {
Vban([Int]$id) {
$this.id = $id
}
@ -165,7 +165,7 @@ class Vban {
class VbanInstream : Vban {
# Constructor
VbanInstream ([int]$id) : base ($id) {
VbanInstream ([Int]$id) : base ($id) {
$this.direction = "in"
}
}
@ -173,20 +173,20 @@ class VbanInstream : Vban {
class VbanOutstream : Vban {
# Constructor
VbanOutstream ([int]$id) : base ($id) {
VbanOutstream ([Int]$id) : base ($id) {
$this.direction = "out"
}
}
Function Make_Vban {
Function Make_Vban([Object]$remote) {
[System.Collections.ArrayList]$instream = @()
[System.Collections.ArrayList]$outstream = @()
0..$($layout.vban_in - 1) | ForEach-Object {
0..$($remote.kind.vban_in - 1) | ForEach-Object {
[void]$instream.Add([VbanInstream]::new($_))
}
0..$($layout.vban_out - 1) | ForEach-Object {
0..$($remote.kind.vban_out - 1) | ForEach-Object {
[void]$outstream.Add([VbanOutstream]::new($_))
}
@ -201,7 +201,7 @@ Function Make_Vban {
}`
{
param( [bool]$arg )
Param_Set -PARAM 'vban.Enable' -VALUE $(if ($arg) { 1 } else { 0 })
Param_Set -PARAM 'vban.Enable' -Value $(if ($arg) { 1 } else { 0 })
}
$CustomObject