2 import scipy.signal as signal
3 import sys, wave, struct, re
5 INT = "([-+]?[0-9][0-9]*)"
7 wav_fond = wave.open("filter_fond.wav", "w")
8 wav_fond.setnchannels(1)
9 wav_fond.setsampwidth(2)
10 wav_fond.setframerate(5000)
11 wav_harm1 = wave.open("filter_harm1.wav", "w")
12 wav_harm1.setnchannels(1)
13 wav_harm1.setsampwidth(2)
14 wav_harm1.setframerate(5000)
15 wav_other = wave.open("filter_other.wav", "w")
16 wav_other.setnchannels(1)
17 wav_other.setsampwidth(2)
18 wav_other.setframerate(5000)
27 l = sys.stdin.readline()
30 m = re.match("%s pow_fond=%s pow_harm1=%s pow_other=%s cpt_filter=%s detected=%s"%(INT, INT, INT, INT, INT, INT), l)
32 n, val_fond, val_harm1, val_other, val_cpt_filter, val_detected = map(int, m.groups())
33 print "pow", n, val_other, val_harm1, val_other, val_cpt_filter, val_detected
34 pow_fond.append(val_fond)
35 pow_harm1.append(val_harm1)
36 pow_other.append(val_other)
37 cpt_filter.append(val_cpt_filter)
38 detected.append(val_detected*500)
39 m = re.match("%s fil_fond=%s fil_harm1=%s fil_other=%s"%(INT, INT, INT, INT), l)
41 n, val_fond, val_harm1, val_other = map(int, m.groups())
42 print "fil", n, val_fond, val_harm1, val_other
43 wav_fond.writeframes(struct.pack("<h", val_fond))
44 wav_harm1.writeframes(struct.pack("<h", val_harm1))
45 wav_other.writeframes(struct.pack("<h", val_other))
49 plot(range(len(pow_fond)), pow_fond)
50 plot(range(len(pow_fond)), pow_harm1)
51 plot(range(len(pow_fond)), pow_other)
55 plot(range(len(cpt_filter)), cpt_filter)
56 plot(range(len(detected)), detected)
60 # save in a file or display
61 if len(sys.argv) >= 2: