diff options
Diffstat (limited to 'src/audio/fft.cc')
| -rw-r--r-- | src/audio/fft.cc | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/src/audio/fft.cc b/src/audio/fft.cc index 3f8e706..64d7b1a 100644 --- a/src/audio/fft.cc +++ b/src/audio/fft.cc @@ -109,7 +109,7 @@ void dct_fft(const float* input, float* output, size_t N) { // Reorder input: even indices first, then odd indices reversed // [x[0], x[2], x[4], ...] followed by [x[N-1], x[N-3], x[N-5], ...] for (size_t i = 0; i < N / 2; i++) { - real[i] = input[2 * i]; // Even indices: 0, 2, 4, ... + real[i] = input[2 * i]; // Even indices: 0, 2, 4, ... real[N - 1 - i] = input[2 * i + 1]; // Odd indices reversed: N-1, N-3, ... } memset(imag, 0, N * sizeof(float)); @@ -153,7 +153,7 @@ void idct_fft(const float* input, float* output, size_t N) { // FFT[k] = DCT[k] * exp(+j*pi*k/(2*N)) / normalization // Note: DCT-III (inverse of DCT-II) requires factor of 2 for AC terms for (size_t k = 0; k < N; k++) { - const float angle = PI * k / (2.0f * N); // Positive angle for inverse + const float angle = PI * k / (2.0f * N); // Positive angle for inverse const float wr = cosf(angle); const float wi = sinf(angle); @@ -178,8 +178,8 @@ void idct_fft(const float* input, float* output, size_t N) { // Even output indices come from first half of FFT output // Odd output indices come from second half (reversed) for (size_t i = 0; i < N / 2; i++) { - output[2 * i] = real[i]; // Even positions - output[2 * i + 1] = real[N - 1 - i]; // Odd positions (reversed) + output[2 * i] = real[i]; // Even positions + output[2 * i + 1] = real[N - 1 - i]; // Odd positions (reversed) } delete[] real; |
