07-01-2015, 04:37 AM
Function init2
Macro audio output level meter
Function GetAudioMeter
ref WINAPI2 "$qm$\winapi2.txt" 7 ;;http://www.quickmacros.com/forum/viewtopic.php?p=6619
Macro audio output level meter
out
ref WINAPI2
double waitPeriod; int channelCount
IAudioMeterInformation meter=GetAudioMeter(waitPeriod channelCount)
rep
,FLOAT peak; meter.GetPeakValue(peak)
,out peak
,
,;ARRAY(FLOAT) af.create(channelCount)
,;meter.GetChannelsPeakValues(af.len &af[0])
,;int i
,;for(i 0 af.len) out af[i]
,
,wait waitPeriod
,1 ;;debug
Function GetAudioMeter
;/
function'WINAPI2.IAudioMeterInformation [double&waitPeriod] [int&channelCount]
if(_winver<0x600) end "need Windows Vista+"
#opt nowarnings 1
ref WINAPI2
IMMDeviceEnumerator en._create(CLSID_MMDeviceEnumerator)
IMMDevice dev; en.GetDefaultAudioEndpoint(eRender eMultimedia &dev)
IAudioMeterInformation meter; dev.Activate(IID_IAudioMeterInformation CLSCTX_ALL 0 &meter)
if &waitPeriod
,IAudioClient ac; dev.Activate(IID_IAudioClient CLSCTX_ALL 0 &ac)
,long perDef perMin; ac.GetDevicePeriod(perDef perMin)
,waitPeriod=perDef/10000000.0 ;;10 ms
if(&channelCount) meter.GetMeteringChannelCount(channelCount)
ret meter