Skip to content

Commit

Permalink
Refine timing error detection logic.
Browse files Browse the repository at this point in the history
  • Loading branch information
batt committed Nov 21, 2014
1 parent d951e78 commit 97d9794
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions qam.py
Original file line number Diff line number Diff line change
Expand Up @@ -101,22 +101,27 @@ def __init__(self, size=32):
self.sma = Sma(size)
self.cnt = 0
self.curr_lock = 0
self.out = 0

def curr_lock(self):
return self.curr_lock

def locked(self):
return (self.cnt)
if self.cnt >= 20:
self.out = 1
elif self.cnt < 1:
self.out = 0
return self.out

def add(self, e):
self.sma.add(e)
self.curr_lock = self.sma.avg() < 1e-3
self.curr_lock = (abs(self.sma.avg()) < 1e-3) and (self.sma.variance() < 1e-4)
if self.curr_lock:
self.cnt += 1
else:
self.cnt -= 1

self.cnt = min(max(self.cnt, 0), 2)
self.cnt = min(max(self.cnt, 0), 64)

class qam:
def __init__(self, filename, samplerate=48000, mode='r'):
Expand Down

0 comments on commit 97d9794

Please sign in to comment.