 |
AutoHotkey Community Let's help each other out
|
| View previous topic :: View next topic |
| Author |
Message |
Mustang
Joined: 17 May 2007 Posts: 421 Location: England
|
Posted: Thu Sep 04, 2008 11:49 pm Post subject: Microphone Peak Value - Vista Audio (Lexikos) |
|
|
Based on Lexikos' Vista Audio Control Functions v2.0
I put together the following script:
| Code: | #Include, COM.ahk
COM_CoInitialize()
; CoCreateInstance
DeviceEnumerator := COM_CreateObject( "{BCDE0395-E52F-467C-8E3D-C4579291692E}", "{A95664D2-9614-4F35-A746-DE8DB63617E6}" )
; IMMDeviceEnumerator::GetDefaultAudioEndpoint
Flow := 1 ; Capture
DllCall( NumGet( NumGet( DeviceEnumerator+0 )+16 ), "UInt", DeviceEnumerator, "UInt", Flow, "UInt", 0, "UInt*", Device)
COM_Release( DeviceEnumerator )
; IMMDevice::Activate
DllCall( NumGet( NumGet( Device+0 )+12), "UIint", Device, "UInt", COM_GUID4String( iid, "{C02216F6-8C67-4B5B-9D00-D008E73E0064}" ), "UInt", 7, "UInt", 0, "UInt*", AudioMeterInformation )
COM_Release( Device )
Loop
{
; IAudioMeterInformation::GetPeakValue
DllCall( NumGet( NumGet( AudioMeterInformation+0 )+12 ), "UIint", AudioMeterInformation, "Float*", Peak )
ToolTip % Round( Peak*100 )
Sleep, 10
}
Delete::
COM_Release( MeterInfo )
ExitApp |
The idea is to output in a ToolTip the peak value of the default recording device (e.g. Microphone)
It works fine if the "Control Panel > Sound > Recording" window is open
However if this window is closed then the ToolTip displays 0
I guess this problem is aimed at Lexikos or anyone else with extensive Vista audio knowledge
But is there anything that I've missed? |
|
| Back to top |
|
 |
Mustang
Joined: 17 May 2007 Posts: 421 Location: England
|
Posted: Fri Sep 19, 2008 1:05 am Post subject: |
|
|
| Or maybe someone can tell me how to do this without using COM functions? |
|
| Back to top |
|
 |
Lexikos
Joined: 17 Oct 2006 Posts: 7295 Location: Australia
|
Posted: Mon Nov 24, 2008 1:27 pm Post subject: |
|
|
(I accidentally found this thread while searching for something else.)
The VA.ahk equivalent is:
| Code: | COM_Init()
peakMeter := VA_GetAudioMeter("capture")
Loop {
VA_IAudioMeterInformation_GetPeakValue(peakMeter, Peak)
ToolTip % Round( Peak*100 )
Sleep, 10
}
Delete::
COM_Release(peakMeter)
COM_Term()
ExitApp | Of course, this has the same issue as your script. The peak meter only reports meaningful values when something is actually capturing audio. I'm not sure how it is done, and haven't spent the necessary time to find out as I don't have a need to detect sound input. |
|
| Back to top |
|
 |
|
|
You can post new topics in this forum You can reply to topics in this forum
|
Powered by phpBB © 2001, 2005 phpBB Group
|