//QM v2.9. Do not edit with text editor!!! //
6     2
ék¿›•v­ÿ™Í¨i¦$€—¿A™@@¤ËÄ+v
  Stop_Program  8 3611B2A4 0
key (VK_MEDIA_STOP)

  Run_Program  8 3611C2C9 0
 ifi-(win("Windows Media Player" "WMPlayerApp"))
	 run "$my music$\Playlists\Test.wpl"
	 wait 0 WV win("Windows Media Player" "WMPlayerApp")
	 key (VK_MEDIA_PLAY_PAUSE)
 else key (VK_MEDIA_PLAY_PAUSE)
  Count_Logic  8 3611B7AA 0
function hDlg
str a.getwintext(id(3 hDlg))
CURRENCY- _SecVal
CURRENCY- _COUNTER
CURRENCY- _SecCOUNTER
_SecVal=_SecVal+val(a)
_COUNTER=_COUNTER+1
_s.getwintext(id(10 hDlg))
int Sens=val(_s)
if _COUNTER=10
	_SecVal=_SecVal/10
	if _SecVal<Sens
		_SecCOUNTER=_SecCOUNTER+1
		str b.getwintext(id(5 hDlg))
		_i=val(b)
		if _SecCOUNTER=_i
			Run_Program
			SetDlgItemInt hDlg 6 1 0		
	else _SecCOUNTER=0
		_s.getwintext(id(6 hDlg))
		if _s=1
			Stop_Program
			SetDlgItemInt hDlg 6 0 0
	_COUNTER=0
	_SecVal=0
	
  dlg_wave_meter  8 3611C399 0
\Dialog_Editor
function# hDlg message wParam lParam
if(hDlg) goto messages

str controls = "3 5 6 10"
str e3 e5 e6 e10
e6=0
rget(_s "Seconds" "Settings" "$desktop$\Audio_Settings.ini")
e5=_s
	 SendMessage id(5 hDlg) PBM_SETPOS _s 0
rget(_s "Sensitivity" "Settings" "$desktop$\Audio_Settings.ini")
e10=_s
	 SendMessage id(10 hDlg) PBM_SETPOS _s 0
if(!ShowDialog("dlg_wave_meter" &dlg_wave_meter &controls)) ret

 BEGIN DIALOG
 0 "" 0x90C80A44 0x100 0 0 223 135 "Line-In Meter"
 1 Button 0x54030001 0x4 136 112 48 14 "Close"
 3 Edit 0x54030080 0x200 4 24 32 16 ""
 4 msctls_progress32 0x54030000 0x0 4 0 208 20 ""
 5 Edit 0x54032000 0x200 4 44 32 14 ""
 6 Edit 0x54032800 0x200 4 64 32 14 ""
 7 Static 0x54000000 0x0 40 28 48 13 "level"
 8 Static 0x54000000 0x0 40 44 48 13 "Secs to React"
 9 Static 0x54000000 0x0 40 64 48 12 "PlayState"
 10 Edit 0x54032000 0x200 4 84 32 14 ""
 11 Static 0x54000000 0x0 40 84 48 13 "Sensitivity"
 12 Button 0x54032000 0x0 136 96 48 14 "Save Settings"
 13 Button 0x54032000 0x0 88 64 20 12 "?"
 END DIALOG
 DIALOG EDITOR: "" 0x2020105 "*" "" ""

ret
 messages
int- hwi
WAVEHDR- hd
sel message
	case WM_INITDIALOG
	key (VK_MEDIA_STOP)

	 SendMessage id(4 hDlg) PBM_SETRANGE 0 0x8000<<16
	
	WAVEFORMATEX wf.cbSize=sizeof(wf)
	wf.wFormatTag=WAVE_FORMAT_PCM
	wf.nChannels=1 ;;mono
	wf.nSamplesPerSec=44.1*1000 ;;44.1 kHz
	wf.wBitsPerSample=16
	wf.nBlockAlign=wf.nChannels*wf.wBitsPerSample/8
	wf.nAvgBytesPerSec=wf.nSamplesPerSec*wf.nBlockAlign
	
	int rc=waveInOpen(&hwi WAVE_MAPPER &wf hDlg 0 CALLBACK_WINDOW)
	if(rc) out "waveInOpen: %i" rc; ret
	
	hd.dwBufferLength=wf.nAvgBytesPerSec/10 ;;10 buffers/s
	hd.lpData=q_malloc(hd.dwBufferLength)
	rc=waveInPrepareHeader(hwi &hd sizeof(hd))
	if(rc) out "waveInPrepareHeader: %i" rc; ret
	
	rc=waveInStart(hwi)
	if(rc) out "waveInStart: %i" rc; ret
	
	case WM_DESTROY
	waveInStop(hwi)
	waveInClose(hwi)
	0
	
	case MM_WIM_OPEN
	out "open"
	rc=waveInAddBuffer(hwi &hd sizeof(hd))
	if(rc) out "waveInAddBuffer: %i" rc; ret
	
	case MM_WIM_CLOSE
	out "close"
	rc=waveInUnprepareHeader(hwi &hd sizeof(hd))
	q_free hd.lpData
	
	case MM_WIM_DATA
	 out "%i %i 0x%X" hd.dwBytesRecorded hd.lpData hd.dwFlags
	int i dc p k
	word* w=hd.lpData; int nsamples=hd.dwBytesRecorded/2
	if(!nsamples) ret
	 calc direct current level
	for(i 0 nsamples) dc+w[i]
	dc/nsamples
	 calc power
	for(i 0 nsamples) p+abs(w[i]-dc)
	p/nsamples
	 out "%i %i" dc p
	p=p*60/0x8000 ;;normalize to max 100. Near 100 can be only for square waveform or when peaks are cut. For nondistorted sinus waveform would be max about 60 or 70.
	if(p>100) p=100
	 p=100-p
	 p-30
	SendMessage id(4 hDlg) PBM_SETPOS p 0
	SetDlgItemInt hDlg 3 p 0
	rc=waveInAddBuffer(hwi &hd sizeof(hd))
	
	case WM_COMMAND goto messages2
ret
 messages2
sel wParam
	case 13
	mes "If Play state is 0, Audio Fill is currently set for stop.  If Play State is 1, Audio Fill is currently set to be playing." "Line-In Meter" "?"
	case 12
	_s.getwintext(id(5 hDlg))
	rset(_s "Seconds" "Settings" "$desktop$\Audio_Settings.ini")
	_s.getwintext(id(10 hDlg))
	rset(_s "Sensitivity" "Settings" "$desktop$\Audio_Settings.ini")
	case EN_CHANGE<<16|3
	Count_Logic hDlg
	case IDOK
	case IDCANCEL
ret 1

  file  268500992 0

  