mirror of
https://github.com/romanz/amodem.git
synced 2026-04-20 21:26:39 +08:00
recv: remove saturation detection
This commit is contained in:
@@ -5,17 +5,6 @@ import logging
|
|||||||
log = logging.getLogger(__name__)
|
log = logging.getLogger(__name__)
|
||||||
|
|
||||||
scaling = 32000.0 # out of 2**15
|
scaling = 32000.0 # out of 2**15
|
||||||
SATURATION_THRESHOLD = (2**15 - 1) / scaling
|
|
||||||
|
|
||||||
|
|
||||||
class SaturationError(ValueError):
|
|
||||||
pass
|
|
||||||
|
|
||||||
|
|
||||||
def check_saturation(x):
|
|
||||||
peak = np.max(np.abs(x))
|
|
||||||
if peak >= SATURATION_THRESHOLD:
|
|
||||||
raise SaturationError(peak)
|
|
||||||
|
|
||||||
|
|
||||||
def load(fileobj):
|
def load(fileobj):
|
||||||
|
|||||||
@@ -217,8 +217,6 @@ def main(config, src, dst, pylab=None):
|
|||||||
log.debug('Skipping %.3f seconds', config.skip_start)
|
log.debug('Skipping %.3f seconds', config.skip_start)
|
||||||
common.take(signal, to_skip)
|
common.take(signal, to_skip)
|
||||||
|
|
||||||
reader.check = common.check_saturation
|
|
||||||
|
|
||||||
detector = detect.Detector(config=config)
|
detector = detect.Detector(config=config)
|
||||||
receiver = Receiver(config=config, pylab=pylab)
|
receiver = Receiver(config=config, pylab=pylab)
|
||||||
success = False
|
success = False
|
||||||
|
|||||||
@@ -12,7 +12,6 @@ class Reader(object):
|
|||||||
self.timeout = timeout
|
self.timeout = timeout
|
||||||
self.wait = wait
|
self.wait = wait
|
||||||
self.total = 0
|
self.total = 0
|
||||||
self.check = None
|
|
||||||
|
|
||||||
def __iter__(self):
|
def __iter__(self):
|
||||||
return self
|
return self
|
||||||
@@ -37,10 +36,7 @@ class Reader(object):
|
|||||||
block.extend(data)
|
block.extend(data)
|
||||||
|
|
||||||
if len(block) == self.bufsize:
|
if len(block) == self.bufsize:
|
||||||
values = self.data_type(block)
|
return self.data_type(block)
|
||||||
if self.check:
|
|
||||||
self.check(values)
|
|
||||||
return values
|
|
||||||
|
|
||||||
time.sleep(self.wait)
|
time.sleep(self.wait)
|
||||||
|
|
||||||
|
|||||||
@@ -47,15 +47,6 @@ def test_dumps_loads():
|
|||||||
assert all(x == y)
|
assert all(x == y)
|
||||||
|
|
||||||
|
|
||||||
def test_saturation():
|
|
||||||
x = np.array([1, -1, 1, -1]) * 1e10
|
|
||||||
try:
|
|
||||||
common.check_saturation(x)
|
|
||||||
assert False
|
|
||||||
except common.SaturationError as e:
|
|
||||||
assert e.args == (max(x),)
|
|
||||||
|
|
||||||
|
|
||||||
def test_izip():
|
def test_izip():
|
||||||
x = range(10)
|
x = range(10)
|
||||||
y = range(-10, 0)
|
y = range(-10, 0)
|
||||||
|
|||||||
Reference in New Issue
Block a user