add am demodulator chain

This commit is contained in:
Jakob Ketterl 2021-07-19 23:32:03 +02:00
parent f03a6c127e
commit eb76ec4a9f
2 changed files with 31 additions and 3 deletions

View File

@ -37,6 +37,7 @@ from csdr.pipe import Pipe
from csdr.chain.demodulator import DemodulatorChain from csdr.chain.demodulator import DemodulatorChain
from csdr.chain.fm import Fm from csdr.chain.fm import Fm
from csdr.chain.am import Am
import logging import logging
@ -118,9 +119,13 @@ class Dsp(DirewolfConfigSubscriber):
self.pipe_base_path = "{tmp_dir}/openwebrx_pipe_".format(tmp_dir=self.temporary_directory) self.pipe_base_path = "{tmp_dir}/openwebrx_pipe_".format(tmp_dir=self.temporary_directory)
def chain(self, which): def chain(self, which):
if self.pycsdr_enabled and which == "nfm": 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, Fm(self.get_audio_rate()))
return self.pycsdr_chain return self.pycsdr_chain
elif which == "am":
self.pycsdr_chain = DemodulatorChain(self.samp_rate, self.get_audio_rate(), 0.0, Am())
return self.pycsdr_chain
chain = ["nc -v 127.0.0.1 {nc_port}"] chain = ["nc -v 127.0.0.1 {nc_port}"]
chain += ["csdr shift_addfast_cc --fifo {shift_pipe}"] chain += ["csdr shift_addfast_cc --fifo {shift_pipe}"]

23
csdr/chain/am.py Normal file
View File

@ -0,0 +1,23 @@
from csdr.chain import Chain
from csdr.chain.demodulator import Demodulator
from pycsdr.modules import AmDemod, DcBlock, Agc, Convert
from pycsdr.types import Format
class Am(Demodulator):
def __init__(self):
workers = [
AmDemod(),
DcBlock(),
# empty chain as placeholder for the "last decimation"
Chain(),
Agc(Format.FLOAT),
Convert(Format.FLOAT, Format.SHORT),
]
super().__init__(*workers)
def setLastDecimation(self, decimation: Chain):
# TODO: build api to replace workers
# TODO: replace placeholder
pass