Skip to content

Commit 535bf2a

Browse files
committed
Limit fft input count for simple spectrum chart to get normal charts plot quality
1 parent d7a3939 commit 535bf2a

File tree

1 file changed

+10
-2
lines changed

1 file changed

+10
-2
lines changed

src/graph_spectrum_calc.js

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,8 @@ const
1717
MAX_ANALYSER_LENGTH = 300 * 1000 * 1000, // 5min
1818
WARNING_RATE_DIFFERENCE = 0.05,
1919
MAX_RPM_HZ_VALUE = 800,
20-
RPM_AXIS_TOP_MARGIN_PERCENT = 2;
20+
RPM_AXIS_TOP_MARGIN_PERCENT = 2,
21+
MIN_SPECTRUM_SAMPLES_COUNT = 2048;
2122
export const NUM_VS_BINS = 100;
2223

2324
export const GraphSpectrumCalc = {
@@ -412,7 +413,14 @@ GraphSpectrumCalc._getFlightSamplesFreq = function(scaled = true) {
412413
}
413414

414415
// The FFT input size is power 2 to get maximal performance
415-
const fftBufferSize = this.getNearPower2Value(samplesCount);
416+
// Limit fft input count for simple spectrum chart to get normal charts plot quality
417+
let fftBufferSize;
418+
if (scaled && samplesCount < MIN_SPECTRUM_SAMPLES_COUNT) {
419+
fftBufferSize = MIN_SPECTRUM_SAMPLES_COUNT;
420+
} else {
421+
fftBufferSize = this.getNearPower2Value(samplesCount);
422+
}
423+
416424
return {
417425
samples : samples.slice(0, fftBufferSize),
418426
count : samplesCount,

0 commit comments

Comments
 (0)