diff --git a/amodem/dsp.py b/amodem/dsp.py index b090980..b12554a 100644 --- a/amodem/dsp.py +++ b/amodem/dsp.py @@ -107,8 +107,8 @@ class QAM(object): class Demux(object): - def __init__(self, src, freqs, sampler=None): - self.sampler = sampling.Sampler(src) if sampler is None else sampler + def __init__(self, sampler, freqs): + self.sampler = sampler self.filters = [exp_iwt(-f, Nsym) / (0.5*Nsym) for f in freqs] self.filters = np.array(self.filters) diff --git a/amodem/equalizer.py b/amodem/equalizer.py index bdf71b7..99b1c18 100644 --- a/amodem/equalizer.py +++ b/amodem/equalizer.py @@ -28,7 +28,7 @@ def modulator(symbols, carriers=modem.carriers): def demodulator(signal, size): signal = itertools.chain(signal, itertools.repeat(0)) - symbols = dsp.Demux(signal, config.frequencies) + symbols = dsp.Demux(sampling.Sampler(signal), config.frequencies) return np.array(list(itertools.islice(symbols, size))) diff --git a/tests/test_dsp.py b/tests/test_dsp.py index 4c8022c..d586c9e 100644 --- a/tests/test_dsp.py +++ b/tests/test_dsp.py @@ -5,6 +5,7 @@ from numpy.linalg import norm from amodem import dsp from amodem import config +from amodem import sampling def test_qam(): @@ -93,6 +94,6 @@ def test_demux(): carriers = [dsp.exp_iwt(f, config.Nsym) for f in freqs] syms = [3, 2j] sig = np.dot(syms, carriers) - res = dsp.Demux(sig.real, freqs) + res = dsp.Demux(sampling.Sampler(sig.real), freqs) res = np.array(list(res)) assert np.max(np.abs(res - syms)) < 1e-12