Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
How to check if any sound is playing
#4
Function init2
Code:
Copy      Help
ref WINAPI2 "$qm$\winapi2.txt" 7 ;;http://www.quickmacros.com/forum/viewtopic.php?p=6619

Macro audio output level meter
Code:
Copy      Help
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
Code:
Copy      Help
;/
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


Messages In This Thread

Forum Jump:


Users browsing this thread: 1 Guest(s)