Skip to content

Hanning window applied to input data (fftInput, not fftOutput) #491

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Jan 5, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 5 additions & 4 deletions js/graph_spectrum_calc.js
Original file line number Diff line number Diff line change
Expand Up @@ -87,13 +87,14 @@ GraphSpectrumCalc.dataLoadFrequencyVsThrottle = function() {

var fftInput = flightSamples.samples.slice(fftChunkIndex, fftChunkIndex + fftChunkLength);
var fftOutput = new Float64Array(fftChunkLength * 2);

fft.simple(fftOutput, fftInput, 'real');


// Hanning window applied to input data
if(userSettings.analyserHanning) {
this._hanningWindow(fftOutput, fftChunkLength * 2);
this._hanningWindow(fftInput, fftChunkLength);
}

fft.simple(fftOutput, fftInput, 'real');

fftOutput = fftOutput.slice(0, fftChunkLength);

// Use only abs values
Expand Down
2 changes: 1 addition & 1 deletion js/user_settings_dialog.js
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ function UserSettingsDialog(dialog, onLoad, onSave) {
graphExpoOverride : true, // Ability to toggle Expo off=normal/ on=force 100%
graphGridOverride : true, // Ability to toggle Grid off=normal/ on=force disabled
analyserSampleRate : 2000/*Hz*/, // the loop time for the log
analyserHanning : false, // use a hanning window on the analyser sample data
analyserHanning : true, // use a hanning window on the analyser sample data
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

General remark: This line uses tabs instead of the 4 spaces normally used in this project. Yes, this is not your change, but as in most projects, it is seen as polite if code is left 'at least as good as, if not better' than how it was found, so this could have been fixed as part of the pull request.

eraseBackground : true, // Set to false if you want the graph to draw on top of an existing canvas image
spectrumType : 0, // By default, frequency Spectrum
overdrawSpectrumType: 0, // By default, show all filters
Expand Down