Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Check if .wav is silent or not
Hi TheVig,

For Function3 we could do something like this using QM:

Function CheckSilentWav
Select All      Help
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
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)

#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
,ret -1

Attached Files
.zip (Size: 5.86 KB / Downloads: 2)
.zip (Size: 396 bytes / Downloads: 2)

Messages In This Thread

Forum Jump:

Users browsing this thread: 1 Guest(s)