summaryrefslogtreecommitdiff
path: root/src/audio/fft.h
blob: 8c10afdc2dd536bc4bdb5d55026fcb96e0e486fa (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
// 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_ */