mirror of
https://github.com/romanz/amodem.git
synced 2026-03-17 07:05:59 +08:00
dsp: fix Demux sampling handling
This commit is contained in:
@@ -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)
|
||||
|
||||
|
||||
@@ -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)))
|
||||
|
||||
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user