implement WFM with the new chain elements

This commit is contained in:
Jakob Ketterl 2021-07-25 22:44:53 +02:00
parent 459a99cbf8
commit 75aac5969a
2 changed files with 22 additions and 6 deletions

View File

@ -38,7 +38,7 @@ from csdr.pipe import Pipe
from pycsdr.modules import Buffer
from pycsdr.types import Format
from csdr.chain.demodulator import DemodulatorChain
from csdr.chain.fm import Fm
from csdr.chain.fm import NFm, WFm
from csdr.chain.am import Am
from csdr.chain.ssb import Ssb
from csdr.chain.clientaudio import ClientAudioChain
@ -127,7 +127,7 @@ class Dsp(DirewolfConfigSubscriber):
def chain(self, which):
if self.pycsdr_enabled:
if which == "nfm":
self.pycsdr_chain = DemodulatorChain(self.samp_rate, self.get_audio_rate(), 0.0, Fm(self.get_audio_rate()))
self.pycsdr_chain = DemodulatorChain(self.samp_rate, self.get_audio_rate(), 0.0, NFm(self.get_audio_rate()))
return self.pycsdr_chain
elif which == "am":
self.pycsdr_chain = DemodulatorChain(self.samp_rate, self.get_audio_rate(), 0.0, Am())
@ -135,6 +135,9 @@ class Dsp(DirewolfConfigSubscriber):
elif which == "ssb":
self.pycsdr_chain = DemodulatorChain(self.samp_rate, self.get_audio_rate(), 0.0, Ssb())
return self.pycsdr_chain
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
chain = ["nc -v 127.0.0.1 {nc_port}"]
chain += ["csdr shift_addfast_cc --fifo {shift_pipe}"]
@ -737,7 +740,8 @@ class Dsp(DirewolfConfigSubscriber):
chain.setInput(self.buffer)
self.pycsdr_client_chain = ClientAudioChain(self.get_audio_rate(), self.get_output_rate(), self.audio_compression)
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)
buffer = Buffer(chain.getOutputFormat())
chain.setWriter(buffer)
self.pycsdr_client_chain.setInput(buffer)
@ -745,7 +749,8 @@ class Dsp(DirewolfConfigSubscriber):
outputBuffer = Buffer(self.pycsdr_client_chain.getOutputFormat())
self.pycsdr_client_chain.setWriter(outputBuffer)
self.pycsdr_reader = outputBuffer.getReader()
self.output.send_output("audio", self.pycsdr_reader.read)
audio_type = "hd_audio" if self.isHdAudio() else "audio"
self.output.send_output(audio_type, self.pycsdr_reader.read)
powerBuffer = Buffer(Format.FLOAT)
chain.setPowerWriter(powerBuffer)

View File

@ -1,9 +1,9 @@
from csdr.chain import Chain
from pycsdr.modules import FmDemod, Limit, NfmDeemphasis, Agc, Convert
from pycsdr.modules import FmDemod, Limit, NfmDeemphasis, Agc, WfmDeemphasis, FractionalDecimator
from pycsdr.types import Format, AgcProfile
class Fm(Chain):
class NFm(Chain):
def __init__(self, sampleRate: int):
agc = Agc(Format.FLOAT)
agc.setProfile(AgcProfile.SLOW)
@ -15,3 +15,14 @@ class Fm(Chain):
agc,
]
super().__init__(*workers)
class WFm(Chain):
def __init__(self, sampleRate: int, tau: float):
workers = [
FmDemod(),
Limit(),
FractionalDecimator(Format.FLOAT, 200000.0 / sampleRate, prefilter=True),
WfmDeemphasis(sampleRate, tau),
]
super().__init__(*workers)