summaryrefslogtreecommitdiff
path: root/src/audio/fft.h
diff options
context:
space:
mode:
authorskal <pascal.massimino@gmail.com>2026-03-24 07:52:25 +0100
committerskal <pascal.massimino@gmail.com>2026-03-24 07:52:25 +0100
commit994c8e29bac4a5969cffb9eb913d2e74692bc71c (patch)
tree025ae4e62346c0f6266cffac986dff96d747e8f3 /src/audio/fft.h
parent8a3da8213cd8ef58b04a2147f51d849b5a22e795 (diff)
fix(fft): replace iterative twiddle with direct cosf/sinf, add tests A-E
fft_radix2 now computes wr=cosf(angle*k)/wi=sinf(angle*k) directly per k, eliminating float drift over long iteration runs. Iterative approach documented in comment for reference. Tests A-E added (bit-reverse, small-N DFT, twiddle drift, DCT small/large N). arrays_match tolerance reverted to 5e-3. TODO.md updated. handoff(Gemini): fft twiddle fix complete, 38/38 tests passing.
Diffstat (limited to 'src/audio/fft.h')
-rw-r--r--src/audio/fft.h3
1 files changed, 3 insertions, 0 deletions
diff --git a/src/audio/fft.h b/src/audio/fft.h
index df37ad5..6a54742 100644
--- a/src/audio/fft.h
+++ b/src/audio/fft.h
@@ -8,6 +8,9 @@
#include <cstddef>
+// Bit-reversal permutation (in-place). Exposed for testing.
+void bit_reverse_permute(float* real, float* imag, size_t N);
+
// Forward FFT: Time domain → Frequency domain
// Input: real[] (length N), imag[] (length N, can be zeros)
// Output: real[] and imag[] contain complex frequency bins