move fft calculations to dsp class
This commit is contained in:
parent
efe80a75f5
commit
40c07ebb57
@ -4,11 +4,16 @@ from pycsdr import Fft, LogAveragePower, FftExchangeSides, CompressFftAdpcm
|
||||
|
||||
class FftChain(Chain):
|
||||
def __init__(self, fft_size, fft_block_size, fft_averages, fft_compression):
|
||||
self.fft = Fft(size=fft_size, every_n_samples=int(fft_block_size))
|
||||
self.logAveragePower = LogAveragePower(add_db=-70, fft_size=fft_size, avg_number=fft_averages)
|
||||
self.fftExchangeSides = FftExchangeSides(fft_size=fft_size)
|
||||
workers = [
|
||||
Fft(size=fft_size, every_n_samples=int(fft_block_size)),
|
||||
LogAveragePower(add_db=-70, fft_size=fft_size, avg_number=fft_averages),
|
||||
FftExchangeSides(fft_size=fft_size),
|
||||
self.fft,
|
||||
self.logAveragePower,
|
||||
self.fftExchangeSides,
|
||||
]
|
||||
self.compressFftAdpcm = None
|
||||
if fft_compression == "adpcm":
|
||||
workers += [CompressFftAdpcm(fft_size=fft_size)]
|
||||
self.compressFftAdpcm = CompressFftAdpcm(fft_size=fft_size)
|
||||
workers += [self.compressFftAdpcm]
|
||||
super().__init__(*workers)
|
||||
|
25
csdr/csdr.py
25
csdr/csdr.py
@ -112,6 +112,7 @@ class dsp(object):
|
||||
self.secondary_fft_size = 1024
|
||||
self.secondary_process_fft = None
|
||||
self.secondary_process_demod = None
|
||||
self.fft_voverlap_factor = 0
|
||||
self.pipe_names = {
|
||||
"bpf_pipe": Pipe.WRITE,
|
||||
"shift_pipe": Pipe.WRITE,
|
||||
@ -523,8 +524,11 @@ class dsp(object):
|
||||
return (self.secondary_fft_size / 2) + (10 / 2)
|
||||
|
||||
def set_samp_rate(self, samp_rate):
|
||||
if self.samp_rate == samp_rate:
|
||||
return
|
||||
self.samp_rate = samp_rate
|
||||
self.calculate_decimation()
|
||||
self.update_fft_averages()
|
||||
if self.running:
|
||||
self.restart()
|
||||
|
||||
@ -639,14 +643,35 @@ class dsp(object):
|
||||
return self.demodulator
|
||||
|
||||
def set_fft_size(self, fft_size):
|
||||
if self.fft_size == fft_size:
|
||||
return
|
||||
self.fft_size = fft_size
|
||||
self.update_fft_averages()
|
||||
self.restart()
|
||||
|
||||
def set_fft_fps(self, fft_fps):
|
||||
if self.fft_fps == fft_fps:
|
||||
return
|
||||
self.fft_fps = fft_fps
|
||||
self.update_fft_averages()
|
||||
self.restart()
|
||||
|
||||
def set_fft_voverlap_factor(self, fft_voverlap_factor):
|
||||
if self.fft_voverlap_factor == fft_voverlap_factor:
|
||||
return
|
||||
self.fft_voverlap_factor = fft_voverlap_factor
|
||||
self.update_fft_averages()
|
||||
|
||||
def update_fft_averages(self):
|
||||
self.set_fft_averages(
|
||||
int(round(1.0 * self.samp_rate / self.fft_size / self.fft_fps / (1.0 - self.fft_voverlap_factor)))
|
||||
if self.fft_voverlap_factor > 0
|
||||
else 0
|
||||
)
|
||||
|
||||
def set_fft_averages(self, fft_averages):
|
||||
if self.fft_averages == fft_averages:
|
||||
return
|
||||
self.fft_averages = fft_averages
|
||||
self.restart()
|
||||
|
||||
|
16
owrx/fft.py
16
owrx/fft.py
@ -34,29 +34,15 @@ class SpectrumThread(csdr.output, SdrSourceEventClient):
|
||||
dsp.setSocketClient(self.sdrSource.getSocketClient())
|
||||
dsp.set_demodulator("fft")
|
||||
|
||||
def set_fft_averages(key, value):
|
||||
samp_rate = props["samp_rate"]
|
||||
fft_size = props["fft_size"]
|
||||
fft_fps = props["fft_fps"]
|
||||
fft_voverlap_factor = props["fft_voverlap_factor"]
|
||||
|
||||
dsp.set_fft_averages(
|
||||
int(round(1.0 * samp_rate / fft_size / fft_fps / (1.0 - fft_voverlap_factor)))
|
||||
if fft_voverlap_factor > 0
|
||||
else 0
|
||||
)
|
||||
|
||||
self.subscriptions = [
|
||||
props.wireProperty("samp_rate", dsp.set_samp_rate),
|
||||
props.wireProperty("fft_size", dsp.set_fft_size),
|
||||
props.wireProperty("fft_fps", dsp.set_fft_fps),
|
||||
props.wireProperty("fft_compression", dsp.set_fft_compression),
|
||||
props.wireProperty("temporary_directory", dsp.set_temporary_directory),
|
||||
props.filter("samp_rate", "fft_size", "fft_fps", "fft_voverlap_factor").wire(set_fft_averages),
|
||||
props.wireProperty("fft_voverlap_factor", dsp.set_fft_voverlap_factor),
|
||||
]
|
||||
|
||||
set_fft_averages(None, None)
|
||||
|
||||
dsp.csdr_dynamic_bufsize = props["csdr_dynamic_bufsize"]
|
||||
dsp.csdr_print_bufsizes = props["csdr_print_bufsizes"]
|
||||
dsp.csdr_through = props["csdr_through"]
|
||||
|
Loading…
Reference in New Issue
Block a user