-
Notifications
You must be signed in to change notification settings - Fork 52
Closed
Description
I am passing 2048 PCM samples to either FFT.Magnitude or FFT.Power, and I'm getting back 1025 elements instead of 1024.
This isn't a big deal since, of course, most of the "far end" (for music) is zero or near-zero, but I wasn't expecting that. Is this known/expected for some reason? Or am I doing something wrong? Nothing fancy in the code, reading 16-bit short samples via OpenAL:
private void FrequencyProcessing()
{
// FFT buffer is 2048, "slide" two passes of PCM 1024 data through it.
// Copy the second half of the FFT buffer "back" to the first half:
Array.Copy(BufferFFT, BufferLength, BufferFFT, 0, BufferLength);
// Next, copy new PCM data to the second half of the FFT buffer:
Array.Copy(BufferPCM, 0, BufferFFT, BufferLength, BufferLength);
var window = new Hanning();
double[] windowed = window.Apply(BufferFFT);
double[] zeroPadded = Pad.ZeroPad(windowed);
System.Numerics.Complex[] spectrum = FFT.Forward(zeroPadded);
// this returns 1025 elements?
BufferFreq = FFT.Magnitude(spectrum);
}Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels