I'm using the code from this Github archive of the library, https://github.com/Masonjar13/AHK-Library/blob/master/Required-Libraries/VA.ahk
So something simple I would try would be something like this:
Code: Select all
device := VA_GetDeviceName("Speakers")
MsgBox % device
I also tried this function:
Code: Select all
Device := VA_GetDevice(device_desc="playback")
MsgBox % Device
Code: Select all
; device_desc = device_id
; | ( friendly_name | 'playback' | 'capture' ) [ ':' index ]
VA_GetDevice(device_desc="playback")
{
static CLSID_MMDeviceEnumerator := "{BCDE0395-E52F-467C-8E3D-C4579291692E}"
, IID_IMMDeviceEnumerator := "{A95664D2-9614-4F35-A746-DE8DB63617E6}"
if !(deviceEnumerator := ComObjCreate(CLSID_MMDeviceEnumerator, IID_IMMDeviceEnumerator))
return 0
device := 0
if VA_IMMDeviceEnumerator_GetDevice(deviceEnumerator, device_desc, device) = 0
goto VA_GetDevice_Return
if device_desc is integer
{
m2 := device_desc
if m2 >= 4096 ; Probably a device pointer, passed here indirectly via VA_GetAudioMeter or such.
{
ObjAddRef(device := m2)
goto VA_GetDevice_Return
}
}
else
RegExMatch(device_desc, "(.*?)\s*(?::(\d+))?$", m)
if m1 in playback,p
m1 := "", flow := 0 ; eRender
else if m1 in capture,c
m1 := "", flow := 1 ; eCapture
else if (m1 . m2) = "" ; no name or number specified
m1 := "", flow := 0 ; eRender (default)
else
flow := 2 ; eAll
if (m1 . m2) = "" ; no name or number (maybe "playback" or "capture")
{
VA_IMMDeviceEnumerator_GetDefaultAudioEndpoint(deviceEnumerator, flow, 0, device)
goto VA_GetDevice_Return
}
VA_IMMDeviceEnumerator_EnumAudioEndpoints(deviceEnumerator, flow, 1, devices)
if m1 =
{
VA_IMMDeviceCollection_Item(devices, m2-1, device)
goto VA_GetDevice_Return
}
VA_IMMDeviceCollection_GetCount(devices, count)
index := 0
Loop % count
if VA_IMMDeviceCollection_Item(devices, A_Index-1, device) = 0
if InStr(VA_GetDeviceName(device), m1) && (m2 = "" || ++index = m2)
goto VA_GetDevice_Return
else
ObjRelease(device), device:=0
VA_GetDevice_Return:
ObjRelease(deviceEnumerator)
if devices
ObjRelease(devices)
return device ; may be 0
}
Code: Select all
CLSID_MMDeviceEnumerator := "{BCDE0395-E52F-467C-8E3D-C4579291692E}"
, IID_IMMDeviceEnumerator := "{A95664D2-9614-4F35-A746-DE8DB63617E6}"
The only functions that made sense to me and gave me a number I expected were under "Master Controls" and just for finding audio volume, muting, setting audio volume, and giving amount of channels.
My current project i'm trying to get the audio levels that are coming to my audio output device, so I can make decisions in my program based on if there is sound coming through the head-phones, but i'm not really understanding what these functions are asking for exactly and how to interpret the addresses and such. I have also not done much object oriented stuff thus far just fyi. Thanks a lot for any help.