restore aprs functionality
This commit is contained in:
@ -1,5 +1,6 @@
|
||||
from csdr.module import Module
|
||||
from pycsdr.modules import Buffer
|
||||
from pycsdr.types import Format
|
||||
from typing import Union, Callable
|
||||
|
||||
|
||||
@ -133,7 +134,13 @@ class Chain(Module):
|
||||
self.clientReader.stop()
|
||||
self.clientReader = None
|
||||
|
||||
def getOutputFormat(self):
|
||||
def getInputFormat(self) -> Format:
|
||||
if self.workers:
|
||||
return self.workers[0].getInputFormat()
|
||||
else:
|
||||
raise BufferError("getInputFormat on empty chain")
|
||||
|
||||
def getOutputFormat(self) -> Format:
|
||||
if self.workers:
|
||||
return self.workers[-1].getOutputFormat()
|
||||
else:
|
||||
|
@ -19,6 +19,7 @@ class Am(BaseDemodulatorChain):
|
||||
|
||||
class NFm(BaseDemodulatorChain):
|
||||
def __init__(self, sampleRate: int):
|
||||
self.sampleRate = sampleRate
|
||||
agc = Agc(Format.FLOAT)
|
||||
agc.setProfile(AgcProfile.SLOW)
|
||||
agc.setMaxGain(3)
|
||||
@ -30,6 +31,12 @@ class NFm(BaseDemodulatorChain):
|
||||
]
|
||||
super().__init__(workers)
|
||||
|
||||
def setSampleRate(self, sampleRate: int) -> None:
|
||||
if sampleRate == self.sampleRate:
|
||||
return
|
||||
self.sampleRate = sampleRate
|
||||
self.replace(2, NfmDeemphasis(sampleRate))
|
||||
|
||||
|
||||
class WFm(BaseDemodulatorChain, FixedIfSampleRateChain, HdAudio):
|
||||
def __init__(self, sampleRate: int, tau: float):
|
||||
|
@ -6,9 +6,13 @@ class BaseDemodulatorChain(Chain):
|
||||
def supportsSquelch(self) -> bool:
|
||||
return True
|
||||
|
||||
def setSampleRate(self, sampleRate: int) -> None:
|
||||
pass
|
||||
|
||||
|
||||
class SecondaryDemodulator(Chain):
|
||||
pass
|
||||
def supportsSquelch(self) -> bool:
|
||||
return True
|
||||
|
||||
|
||||
class FixedAudioRateChain(ABC):
|
||||
|
@ -1,7 +1,10 @@
|
||||
from csdr.chain.demodulator import SecondaryDemodulator, FixedAudioRateChain, DialFrequencyReceiver
|
||||
from owrx.audio.chopper import AudioChopper
|
||||
from pycsdr.modules import Agc, Convert
|
||||
from owrx.aprs.kiss import KissDeframer
|
||||
from owrx.aprs import Ax25Parser, AprsParser
|
||||
from pycsdr.modules import Convert, FmDemod
|
||||
from pycsdr.types import Format
|
||||
from owrx.aprs.module import DirewolfModule
|
||||
|
||||
|
||||
class AudioChopperDemodulator(SecondaryDemodulator, FixedAudioRateChain, DialFrequencyReceiver):
|
||||
@ -16,3 +19,26 @@ class AudioChopperDemodulator(SecondaryDemodulator, FixedAudioRateChain, DialFre
|
||||
|
||||
def setDialFrequency(self, frequency: int) -> None:
|
||||
self.chopper.setDialFrequency(frequency)
|
||||
|
||||
|
||||
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)
|
||||
|
@ -62,7 +62,7 @@ class Decimator(Chain):
|
||||
|
||||
|
||||
class Selector(Chain):
|
||||
def __init__(self, inputRate: int, outputRate: int, shiftRate: float):
|
||||
def __init__(self, inputRate: int, outputRate: int, shiftRate: float, withSquelch: bool = True):
|
||||
self.outputRate = outputRate
|
||||
|
||||
self.shift = Shift(shiftRate)
|
||||
@ -73,12 +73,14 @@ class Selector(Chain):
|
||||
self.bandpassCutoffs = None
|
||||
self.setBandpass(-4000, 4000)
|
||||
|
||||
self.readings_per_second = 4
|
||||
# s-meter readings are available every 1024 samples
|
||||
# the reporting interval is measured in those 1024-sample blocks
|
||||
self.squelch = Squelch(5, int(outputRate / (self.readings_per_second * 1024)))
|
||||
workers = [self.shift, self.decimation, self.bandpass]
|
||||
|
||||
workers = [self.shift, self.decimation, self.bandpass, self.squelch]
|
||||
if withSquelch:
|
||||
self.readings_per_second = 4
|
||||
# s-meter readings are available every 1024 samples
|
||||
# the reporting interval is measured in those 1024-sample blocks
|
||||
self.squelch = Squelch(5, int(outputRate / (self.readings_per_second * 1024)))
|
||||
workers += [self.squelch]
|
||||
|
||||
super().__init__(workers)
|
||||
|
||||
|
Reference in New Issue
Block a user