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