diff options
Diffstat (limited to 'src/audio/fft.h')
| -rw-r--r-- | src/audio/fft.h | 34 |
1 files changed, 34 insertions, 0 deletions
diff --git a/src/audio/fft.h b/src/audio/fft.h new file mode 100644 index 0000000..81a12d4 --- /dev/null +++ b/src/audio/fft.h @@ -0,0 +1,34 @@ +// Fast Fourier Transform (FFT) implementation +// Radix-2 Cooley-Tukey algorithm for power-of-2 sizes +// This implementation matches the JavaScript version in tools/spectral_editor/dct.js + +#ifndef AUDIO_FFT_H_ +#define AUDIO_FFT_H_ + +#include <cstddef> + +// Forward FFT: Time domain → Frequency domain +// Input: real[] (length N), imag[] (length N, can be zeros) +// Output: real[] and imag[] contain complex frequency bins +// N must be a power of 2 +void fft_forward(float* real, float* imag, size_t N); + +// Inverse FFT: Frequency domain → Time domain +// Input: real[] (length N), imag[] (length N) +// Output: real[] and imag[] contain complex time samples (scaled by 1/N) +// N must be a power of 2 +void fft_inverse(float* real, float* imag, size_t N); + +// DCT Type-II via FFT (matches existing dct_512 signature) +// Input: input[] (length N) +// Output: output[] (length N) containing DCT-II coefficients +// N must be a power of 2 +void dct_fft(const float* input, float* output, size_t N); + +// IDCT (Inverse DCT Type-II) via FFT (matches existing idct_512 signature) +// Input: input[] (length N) +// Output: output[] (length N) containing time-domain samples +// N must be a power of 2 +void idct_fft(const float* input, float* output, size_t N); + +#endif /* AUDIO_FFT_H_ */ |
