07-01-2018, 05:48 PM
(This post was last modified: 07-01-2018, 11:24 PM by Start_Learning.)
Hi TheVig,
For Function3 we could do something like this using QM:
Function CheckSilentWav
For Function3 we could do something like this using QM:
Function CheckSilentWav
str wavFile1="C:\Temp\noise.wav"
str wavFile2="C:\Temp\silence.wav"
;Read in data from wav files
str s1.getfile(wavFile1)
str s2.getfile(wavFile2)
;Convert binary data to string array, just extract 50 bytes only.
ARRAY(str) a1 a2
sub.GetDataFile(s1 50 a1)
sub.GetDataFile(s2 50 a2)
;Check for silent wavFile1
int result=sub.CheckSilentWav(a1)
if(result) out F"{wavFile1} is silent."
else if(result=0) out F"{wavFile1} is noisy."
else out F"Unknown {wavFile1} file."
;Check for silent wavFile2
result=sub.CheckSilentWav(a2)
if(result) out F"{wavFile2} is silent."
else if(result=0) out F"{wavFile2} is noisy."
else out F"Unknown {wavFile2} file."
#sub GetDataFile
function !*ptr nBytes ARRAY(str)&a
_s.encrypt(8 _s.fromn(ptr nBytes) "" 1)
_s.findreplace(" ", "[]", 8)
a=_s
#sub CheckSilentWav
function# ARRAY(str)&wav
;Note1: return 1 if wav file is silent; return 0 if wav file is noisy; otherwise return -1.
;Note2: just check the value from 44th to 50th position (7 bytes only) to find out if it is silence or not.
if wav.len > 0
,for _i 43 50
,,if(!(StrCompare(wav[_i], "00")=0)) ret 0
,ret 1
else
,ret -1