Skip to content

Commit

Permalink
measure waterfall min/max in two passes, to prevent stack overflow on…
Browse files Browse the repository at this point in the history
… high fft sizes.
  • Loading branch information
jwt27 committed Sep 13, 2020
1 parent 3a84add commit 0c27e6e
Showing 1 changed file with 12 additions and 2 deletions.
14 changes: 12 additions & 2 deletions htdocs/openwebrx.js
Original file line number Diff line number Diff line change
Expand Up @@ -1088,9 +1088,19 @@ function waterfall_measure_minmax_do(what) {
// this is based on an oversampling factor of about 1,25
var ignored = .1 * what.length;
var data = what.slice(ignored, -ignored);
var min = [];
var max = [];
var max_slice = 1e5;
var n = Math.ceil(data.length / max_slice);
for (var i = 0; i < n; ++i)
{
slice = data.slice(i * max_slice, (i + 1) * max_slice);
min.push(Math.min.apply(Math, slice));
max.push(Math.max.apply(Math, slice));
}
return {
min: Math.min.apply(Math, data),
max: Math.max.apply(Math, data)
min: Math.min.apply(Math, min),
max: Math.max.apply(Math, max)
};
}

Expand Down

0 comments on commit 0c27e6e

Please sign in to comment.