support concurrent multiple frequencies demodulation.

This commit is contained in:
Roman Zeyde
2014-07-05 09:48:03 +03:00
parent 8a1d8f33bd
commit 933e0f7cfc
2 changed files with 11 additions and 5 deletions

View File

@@ -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
View File

@@ -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)