AutoHotkey Homepage AutoHotkey Community
Let's help each other out
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Microphone Peak Value - Vista Audio (Lexikos)

 
Reply to topic    AutoHotkey Community Forum Index -> Ask for Help
View previous topic :: View next topic  
Author Message
Mustang



Joined: 17 May 2007
Posts: 421
Location: England

PostPosted: Thu Sep 04, 2008 11:49 pm    Post subject: Microphone Peak Value - Vista Audio (Lexikos) Reply with quote

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
View user's profile Send private message
Mustang



Joined: 17 May 2007
Posts: 421
Location: England

PostPosted: Fri Sep 19, 2008 1:05 am    Post subject: Reply with quote

Or maybe someone can tell me how to do this without using COM functions?
Back to top
View user's profile Send private message
Lexikos



Joined: 17 Oct 2006
Posts: 7295
Location: Australia

PostPosted: Mon Nov 24, 2008 1:27 pm    Post subject: Reply with quote

(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
View user's profile Send private message Visit poster's website
Display posts from previous:   
Reply to topic    AutoHotkey Community Forum Index -> Ask for Help All times are GMT
Page 1 of 1

 
Jump to:  
You can post new topics in this forum
You can reply to topics in this forum


Powered by phpBB © 2001, 2005 phpBB Group