Skip to content

Commit c088b4d

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

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 = {
@@ -410,7 +411,14 @@ GraphSpectrumCalc._getFlightSamplesFreq = function(scaled = true) {
410411
}
411412

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

0 commit comments

Comments
 (0)