refactor
This commit is contained in:
parent
42b315ef86
commit
4c1777dc19
@ -1,4 +1,4 @@
|
||||
from csdr.chain.demodulator import BaseDemodulatorChain
|
||||
from csdr.chain.demodulator import BaseDemodulatorChain, FixedIfSampleRateChain, HdAudio
|
||||
from pycsdr.modules import AmDemod, DcBlock, FmDemod, Limit, NfmDeemphasis, Agc, WfmDeemphasis, FractionalDecimator, RealPart
|
||||
from pycsdr.types import Format, AgcProfile
|
||||
|
||||
@ -31,7 +31,7 @@ class NFm(BaseDemodulatorChain):
|
||||
super().__init__(workers)
|
||||
|
||||
|
||||
class WFm(BaseDemodulatorChain):
|
||||
class WFm(BaseDemodulatorChain, FixedIfSampleRateChain, HdAudio):
|
||||
def __init__(self, sampleRate: int, tau: float):
|
||||
workers = [
|
||||
FmDemod(),
|
||||
|
@ -1,12 +1,27 @@
|
||||
from csdr.chain import Chain
|
||||
from abc import ABC, abstractmethod
|
||||
|
||||
|
||||
class BaseDemodulatorChain(Chain):
|
||||
def getFixedIfSampleRate(self):
|
||||
return None
|
||||
|
||||
def getFixedAudioRate(self):
|
||||
return None
|
||||
|
||||
def supportsSquelch(self):
|
||||
return True
|
||||
|
||||
|
||||
class FixedAudioRateChain(ABC):
|
||||
@abstractmethod
|
||||
def getFixedAudioRate(self):
|
||||
pass
|
||||
|
||||
|
||||
class FixedIfSampleRateChain(ABC):
|
||||
@abstractmethod
|
||||
def getFixedIfSampleRate(self):
|
||||
return self.fixedIfSampleRate
|
||||
|
||||
|
||||
# marker interface
|
||||
class HdAudio:
|
||||
pass
|
||||
|
@ -1,11 +1,11 @@
|
||||
from csdr.chain.demodulator import BaseDemodulatorChain
|
||||
from csdr.chain.demodulator import BaseDemodulatorChain, FixedAudioRateChain, FixedIfSampleRateChain
|
||||
from pycsdr.modules import FmDemod, Agc, Writer
|
||||
from pycsdr.types import Format
|
||||
from digiham.modules import DstarDecoder, DcBlock, FskDemodulator, GfskDemodulator, DigitalVoiceFilter, MbeSynthesizer, NarrowRrcFilter, NxdnDecoder, DmrDecoder, WideRrcFilter, YsfDecoder
|
||||
from digiham.ambe import Modes
|
||||
|
||||
|
||||
class DigihamChain(BaseDemodulatorChain):
|
||||
class DigihamChain(BaseDemodulatorChain, FixedIfSampleRateChain, FixedAudioRateChain):
|
||||
def __init__(self, fskDemodulator, decoder, mbeMode, filter=None, codecserver: str = ""):
|
||||
self.decoder = decoder
|
||||
if codecserver is None:
|
||||
|
17
owrx/dsp.py
17
owrx/dsp.py
@ -7,10 +7,9 @@ from owrx.source import SdrSourceEventClient, SdrSourceState, SdrClientClass
|
||||
from owrx.property import PropertyStack, PropertyLayer, PropertyValidator
|
||||
from owrx.property.validators import OrValidator, RegexValidator, BoolValidator
|
||||
from owrx.modes import Modes
|
||||
from owrx.config.core import CoreConfig
|
||||
from csdr.output import Output
|
||||
from csdr.chain import Chain
|
||||
from csdr.chain.demodulator import BaseDemodulatorChain
|
||||
from csdr.chain.demodulator import BaseDemodulatorChain, FixedIfSampleRateChain, FixedAudioRateChain
|
||||
from csdr.chain.selector import Selector
|
||||
from csdr.chain.clientaudio import ClientAudioChain
|
||||
from csdr.chain.analog import NFm, WFm, Am, Ssb
|
||||
@ -53,15 +52,13 @@ class ClientDemodulatorChain(Chain):
|
||||
|
||||
self.demodulator = demodulator
|
||||
|
||||
ifRate = self.demodulator.getFixedIfSampleRate()
|
||||
if ifRate is not None:
|
||||
self.selector.setOutputRate(ifRate)
|
||||
if isinstance(self.demodulator, FixedIfSampleRateChain):
|
||||
self.selector.setOutputRate(self.demodulator.getFixedIfSampleRate())
|
||||
else:
|
||||
self.selector.setOutputRate(self.outputRate)
|
||||
|
||||
audioRate = self.demodulator.getFixedAudioRate()
|
||||
if audioRate is not None:
|
||||
self.clientAudioChain.setInputRate(audioRate)
|
||||
if isinstance(self.demodulator, FixedAudioRateChain):
|
||||
self.clientAudioChain.setInputRate(self.demodulator.getFixedAudioRate())
|
||||
else:
|
||||
self.clientAudioChain.setInputRate(self.outputRate)
|
||||
|
||||
@ -102,9 +99,9 @@ class ClientDemodulatorChain(Chain):
|
||||
return
|
||||
|
||||
self.outputRate = outputRate
|
||||
if self.demodulator.getFixedIfSampleRate() is None:
|
||||
if not isinstance(self.demodulator, FixedIfSampleRateChain):
|
||||
self.selector.setOutputRate(outputRate)
|
||||
if self.demodulator.getFixedAudioRate() is None:
|
||||
if not isinstance(self.demodulator, FixedAudioRateChain):
|
||||
self.clientAudioChain.setClientRate(outputRate)
|
||||
|
||||
def setPowerWriter(self, writer: Writer) -> None:
|
||||
|
Loading…
Reference in New Issue
Block a user