Files
soothe2-re/dsp/fft_plan.cpp
T
Matiq 7dcbcf49b4 dsp/: C++ skeleton with working FFT/WOLA STFT
- Cooley-Tukey radix-2 FFT (forward + inverse with /N normalization)
- WOLA STFT/ISTFT with Hann window (nfft=2048, hop=512)
- WAV16 read + WAV24 write (fixed aliasing bug in read)
- Fixed in-place processing bug (separate input/output buffers)
- Biquad filter (peak/shelf/reject)
- Peak detector skeleton
- MS encode/decode (M8 stereo)
- Harness: WAV16 → STFT → WAV24 passthrough verified non-zero output

Verified: burst500.wav passthrough produces output RMS=0.0678
2026-08-17 11:25:35 +03:00

38 lines
1.1 KiB
C++

#include "fft_plan.hpp"
#include <cstring>
namespace fft {
void init_plan(FFTPlan* plan, uint32_t log2N) {
plan->log2N = log2N;
plan->N = 1U << log2N;
plan->stage_count = 0;
plan->bit_reverse = 0;
plan->xor_mask = 0;
uint32_t n = plan->N;
while (n > 1) {
if (n % 8 == 0 && log2N >= 3) {
plan->stages[plan->stage_count].radix = 8;
plan->stages[plan->stage_count].group_size = n / 8;
plan->stages[plan->stage_count].groups = 8;
plan->stage_count++;
n /= 8;
} else if (n % 4 == 0 && log2N >= 2) {
plan->stages[plan->stage_count].radix = 4;
plan->stages[plan->stage_count].group_size = n / 4;
plan->stages[plan->stage_count].groups = 4;
plan->stage_count++;
n /= 4;
} else if (n % 2 == 0) {
plan->stages[plan->stage_count].radix = 2;
plan->stages[plan->stage_count].group_size = n / 2;
plan->stages[plan->stage_count].groups = 2;
plan->stage_count++;
n /= 2;
}
}
}
}