mirror of
https://github.com/romanz/amodem.git
synced 2026-03-18 07:36:02 +08:00
detect: split waiting logic
This commit is contained in:
@@ -28,7 +28,7 @@ class Detector(object):
|
||||
self.maxlen = config.baud # 1 second of symbols
|
||||
self.max_offset = self.TIMEOUT * config.Fs
|
||||
|
||||
def run(self, samples):
|
||||
def _wait(self, samples):
|
||||
counter = 0
|
||||
bufs = collections.deque([], maxlen=self.maxlen)
|
||||
for offset, buf in common.iterate(samples, self.Nsym, index=True):
|
||||
@@ -43,10 +43,13 @@ class Detector(object):
|
||||
counter = 0
|
||||
|
||||
if counter == self.CARRIER_THRESHOLD:
|
||||
break
|
||||
return offset, bufs
|
||||
else:
|
||||
raise ValueError('No carrier detected')
|
||||
|
||||
def run(self, samples):
|
||||
offset, bufs = self._wait(samples)
|
||||
|
||||
length = (self.CARRIER_THRESHOLD - 1) * self.Nsym
|
||||
begin = offset - length
|
||||
|
||||
|
||||
Reference in New Issue
Block a user