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

View File

@ -5,6 +5,7 @@ from owrx.aprs import AprsParser
from owrx.pocsag import PocsagParser from owrx.pocsag import PocsagParser
from owrx.source import SdrSource from owrx.source import SdrSource
from owrx.property import PropertyStack, PropertyLayer from owrx.property import PropertyStack, PropertyLayer
from owrx.modes import Modes
from csdr import csdr from csdr import csdr
import threading import threading
@ -51,6 +52,8 @@ class DspManager(csdr.output):
"digital_voice_unvoiced_quality", "digital_voice_unvoiced_quality",
"temporary_directory", "temporary_directory",
"center_freq", "center_freq",
"start_mod",
"start_freq",
)) ))
self.dsp = csdr.dsp(self) self.dsp = csdr.dsp(self)
@ -71,6 +74,20 @@ class DspManager(csdr.output):
for parser in self.parsers.values(): for parser in self.parsers.values():
parser.setDialFrequency(freq) 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.subscriptions = [
self.props.wireProperty("audio_compression", self.dsp.set_audio_compression), self.props.wireProperty("audio_compression", self.dsp.set_audio_compression),
self.props.wireProperty("fft_compression", self.dsp.set_fft_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.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_dynamic_bufsize = self.props["csdr_dynamic_bufsize"]
self.dsp.csdr_print_bufsizes = self.props["csdr_print_bufsizes"] self.dsp.csdr_print_bufsizes = self.props["csdr_print_bufsizes"]
self.dsp.csdr_through = self.props["csdr_through"] self.dsp.csdr_through = self.props["csdr_through"]

View File

@ -70,3 +70,9 @@ class Modes(object):
@staticmethod @staticmethod
def getAvailableServices(): def getAvailableServices():
return [m for m in Modes.getAvailableModes() if m.is_service()] 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]