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
This commit is contained in:
@@ -0,0 +1,34 @@
|
||||
#pragma once
|
||||
#include <cstddef>
|
||||
#include <cstdint>
|
||||
#include <complex>
|
||||
#include <vector>
|
||||
#include "fft.hpp"
|
||||
|
||||
constexpr size_t DEFAULT_NFFT = 2048;
|
||||
constexpr size_t DEFAULT_HOP = 512;
|
||||
|
||||
class SpectralProcessor {
|
||||
public:
|
||||
SpectralProcessor(size_t nfft = DEFAULT_NFFT, size_t hop = DEFAULT_HOP);
|
||||
~SpectralProcessor();
|
||||
|
||||
void processBlock(float* in, float* out, size_t num_samples, size_t num_channels = 1);
|
||||
|
||||
private:
|
||||
size_t nfft_;
|
||||
size_t hop_;
|
||||
double* window_;
|
||||
FFTPlan plan_;
|
||||
std::complex<double>* buf_;
|
||||
std::complex<double>* tmp_buf_;
|
||||
std::vector<float> overlap_;
|
||||
size_t frame_count_;
|
||||
size_t output_pos_;
|
||||
|
||||
void computeWindow();
|
||||
void stftFrame(const float* in, std::complex<double>* out);
|
||||
void istftFrame(std::complex<double>* in, float* out, float* overlap);
|
||||
void updateDetector();
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user