diff --git a/csdr/chain/am.py b/csdr/chain/am.py index 64416e5..e57fa9a 100644 --- a/csdr/chain/am.py +++ b/csdr/chain/am.py @@ -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) diff --git a/csdr/chain/demodulator.py b/csdr/chain/demodulator.py index 0f91336..2960a6f 100644 --- a/csdr/chain/demodulator.py +++ b/csdr/chain/demodulator.py @@ -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) diff --git a/csdr/chain/fm.py b/csdr/chain/fm.py index f5ef6bd..150cce4 100644 --- a/csdr/chain/fm.py +++ b/csdr/chain/fm.py @@ -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) diff --git a/csdr/chain/ssb.py b/csdr/chain/ssb.py index e10ae96..cf94d42 100644 --- a/csdr/chain/ssb.py +++ b/csdr/chain/ssb.py @@ -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(),