Skip to content

Commit

Permalink
Change Hamming to Hanning Window
Browse files Browse the repository at this point in the history
Issue #332 This will create conflict in another brnach. Easy to fix. Accept Hanning as default window.
  • Loading branch information
towsey committed Aug 11, 2020
1 parent 277a0de commit 9f2904f
Showing 1 changed file with 3 additions and 10 deletions.
13 changes: 3 additions & 10 deletions src/AudioAnalysisTools/DSP/DSP_Frames.cs
Original file line number Diff line number Diff line change
Expand Up @@ -196,7 +196,7 @@ public static EnvelopeAndFft ExtractEnvelopeAndAmplSpectrogram(
// set up the FFT parameters
if (windowName == null)
{
windowName = FFT.KeyHammingWindow;
windowName = FFT.KeyHanningWindow;
}

FFT.WindowFunc w = FFT.GetWindowFunction(windowName);
Expand Down Expand Up @@ -263,7 +263,7 @@ public static EnvelopeAndFft ExtractEnvelopeAndAmplSpectrogram(
{
maxAbsValue = absValue;
}
} // end of frame
} // end frame

double frameDc = frameSum / frameSize;
minValues[i] = frameMin;
Expand All @@ -283,14 +283,7 @@ public static EnvelopeAndFft ExtractEnvelopeAndAmplSpectrogram(
// generate the spectra of FFT AMPLITUDES - NOTE: f[0]=DC; f[64]=Nyquist
var f1 = fft.InvokeDotNetFFT(signalMinusAv);

// Previous alternative call to do the FFT and return amplitude spectrum
//f1 = fft.Invoke(window);

// Smooth spectrum to reduce variance
// In the early days (pre-2010), we used to smooth the spectra to reduce sonogram variance. This is statistically correct thing to do.
// Later, we stopped this for standard sonograms but kept it for calculating acoustic indices.
// As of 28 March 2017, we are merging the two codes and keeping spectrum smoothing.
// Will need to check the effect on spectrograms.
int smoothingWindow = 3;
f1 = DataTools.filterMovingAverage(f1, smoothingWindow);

Expand All @@ -301,7 +294,7 @@ public static EnvelopeAndFft ExtractEnvelopeAndAmplSpectrogram(
}
} // end frames

// Remove the DC column ie column zero from amplitude spectrogram.
// Remove the DC column (ie column zero) from amplitude spectrogram.
double[,] amplitudeSpectrogram = MatrixTools.Submatrix(spectrogram, 0, 1, spectrogram.GetLength(0) - 1, spectrogram.GetLength(1) - 1);

// check the envelope for clipping. Accept a clip if two consecutive frames have max value = 1,0
Expand Down

0 comments on commit 9f2904f

Please sign in to comment.