mirror of
https://github.com/onyx-and-iris/voicemeeter-api-powershell.git
synced 2026-03-20 08:59:10 +00:00
add device enumeration
bindings, base functions, and Remote methods implemented initial manual tests for potato pass
This commit is contained in:
parent
b41001f4a9
commit
abd792acd5
@ -75,6 +75,22 @@ class Remote {
|
||||
[void] PDirty() { P_Dirty }
|
||||
|
||||
[void] MDirty() { M_Dirty }
|
||||
|
||||
[int] GetOutputCount() {
|
||||
return Device_Count -IS_OUT $true
|
||||
}
|
||||
|
||||
[int] GetInputCount() {
|
||||
return Device_Count
|
||||
}
|
||||
|
||||
[PSObject] GetOutputDevice([int]$index) {
|
||||
return Device_Desc -INDEX $index -IS_OUT $true
|
||||
}
|
||||
|
||||
[PSObject] GetInputDevice([int]$index) {
|
||||
return Device_Desc -INDEX $index
|
||||
}
|
||||
}
|
||||
|
||||
class RemoteBasic : Remote {
|
||||
|
||||
55
lib/base.ps1
55
lib/base.ps1
@ -225,4 +225,59 @@ function Get_Level {
|
||||
throw [CAPIError]::new($retval, 'VBVMR_GetLevel')
|
||||
}
|
||||
[float]$ptr
|
||||
}
|
||||
|
||||
function Device_Count {
|
||||
param(
|
||||
[bool]$IS_OUT = $false
|
||||
)
|
||||
if ($IS_OUT) {
|
||||
$retval = [int][Voicemeeter.Remote]::VBVMR_Output_GetDeviceNumber()
|
||||
if ($retval -lt 0) {
|
||||
throw [CAPIError]::new($retval, 'VBVMR_Output_GetDeviceNumber')
|
||||
}
|
||||
}
|
||||
else {
|
||||
$retval = [int][Voicemeeter.Remote]::VBVMR_Input_GetDeviceNumber()
|
||||
if ($retval -lt 0) {
|
||||
throw [CAPIError]::new($retval, 'VBVMR_Input_GetDeviceNumber')
|
||||
}
|
||||
}
|
||||
$retval
|
||||
}
|
||||
|
||||
function Device_Desc {
|
||||
param(
|
||||
[int]$INDEX, [bool]$IS_OUT = $false
|
||||
)
|
||||
$driver = 0
|
||||
$name = [System.Byte[]]::new(512)
|
||||
$hardwareid = [System.Byte[]]::new(512)
|
||||
|
||||
if ($IS_OUT) {
|
||||
$retval = [int][Voicemeeter.Remote]::VBVMR_Output_GetDeviceDescA($INDEX, [ref]$driver, $name, $hardwareid)
|
||||
if ($retval -notin @(0)) {
|
||||
throw [CAPIError]::new($retval, 'VBVMR_Output_GetDeviceDescA')
|
||||
}
|
||||
}
|
||||
else {
|
||||
$retval = [int][Voicemeeter.Remote]::VBVMR_Input_GetDeviceDescA($INDEX, [ref]$driver, $name, $hardwareid)
|
||||
if ($retval -notin @(0)) {
|
||||
throw [CAPIError]::new($retval, 'VBVMR_Input_GetDeviceDescA')
|
||||
}
|
||||
}
|
||||
|
||||
$drivers = @{
|
||||
1 = 'MME'
|
||||
3 = 'WDM'
|
||||
4 = 'KS'
|
||||
5 = 'ASIO'
|
||||
}
|
||||
|
||||
[PSCustomObject]@{
|
||||
Driver = $drivers[$driver]
|
||||
Name = [System.Text.Encoding]::ASCII.GetString($name).Trim([char]0)
|
||||
HardwareID = [System.Text.Encoding]::ASCII.GetString($hardwareid).Trim([char]0)
|
||||
IsOutput = $IS_OUT
|
||||
}
|
||||
}
|
||||
@ -43,6 +43,15 @@ function Setup_DLL {
|
||||
|
||||
[DllImport(@"$dll")]
|
||||
public static extern int VBVMR_GetLevel(Int64 mode, Int64 index, ref float ptr);
|
||||
|
||||
[DllImport(@"$dll")]
|
||||
public static extern int VBVMR_Output_GetDeviceNumber();
|
||||
[DllImport(@"$dll")]
|
||||
public static extern int VBVMR_Input_GetDeviceNumber();
|
||||
[DllImport(@"$dll")]
|
||||
public static extern int VBVMR_Output_GetDeviceDescA(Int64 index, ref int type, byte[] name, byte[] hardwareid);
|
||||
[DllImport(@"$dll")]
|
||||
public static extern int VBVMR_Input_GetDeviceDescA(Int64 index, ref int type, byte[] name, byte[] hardwareid);
|
||||
"@
|
||||
|
||||
Add-Type -MemberDefinition $Signature -Name Remote -Namespace Voicemeeter -PassThru | Out-Null
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user