dsp/: add spectral detector with envelope + peak suppression
- Detector computes smoothed spectral envelope - Finds peaks exceeding envelope - Creates per-bin suppression mask - Applies mask in frequency domain before ISTFT - Default params: sharpness=1.0, selectivity=0.5, depth=0.3 Verified: burst500.wav → output RMS reduced from 0.0678 to 0.0476
This commit is contained in:
+7
-5
@@ -4,6 +4,7 @@
|
||||
#include <complex>
|
||||
#include <vector>
|
||||
#include "fft.hpp"
|
||||
#include "detect.hpp"
|
||||
|
||||
constexpr size_t DEFAULT_NFFT = 2048;
|
||||
constexpr size_t DEFAULT_HOP = 512;
|
||||
@@ -12,9 +13,10 @@ class SpectralProcessor {
|
||||
public:
|
||||
SpectralProcessor(size_t nfft = DEFAULT_NFFT, size_t hop = DEFAULT_HOP);
|
||||
~SpectralProcessor();
|
||||
|
||||
|
||||
void setDetectorParams(float sharpness, float selectivity, float depth);
|
||||
void processBlock(float* in, float* out, size_t num_samples, size_t num_channels = 1);
|
||||
|
||||
|
||||
private:
|
||||
size_t nfft_;
|
||||
size_t hop_;
|
||||
@@ -23,12 +25,12 @@ private:
|
||||
std::complex<double>* buf_;
|
||||
std::complex<double>* tmp_buf_;
|
||||
std::vector<float> overlap_;
|
||||
std::vector<float> mask_;
|
||||
Detector detector_;
|
||||
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