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

@@ -1,4 +1,6 @@
. $PSScriptRoot\errors.ps1
. $PSScriptRoot\binding.ps1
. $PSScriptRoot\profiles.ps1
. $PSScriptRoot\inst.ps1
. $PSScriptRoot\strip.ps1
. $PSScriptRoot\bus.ps1
@@ -7,63 +9,70 @@
. $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 { $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
}
else {
$dll = Join-Path -Path $vb_path -ChildPath ("VoicemeeterRemote" + `
(& { If ([Environment]::Is64BitOperatingSystem) { "64" } Else { "" } }) + `
".dll")
elseif ($retval -eq -2) {
throw [LoginError]::new('Login may only be called once per session')
}
else { Exit }
}
catch [VMRemoteErrors] {
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(
[String]$PARAM, [bool]$IS_STRING = $false
@@ -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()
}