Skip to content

Commit 0c27e6e

Browse files
committed
measure waterfall min/max in two passes, to prevent stack overflow on high fft sizes.
1 parent 3a84add commit 0c27e6e

File tree

1 file changed

+12
-2
lines changed

1 file changed

+12
-2
lines changed

htdocs/openwebrx.js

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1088,9 +1088,19 @@ function waterfall_measure_minmax_do(what) {
10881088
// this is based on an oversampling factor of about 1,25
10891089
var ignored = .1 * what.length;
10901090
var data = what.slice(ignored, -ignored);
1091+
var min = [];
1092+
var max = [];
1093+
var max_slice = 1e5;
1094+
var n = Math.ceil(data.length / max_slice);
1095+
for (var i = 0; i < n; ++i)
1096+
{
1097+
slice = data.slice(i * max_slice, (i + 1) * max_slice);
1098+
min.push(Math.min.apply(Math, slice));
1099+
max.push(Math.max.apply(Math, slice));
1100+
}
10911101
return {
1092-
min: Math.min.apply(Math, data),
1093-
max: Math.max.apply(Math, data)
1102+
min: Math.min.apply(Math, min),
1103+
max: Math.max.apply(Math, max)
10941104
};
10951105
}
10961106

0 commit comments

Comments
 (0)