openwebrx-clone/csdr/chain/digimodes.py

64 lines
2.0 KiB
Python
Raw Normal View History

2021-08-31 20:46:11 +00:00
from csdr.chain.demodulator import SecondaryDemodulator, FixedAudioRateChain, DialFrequencyReceiver
2021-08-31 14:54:37 +00:00
from owrx.audio.chopper import AudioChopper
2021-09-06 13:05:33 +00:00
from owrx.aprs.kiss import KissDeframer
from owrx.aprs import Ax25Parser, AprsParser
from pycsdr.modules import Convert, FmDemod
2021-08-31 14:54:37 +00:00
from pycsdr.types import Format
2021-09-06 13:05:33 +00:00
from owrx.aprs.module import DirewolfModule
2021-09-06 18:00:14 +00:00
from digiham.modules import FskDemodulator, PocsagDecoder
from owrx.pocsag import PocsagParser
2021-08-31 14:54:37 +00:00
2021-08-31 20:46:11 +00:00
class AudioChopperDemodulator(SecondaryDemodulator, FixedAudioRateChain, DialFrequencyReceiver):
2021-08-31 14:54:37 +00:00
# TODO parser typing
def __init__(self, mode: str, parser):
2021-08-31 20:46:11 +00:00
self.chopper = AudioChopper(mode, parser)
workers = [Convert(Format.FLOAT, Format.SHORT), self.chopper]
2021-08-31 14:54:37 +00:00
super().__init__(workers)
def getFixedAudioRate(self):
return 12000
2021-08-31 20:46:11 +00:00
def setDialFrequency(self, frequency: int) -> None:
self.chopper.setDialFrequency(frequency)
2021-09-06 13:05:33 +00:00
class PacketDemodulator(SecondaryDemodulator, FixedAudioRateChain, DialFrequencyReceiver):
def __init__(self, service: bool = False):
self.parser = AprsParser()
workers = [
FmDemod(),
Convert(Format.FLOAT, Format.SHORT),
DirewolfModule(service=service),
KissDeframer(),
Ax25Parser(),
self.parser,
]
super().__init__(workers)
def supportsSquelch(self) -> bool:
return False
def getFixedAudioRate(self) -> int:
return 48000
def setDialFrequency(self, frequency: int) -> None:
self.parser.setDialFrequency(frequency)
2021-09-06 18:00:14 +00:00
class PocsagDemodulator(SecondaryDemodulator, FixedAudioRateChain):
def __init__(self):
workers = [
FmDemod(),
FskDemodulator(samplesPerSymbol=40, invert=True),
PocsagDecoder(),
PocsagParser(),
]
super().__init__(workers)
def supportsSquelch(self) -> bool:
return False
def getFixedAudioRate(self) -> int:
return 48000