Files
soothe2-re/dsp/ms.hpp
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

32 lines
819 B
C++

#pragma once
#include <cstddef>
#include <cstdint>
inline void encode_ms(float* left, float* right, size_t n) {
for (size_t i = 0; i < n; i++) {
float mid = (left[i] + right[i]) * 0.5f;
float side = (left[i] - right[i]) * 0.5f;
left[i] = mid;
right[i] = side;
}
}
inline void decode_ms(float* left, float* right, size_t n) {
for (size_t i = 0; i < n; i++) {
float mid = left[i];
float side = right[i];
left[i] = mid + side;
right[i] = mid - side;
}
}
inline void apply_balance(float* left, float* right, float balance, size_t n) {
float gain_l = std::sqrt(0.5f * (1 - balance));
float gain_r = std::sqrt(0.5f * (1 + balance));
for (size_t i = 0; i < n; i++) {
left[i] *= gain_l;
right[i] *= gain_r;
}
}