diff --git a/csdr/__init__.py b/csdr/__init__.py index c87fbb1..3e13453 100644 --- a/csdr/__init__.py +++ b/csdr/__init__.py @@ -41,6 +41,7 @@ from csdr.chain.demodulator import DemodulatorChain from csdr.chain.fm import NFm, WFm from csdr.chain.am import Am from csdr.chain.ssb import Ssb +from csdr.chain.digiham import Dstar from csdr.chain.clientaudio import ClientAudioChain import logging @@ -138,6 +139,9 @@ class Dsp(DirewolfConfigSubscriber): elif which == "wfm": self.pycsdr_chain = DemodulatorChain(self.samp_rate, 200000, 0.0, WFm(self.get_audio_rate(), self.wfm_deemphasis_tau)) return self.pycsdr_chain + elif which == "dstar": + self.pycsdr_chain = DemodulatorChain(self.samp_rate, 48000, 0.0, Dstar(self.codecserver)) + return self.pycsdr_chain chain = ["nc -v 127.0.0.1 {nc_port}"] chain += ["csdr shift_addfast_cc --fifo {shift_pipe}"] @@ -741,7 +745,8 @@ class Dsp(DirewolfConfigSubscriber): chain.setInput(self.buffer) output_rate = self.get_hd_output_rate() if self.isHdAudio() else self.get_output_rate() - self.pycsdr_client_chain = ClientAudioChain(self.get_audio_rate(), output_rate, self.audio_compression) + audio_rate = 8000 if self.isDigitalVoice() else self.get_audio_rate() + self.pycsdr_client_chain = ClientAudioChain(chain.getOutputFormat(), audio_rate, output_rate, self.audio_compression) buffer = Buffer(chain.getOutputFormat()) chain.setWriter(buffer) self.pycsdr_client_chain.setInput(buffer) diff --git a/csdr/chain/clientaudio.py b/csdr/chain/clientaudio.py index 1f346f9..5441bc8 100644 --- a/csdr/chain/clientaudio.py +++ b/csdr/chain/clientaudio.py @@ -4,8 +4,10 @@ from pycsdr.types import Format class ClientAudioChain(Chain): - def __init__(self, inputRate: int, clientRate: int, compression: str): + def __init__(self, format: Format, inputRate: int, clientRate: int, compression: str): workers = [] + if format != Format.FLOAT: + workers += [Convert(format, Format.FLOAT)] if inputRate != clientRate: workers += [AudioResampler(inputRate, clientRate)] workers += [Convert(Format.FLOAT, Format.SHORT)] diff --git a/csdr/chain/digiham.py b/csdr/chain/digiham.py new file mode 100644 index 0000000..c3c8a9b --- /dev/null +++ b/csdr/chain/digiham.py @@ -0,0 +1,31 @@ +from csdr.chain import Chain +from pycsdr.modules import FmDemod +from digiham.modules import DstarDecoder, DcBlock, FskDemodulator, DigitalVoiceFilter, MbeSynthesizer, NarrowRrcFilter, NxdnDecoder + + +class Dstar(Chain): + def __init__(self, codecserver: str = ""): + workers = [ + FmDemod(), + DcBlock(), + FskDemodulator(samplesPerSymbol=10), + DstarDecoder(), + MbeSynthesizer(codecserver), + DigitalVoiceFilter() + ] + super().__init__(*workers) + + +class Nxdn(Chain): + def __init__(self, codecserver: str = ""): + workers = [ + FmDemod(), + DcBlock(), + NarrowRrcFilter(), + # todo: switch out with gfsk + FskDemodulator(samplesPerSymbol=20), + NxdnDecoder(), + MbeSynthesizer(codecserver), + DigitalVoiceFilter() + ] + super().__init__(*workers)