improve demodulator initialization

This commit is contained in:
Jakob Ketterl 2020-04-26 22:46:30 +02:00
parent 26321ab68b
commit 6a8168025d
3 changed files with 35 additions and 6 deletions

View File

@ -1048,7 +1048,7 @@ function on_ws_recv(evt) {
updateSquelch();
waterfall_init();
initialize_demodulator(initial_demodulator_params);
synchronize_demodulator_init({initialParams: initial_demodulator_params});
bookmarks.loadLocalBookmarks();
waterfall_clear();
@ -1093,6 +1093,7 @@ function on_ws_recv(evt) {
break;
case "features":
Modes.setFeatures(json['value']);
synchronize_demodulator_init({features: true});
break;
case "metadata":
update_metadata(json['value']);
@ -1144,6 +1145,7 @@ function on_ws_recv(evt) {
break;
case 'modes':
Modes.setModes(json['value']);
synchronize_demodulator_init({modes: true});
demodulator_buttons_update();
break;
default:
@ -1539,6 +1541,15 @@ function onAudioStart(success, apiType){
updateVolume();
}
var sync_params = {}
function synchronize_demodulator_init(params) {
sync_params = $.extend(sync_params, params);
if (sync_params.initialParams && sync_params.modes && sync_params.features) {
initialize_demodulator(sync_params.initialParams);
}
}
function initialize_demodulator(initialParams) {
mkscale();
var params = $.extend(initialParams || {}, validateHash());
@ -1929,10 +1940,7 @@ function demodulator_buttons_update() {
var mode = Modes.findByModulation(secondary_demod);
if (mode) {
var active = mode.underlying.map(function(u){ return 'openwebrx-button-' + u; });
console.info(active);
$buttons.filter(function(){
console.info(this.id);
console.info(active.indexOf(this.id));
return this.id !== "openwebrx-button-dig" && active.indexOf(this.id) < 0;
}).addClass('disabled');
}

View File

@ -5,6 +5,7 @@ from owrx.aprs import AprsParser
from owrx.pocsag import PocsagParser
from owrx.source import SdrSource
from owrx.property import PropertyStack, PropertyLayer
from owrx.modes import Modes
from csdr import csdr
import threading
@ -51,6 +52,8 @@ class DspManager(csdr.output):
"digital_voice_unvoiced_quality",
"temporary_directory",
"center_freq",
"start_mod",
"start_freq",
))
self.dsp = csdr.dsp(self)
@ -71,6 +74,20 @@ class DspManager(csdr.output):
for parser in self.parsers.values():
parser.setDialFrequency(freq)
if "start_mod" in self.props:
self.dsp.set_demodulator(self.props["start_mod"])
mode = Modes.findByModulation(self.props["start_mod"])
if mode and mode.bandpass:
self.dsp.set_bpf(mode.bandpass.low_cut, mode.bandpass.high_cut)
else:
self.dsp.set_bpf(-4000, 4000)
if "start_freq" in self.props and "center_freq" in self.props:
self.dsp.set_offset_freq(self.props["start_freq"] - self.props["center_freq"])
else:
self.dsp.set_offset_freq(0)
self.subscriptions = [
self.props.wireProperty("audio_compression", self.dsp.set_audio_compression),
self.props.wireProperty("fft_compression", self.dsp.set_fft_compression),
@ -89,8 +106,6 @@ class DspManager(csdr.output):
self.props.filter("center_freq", "offset_freq").wire(set_dial_freq),
]
self.dsp.set_offset_freq(0)
self.dsp.set_bpf(-4000, 4000)
self.dsp.csdr_dynamic_bufsize = self.props["csdr_dynamic_bufsize"]
self.dsp.csdr_print_bufsizes = self.props["csdr_print_bufsizes"]
self.dsp.csdr_through = self.props["csdr_through"]

View File

@ -70,3 +70,9 @@ class Modes(object):
@staticmethod
def getAvailableServices():
return [m for m in Modes.getAvailableModes() if m.is_service()]
@staticmethod
def findByModulation(modulation):
modes = [m for m in Modes.getAvailableModes() if m.modulation == modulation]
if modes:
return modes[0]