apply all decimation in comples to simplify the chain

This commit is contained in:
Jakob Ketterl 2021-07-24 22:25:41 +02:00
parent ab99b8e476
commit c50da15bfd
4 changed files with 12 additions and 34 deletions

View File

@ -1,10 +1,9 @@
from csdr.chain import Chain
from csdr.chain.demodulator import Demodulator
from pycsdr.modules import AmDemod, DcBlock, Agc, Convert
from pycsdr.types import Format, AgcProfile
class Am(Demodulator):
class Am(Chain):
def __init__(self):
agc = Agc(Format.FLOAT)
agc.setProfile(AgcProfile.SLOW)
@ -12,13 +11,8 @@ class Am(Demodulator):
workers = [
AmDemod(),
DcBlock(),
# empty chain as placeholder for the "last decimation"
Chain(),
agc,
Convert(Format.FLOAT, Format.SHORT),
]
super().__init__(*workers)
def setLastDecimation(self, decimation: Chain):
self.replace(2, decimation)

View File

@ -1,16 +1,10 @@
from csdr.chain import Chain
from pycsdr.modules import Module, Shift, FirDecimate, Bandpass, Squelch, FractionalDecimator
from abc import ABCMeta, abstractmethod
class Demodulator(Chain, metaclass=ABCMeta):
@abstractmethod
def setLastDecimation(self, decimation: Module):
pass
from pycsdr.modules import Shift, FirDecimate, Bandpass, Squelch, FractionalDecimator
from pycsdr.types import Format
class DemodulatorChain(Chain):
def __init__(self, samp_rate: int, audioRate: int, shiftRate: float, demodulator: Demodulator):
def __init__(self, samp_rate: int, audioRate: int, shiftRate: float, demodulator: Chain):
self.shift = Shift(shiftRate)
decimation, fraction = self._getDecimation(samp_rate, audioRate)
@ -23,16 +17,12 @@ class DemodulatorChain(Chain):
self.squelch = Squelch(5)
if fraction != 1.0:
demodulator.setLastDecimation(FractionalDecimator(fraction))
workers = [self.shift, self.decimation]
workers = [
self.shift,
self.decimation,
self.bandpass,
self.squelch,
demodulator
]
if fraction != 1.0:
workers += [FractionalDecimator(Format.COMPLEX_FLOAT, fraction)]
workers += [self.bandpass, self.squelch, demodulator]
super().__init__(*workers)

View File

@ -1,9 +1,9 @@
from csdr.chain.demodulator import Demodulator, Chain
from csdr.chain import Chain
from pycsdr.modules import FmDemod, Limit, NfmDeemphasis, Agc, Convert
from pycsdr.types import Format, AgcProfile
class Fm(Demodulator):
class Fm(Chain):
def __init__(self, sampleRate: int):
agc = Agc(Format.FLOAT)
agc.setProfile(AgcProfile.SLOW)
@ -11,13 +11,8 @@ class Fm(Demodulator):
workers = [
FmDemod(),
Limit(),
# empty chain as placeholder for the "last decimation"
Chain(),
NfmDeemphasis(sampleRate),
agc,
Convert(Format.FLOAT, Format.SHORT),
]
super().__init__(*workers)
def setLastDecimation(self, decimation: Chain):
self.replace(2, decimation)

View File

@ -1,10 +1,9 @@
from csdr.chain import Chain
from csdr.chain.demodulator import Demodulator
from pycsdr.modules import RealPart, Agc, Convert
from pycsdr.types import Format
class Ssb(Demodulator):
class Ssb(Chain):
def __init__(self):
workers = [
RealPart(),