-
Notifications
You must be signed in to change notification settings - Fork 1
/
play_tone_measurement.py
59 lines (50 loc) · 1.35 KB
/
play_tone_measurement.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
#!/usr/bin/env python
# Chat Client (Test)
import sys
import soundrxtx
(p, stream) = soundrxtx.tone.init()
global state
global prev_freq
global str_buf
global bit_str_buf
global total_bit_str
global freq_found
state = 0
prev_freq = 0
str_buf = ""
bit_str_buf = ""
total_bit_str = ""
freq_found = False
def process_freq(freq):
global state
global prev_freq
global str_buf
global bit_str_buf
global total_bit_str
global freq_found
#print "FOUND FREQ: %i (Bsize: %i)" % (freq, len(bit_str_buf))
#if freq != prev_freq:
# print "FOUND FREQ: %i (Bsize: %i)" % (freq, len(bit_str_buf))
prev_freq = freq
if freq == tone:
freq_found = True
'''if (len(bit_str_buf) % 8 == 0) and (len(bit_str_buf) != 0):
sys.stdout.write(soundrxtx.textconvert.binary_to_ASCII(bit_str_buf))
sys.stdout.flush()
total_bit_str += bit_str_buf
print "bits: %s" % bit_str_buf
bit_str_buf = ""'''
global tone
tone = 100
#tone = 1450
while tone < 10000:
sys.stderr.write("Playing tone %i!\n" % tone)
try:
(p, stream) = soundrxtx.tone.init()
soundrxtx.tone.play_tone(tone, 1, 0.5, soundrxtx.tone.audio_rate, stream)
soundrxtx.tone.end((p, stream))
except KeyboardInterrupt:
break
except:
print "CRASH! Stopped at %i." % tone
tone += 50