2021-08-27 15:34:48 +00:00
|
|
|
from csdr.chain.demodulator import BaseDemodulatorChain, FixedIfSampleRateChain, HdAudio
|
2021-08-23 12:25:28 +00:00
|
|
|
from pycsdr.modules import AmDemod, DcBlock, FmDemod, Limit, NfmDeemphasis, Agc, WfmDeemphasis, FractionalDecimator, RealPart
|
|
|
|
from pycsdr.types import Format, AgcProfile
|
|
|
|
|
|
|
|
|
|
|
|
class Am(BaseDemodulatorChain):
|
|
|
|
def __init__(self):
|
|
|
|
agc = Agc(Format.FLOAT)
|
|
|
|
agc.setProfile(AgcProfile.SLOW)
|
|
|
|
agc.setInitialGain(200)
|
|
|
|
workers = [
|
|
|
|
AmDemod(),
|
|
|
|
DcBlock(),
|
|
|
|
agc,
|
|
|
|
]
|
|
|
|
|
|
|
|
super().__init__(workers)
|
|
|
|
|
|
|
|
|
|
|
|
class NFm(BaseDemodulatorChain):
|
|
|
|
def __init__(self, sampleRate: int):
|
2021-09-06 13:05:33 +00:00
|
|
|
self.sampleRate = sampleRate
|
2021-08-23 12:25:28 +00:00
|
|
|
agc = Agc(Format.FLOAT)
|
|
|
|
agc.setProfile(AgcProfile.SLOW)
|
|
|
|
agc.setMaxGain(3)
|
|
|
|
workers = [
|
|
|
|
FmDemod(),
|
|
|
|
Limit(),
|
|
|
|
NfmDeemphasis(sampleRate),
|
|
|
|
agc,
|
|
|
|
]
|
|
|
|
super().__init__(workers)
|
|
|
|
|
2021-09-06 13:05:33 +00:00
|
|
|
def setSampleRate(self, sampleRate: int) -> None:
|
|
|
|
if sampleRate == self.sampleRate:
|
|
|
|
return
|
|
|
|
self.sampleRate = sampleRate
|
|
|
|
self.replace(2, NfmDeemphasis(sampleRate))
|
|
|
|
|
2021-08-23 12:25:28 +00:00
|
|
|
|
2021-08-27 15:34:48 +00:00
|
|
|
class WFm(BaseDemodulatorChain, FixedIfSampleRateChain, HdAudio):
|
2021-08-23 12:25:28 +00:00
|
|
|
def __init__(self, sampleRate: int, tau: float):
|
|
|
|
workers = [
|
|
|
|
FmDemod(),
|
|
|
|
Limit(),
|
|
|
|
FractionalDecimator(Format.FLOAT, 200000.0 / sampleRate, prefilter=True),
|
|
|
|
WfmDeemphasis(sampleRate, tau),
|
|
|
|
]
|
|
|
|
super().__init__(workers)
|
|
|
|
|
|
|
|
def getFixedIfSampleRate(self):
|
|
|
|
return 200000
|
|
|
|
|
|
|
|
|
|
|
|
class Ssb(BaseDemodulatorChain):
|
|
|
|
def __init__(self):
|
|
|
|
workers = [
|
|
|
|
RealPart(),
|
|
|
|
Agc(Format.FLOAT),
|
|
|
|
]
|
|
|
|
super().__init__(workers)
|