apply 80% rule to visible range too

- previous system would run into error if visible range was outside of
  80% range
This commit is contained in:
Jakob Ketterl 2024-01-29 02:24:18 +01:00
parent e2192a9665
commit 5eaa53f028

View file

@ -951,13 +951,14 @@ function on_ws_recv(evt) {
function waterfall_measure_minmax_do(what) { function waterfall_measure_minmax_do(what) {
// Get visible range // Get visible range
var range = get_visible_freq_range(); var range = get_visible_freq_range();
var start = center_freq - bandwidth / 2; var overallStart = center_freq - bandwidth / 2;
var center = (range.center - overallStart) / bandwidth;
// 80% of visible range
// this is based on an oversampling factor of about 1,25 // this is based on an oversampling factor of about 1,25
range.start = Math.max(0.1, (range.start - start) / bandwidth); var bw = .4 * (range.bw / bandwidth);
range.end = Math.min(0.9, (range.end - start) / bandwidth); var data = what.slice((center - bw) * what.length, (center + bw) * what.length);
var data = what.slice(range.start * what.length, range.end * what.length);
return { return {
min: Math.min.apply(Math, data), min: Math.min.apply(Math, data),
max: Math.max.apply(Math, data) max: Math.max.apply(Math, data)