2021-07-19 19:04:14 +02:00
|
|
|
from csdr.chain import Chain
|
2021-09-23 18:43:41 +02:00
|
|
|
from abc import ABC, ABCMeta, abstractmethod
|
2021-09-20 16:14:23 +02:00
|
|
|
from pycsdr.modules import Writer
|
2021-07-19 19:04:14 +02:00
|
|
|
|
2024-07-10 13:49:40 +02:00
|
|
|
import logging
|
|
|
|
|
|
|
|
|
|
logger = logging.getLogger(__name__)
|
|
|
|
|
|
2021-07-19 19:04:14 +02:00
|
|
|
|
2021-08-27 17:34:48 +02:00
|
|
|
class FixedAudioRateChain(ABC):
|
|
|
|
|
@abstractmethod
|
2021-08-31 22:46:11 +02:00
|
|
|
def getFixedAudioRate(self) -> int:
|
2021-08-27 17:34:48 +02:00
|
|
|
pass
|
|
|
|
|
|
|
|
|
|
|
2024-07-10 13:49:40 +02:00
|
|
|
class DynamicAudioRateListener(ABC):
|
|
|
|
|
@abstractmethod
|
|
|
|
|
def onAudioRateChange(self, rate: int):
|
|
|
|
|
pass
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class DynamicAudioRateChain(ABC):
|
|
|
|
|
def __init__(self):
|
|
|
|
|
self.listeners = []
|
|
|
|
|
super().__init__()
|
|
|
|
|
|
|
|
|
|
def addListener(self, listener: DynamicAudioRateListener):
|
|
|
|
|
if listener in self.listeners:
|
|
|
|
|
return
|
|
|
|
|
self.listeners.append(listener)
|
|
|
|
|
|
|
|
|
|
def removeListener(self, listener: DynamicAudioRateListener):
|
|
|
|
|
if listener not in self.listeners:
|
|
|
|
|
return
|
|
|
|
|
self.listeners.remove(listener)
|
|
|
|
|
|
|
|
|
|
def fireAudioRateChange(self, rate: int):
|
|
|
|
|
for listener in self.listeners:
|
|
|
|
|
try:
|
|
|
|
|
listener.onAudioRateChange(rate)
|
|
|
|
|
except:
|
|
|
|
|
logger.exception("error while sending audio rate change")
|
|
|
|
|
|
|
|
|
|
@abstractmethod
|
|
|
|
|
def getAudioRate(self) -> int:
|
|
|
|
|
pass
|
|
|
|
|
|
|
|
|
|
|
2021-08-27 17:34:48 +02:00
|
|
|
class FixedIfSampleRateChain(ABC):
|
|
|
|
|
@abstractmethod
|
2021-08-31 22:46:11 +02:00
|
|
|
def getFixedIfSampleRate(self) -> int:
|
|
|
|
|
pass
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class DialFrequencyReceiver(ABC):
|
|
|
|
|
@abstractmethod
|
|
|
|
|
def setDialFrequency(self, frequency: int) -> None:
|
|
|
|
|
pass
|
2021-08-27 17:34:48 +02:00
|
|
|
|
|
|
|
|
|
|
|
|
|
# marker interface
|
|
|
|
|
class HdAudio:
|
|
|
|
|
pass
|
2021-09-20 16:14:23 +02:00
|
|
|
|
|
|
|
|
|
|
|
|
|
class MetaProvider(ABC):
|
|
|
|
|
@abstractmethod
|
|
|
|
|
def setMetaWriter(self, writer: Writer) -> None:
|
|
|
|
|
pass
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class SlotFilterChain(ABC):
|
|
|
|
|
@abstractmethod
|
|
|
|
|
def setSlotFilter(self, filter: int) -> None:
|
|
|
|
|
pass
|
2021-09-23 18:43:41 +02:00
|
|
|
|
|
|
|
|
|
|
|
|
|
class SecondarySelectorChain(ABC):
|
|
|
|
|
def getBandwidth(self) -> float:
|
|
|
|
|
pass
|
|
|
|
|
|
|
|
|
|
|
2021-09-27 17:46:19 +02:00
|
|
|
class DeemphasisTauChain(ABC):
|
|
|
|
|
@abstractmethod
|
|
|
|
|
def setDeemphasisTau(self, tau: float) -> None:
|
|
|
|
|
pass
|
|
|
|
|
|
|
|
|
|
|
2024-01-18 16:59:10 +01:00
|
|
|
class RdsChain(ABC):
|
|
|
|
|
@abstractmethod
|
|
|
|
|
def setRdsRbds(self, rdsRbds: bool) -> None:
|
|
|
|
|
pass
|
|
|
|
|
|
|
|
|
|
|
2024-01-25 00:10:25 +01:00
|
|
|
class DabServiceSelector(ABC):
|
|
|
|
|
@abstractmethod
|
|
|
|
|
def setDabServiceId(self, serviceId: int) -> None:
|
|
|
|
|
pass
|
|
|
|
|
|
|
|
|
|
|
2021-09-23 18:43:41 +02:00
|
|
|
class BaseDemodulatorChain(Chain):
|
|
|
|
|
def supportsSquelch(self) -> bool:
|
|
|
|
|
return True
|
|
|
|
|
|
|
|
|
|
def setSampleRate(self, sampleRate: int) -> None:
|
|
|
|
|
pass
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class SecondaryDemodulator(Chain):
|
|
|
|
|
def supportsSquelch(self) -> bool:
|
|
|
|
|
return True
|
|
|
|
|
|
|
|
|
|
def setSampleRate(self, sampleRate: int) -> None:
|
|
|
|
|
pass
|
|
|
|
|
|
2023-08-24 22:00:59 +02:00
|
|
|
def isSecondaryFftShown(self):
|
|
|
|
|
return True
|
|
|
|
|
|
2021-09-23 18:43:41 +02:00
|
|
|
|
|
|
|
|
class ServiceDemodulator(SecondaryDemodulator, FixedAudioRateChain, metaclass=ABCMeta):
|
|
|
|
|
pass
|
2021-12-13 13:26:47 +01:00
|
|
|
|
|
|
|
|
|
|
|
|
|
class DemodulatorError(Exception):
|
|
|
|
|
pass
|