Skip to content

Commit a1585d5

Browse files
committed
use the leftover bits after rounding to reduce errors (29bad/920good)
1 parent bf8dc9d commit a1585d5

File tree

2 files changed

+12
-6
lines changed

2 files changed

+12
-6
lines changed

chopin8.py

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@
2929
dc = data.mean()
3030
data -= dc
3131

32-
# without filter: 340 errors
32+
# without filter: 340 errors, 303bad/449good if DP
3333

3434
# 91 errors
3535
bandpass = sps.firwin(97, [.08/NYQUIST_MHZ, 1.20/NYQUIST_MHZ], pass_zero=False)
@@ -41,10 +41,13 @@
4141
bandpass = sps.firwin(97, [.100/NYQUIST_MHZ, 1.50/NYQUIST_MHZ], pass_zero=False)
4242
# 44 (double precision)
4343
bandpass = sps.firwin(91, [.100/NYQUIST_MHZ, 1.50/NYQUIST_MHZ], pass_zero=False)
44-
# 40 (double precision)
45-
bandpass = sps.firwin(91, [.095/NYQUIST_MHZ, 1.70/NYQUIST_MHZ], pass_zero=False)
44+
# 40 (double precision)/ 842 good
45+
bandpass = sps.firwin(91, [.095/NYQUIST_MHZ, 1.72/NYQUIST_MHZ], pass_zero=False)
4646
data = sps.lfilter(bandpass, 1.0, data)
4747

48+
#bandpassb, bandpassa = sps.butter(4, [0.20/NYQUIST_MHZ, 1.7/NYQUIST_MHZ], btype='bandpass')
49+
#data = sps.lfilter(bandpassb, bandpassa, data)
50+
4851
# filter to binary signal
4952
data = (data > 0.0)
5053

@@ -115,6 +118,9 @@
115118
print "writing file ..."
116119

117120
with open("chopin8-bits.txt", "w") as f:
121+
leftover = 0
118122
for (value, duration) in zip(runValues, runDurations):
119-
duration = int(round(duration)) # to integer
120-
f.write(str(value) * duration)
123+
durationr = int(round(duration + (leftover * .111))) # to integer
124+
leftover = duration - durationr
125+
126+
f.write(str(value) * durationr)

laser2wav.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -218,6 +218,7 @@ def main():
218218
z = delta_signal.find("100000000001000000000010", z)
219219
if z<0: break
220220
frame = delta_signal[z:z+588]
221+
z = z + 588
221222
if len(frame)==588:
222223
try:
223224
(control, data) = analyze_frame(frame)
@@ -226,7 +227,6 @@ def main():
226227
print("good")
227228
except KeyError:
228229
print("argh")
229-
z = z + 588
230230

231231
analyze_control_stream(control_stream)
232232

0 commit comments

Comments
 (0)