mirror of
https://github.com/romanz/amodem.git
synced 2026-03-27 05:19:04 +08:00
support concurrent multiple frequencies demodulation.
This commit is contained in:
4
drift.py
4
drift.py
@@ -13,9 +13,9 @@ def main():
|
||||
S = []
|
||||
Y = []
|
||||
|
||||
symbols = loop.FreqLoop(x, f0)
|
||||
prefix = 100
|
||||
for s in symbols:
|
||||
symbols = loop.FreqLoop(x, [f0])
|
||||
for s, in symbols:
|
||||
S.append(s)
|
||||
if len(S) > prefix:
|
||||
symbols.correct(s, np.mean(S[:prefix]))
|
||||
|
||||
12
loop.py
12
loop.py
@@ -1,4 +1,5 @@
|
||||
import numpy as np
|
||||
import itertools
|
||||
|
||||
import recv
|
||||
import sampling
|
||||
@@ -20,9 +21,14 @@ class Filter(object):
|
||||
return y
|
||||
|
||||
class FreqLoop(object):
|
||||
def __init__(self, x, freq):
|
||||
def __init__(self, x, freqs):
|
||||
self.sampler = sampling.Sampler(x, sampling.Interpolator())
|
||||
self.symbols = recv.extract_symbols(self.sampler, freq)
|
||||
self.gens = []
|
||||
|
||||
gens = itertools.tee(self.sampler, len(freqs))
|
||||
for freq, gen in zip(freqs, gens):
|
||||
self.gens.append( recv.extract_symbols(self.sampler, freq) )
|
||||
|
||||
Kp, Ki = 0.2, 0.01
|
||||
b = np.array([1, -1])*Kp + np.array([0.5, 0.5])*Ki
|
||||
self.filt = Filter(b=b, a=[1])
|
||||
@@ -35,4 +41,4 @@ class FreqLoop(object):
|
||||
self.sampler.correct(offset=self.correction)
|
||||
|
||||
def __iter__(self):
|
||||
return iter(self.symbols)
|
||||
return itertools.izip(*self.gens)
|
||||
|
||||
Reference in New Issue
Block a user