fix bookmark tuning

This commit is contained in:
Jakob Ketterl 2020-01-19 10:50:40 +01:00
parent 18a63a6e7b
commit 136b668f8f
2 changed files with 8 additions and 13 deletions

View File

@ -9,7 +9,7 @@ function BookmarkBar() {
me.$container.find('.bookmark').removeClass('selected'); me.$container.find('.bookmark').removeClass('selected');
var b = $bookmark.data(); var b = $bookmark.data();
if (!b || !b.frequency || (!b.modulation && !b.digital_modulation)) return; if (!b || !b.frequency || (!b.modulation && !b.digital_modulation)) return;
demodulator_set_offset_frequency(0, b.frequency - center_freq); demodulators[0].set_offset_frequency(b.frequency - center_freq);
if (b.modulation) { if (b.modulation) {
demodulator_analog_replace(b.modulation); demodulator_analog_replace(b.modulation);
} else if (b.digital_modulation) { } else if (b.digital_modulation) {

View File

@ -334,7 +334,6 @@ function demod_envelope_where_clicked(x, drag_ranges, key_modifiers) { // Check
//******* class Demodulator ******* //******* class Demodulator *******
// this can be used as a base class for ANY demodulator // this can be used as a base class for ANY demodulator
Demodulator = function (offset_frequency) { Demodulator = function (offset_frequency) {
//console.log("this too");
this.offset_frequency = offset_frequency; this.offset_frequency = offset_frequency;
this.envelope = {}; this.envelope = {};
this.color = demodulators_get_next_color(); this.color = demodulators_get_next_color();
@ -357,11 +356,7 @@ Demodulator.draggable_ranges = {
demodulator_response_time = 50; demodulator_response_time = 50;
//in ms; if we don't limit the number of SETs sent to the server, audio will underrun (possibly output buffer is cleared on SETs in GNU Radio
function Demodulator_default_analog(offset_frequency, subtype) { function Demodulator_default_analog(offset_frequency, subtype) {
//console.log("hopefully this happens");
//http://stackoverflow.com/questions/4152931/javascript-inheritance-call-super-constructor-or-use-prototype-chain
Demodulator.call(this, offset_frequency); Demodulator.call(this, offset_frequency);
this.subtype = subtype; this.subtype = subtype;
this.filter = { this.filter = {
@ -565,10 +560,10 @@ function demodulator_analog_replace(subtype, for_digital) { //this function shou
update_digitalvoice_panels("openwebrx-panel-metadata-" + subtype); update_digitalvoice_panels("openwebrx-panel-metadata-" + subtype);
} }
function demodulator_set_offset_frequency(to_what) { Demodulator.prototype.set_offset_frequency = function(to_what) {
if (to_what > bandwidth / 2 || to_what < -bandwidth / 2) return; if (to_what > bandwidth / 2 || to_what < -bandwidth / 2) return;
demodulators[0].offset_frequency = Math.round(to_what); this.offset_frequency = Math.round(to_what);
demodulators[0].set(); this.set();
mkenvelopes(get_visible_freq_range()); mkenvelopes(get_visible_freq_range());
tunedFrequencyDisplay.setFrequency(center_freq + to_what); tunedFrequencyDisplay.setFrequency(center_freq + to_what);
} }
@ -635,7 +630,7 @@ function scale_canvas_mousemove(evt) {
else if (scale_canvas_drag_params.drag) { else if (scale_canvas_drag_params.drag) {
//call the drag_move for all demodulators (and they will decide if they're dragged) //call the drag_move for all demodulators (and they will decide if they're dragged)
for (i = 0; i < demodulators.length; i++) event_handled |= demodulators[i].envelope.drag_move(evt.pageX); for (i = 0; i < demodulators.length; i++) event_handled |= demodulators[i].envelope.drag_move(evt.pageX);
if (!event_handled) demodulator_set_offset_frequency(scale_offset_freq_from_px(evt.pageX)); if (!event_handled) demodulators[0].set_offset_frequency(scale_offset_freq_from_px(evt.pageX));
} }
} }
@ -651,7 +646,7 @@ function scale_canvas_end_drag(x) {
scale_canvas_drag_params.mouse_down = false; scale_canvas_drag_params.mouse_down = false;
var event_handled = false; var event_handled = false;
for (var i = 0; i < demodulators.length; i++) event_handled |= demodulators[i].envelope.drag_end(); for (var i = 0; i < demodulators.length; i++) event_handled |= demodulators[i].envelope.drag_end();
if (!event_handled) demodulator_set_offset_frequency(scale_offset_freq_from_px(x)); if (!event_handled) demodulators[0].set_offset_frequency(scale_offset_freq_from_px(x));
} }
function scale_canvas_mouseup(evt) { function scale_canvas_mouseup(evt) {
@ -932,7 +927,7 @@ function canvas_mouseup(evt) {
var relativeX = get_relative_x(evt); var relativeX = get_relative_x(evt);
if (!canvas_drag) { if (!canvas_drag) {
demodulator_set_offset_frequency(canvas_get_freq_offset(relativeX)); demodulators[0].set_offset_frequency(canvas_get_freq_offset(relativeX));
} }
else { else {
canvas_end_drag(); canvas_end_drag();
@ -1792,7 +1787,7 @@ function openwebrx_init() {
initPanels(); initPanels();
tunedFrequencyDisplay = new TuneableFrequencyDisplay($('#webrx-actual-freq')); tunedFrequencyDisplay = new TuneableFrequencyDisplay($('#webrx-actual-freq'));
tunedFrequencyDisplay.onFrequencyChange(function(f) { tunedFrequencyDisplay.onFrequencyChange(function(f) {
demodulator_set_offset_frequency(f - center_freq); demodulators[0].set_offset_frequency(f - center_freq);
}); });
mouseFrequencyDisplay = new FrequencyDisplay($('#webrx-mouse-freq')); mouseFrequencyDisplay = new FrequencyDisplay($('#webrx-mouse-freq'));
window.addEventListener("resize", openwebrx_resize); window.addEventListener("resize", openwebrx_resize);