24v: STFT layer solved — NO synthesis window (partitioned-conv architecture); dual corpus 0.193 mean/0.438 max (was 3.264); RT_SYN/RT_WIN env options; remaining: q/sens parameterization of law constants

This commit is contained in:
2026-08-24 22:29:56 +03:00
parent edf6f35cdf
commit cf38622995
2 changed files with 49 additions and 3 deletions
+13 -3
View File
@@ -39,8 +39,14 @@ void SpectralProcessor::setDetectorParams(const std::vector<DetectorBand>& bands
}
void SpectralProcessor::computeWindow() {
// RT_WIN: 0=symmetric hann (legacy), 1=periodic hann, 2=rectangular
static const int winmode = getenv("RT_WIN") ? atoi(getenv("RT_WIN")) : 0;
for (size_t i = 0; i < nfft_; i++) {
window_[i] = 0.5 * (1.0 - std::cos(2.0 * M_PI * i / (nfft_ - 1)));
double v;
if (winmode == 1) v = 0.5 * (1.0 - std::cos(2.0 * M_PI * i / nfft_));
else if (winmode == 2) v = 1.0;
else v = 0.5 * (1.0 - std::cos(2.0 * M_PI * i / (nfft_ - 1)));
window_[i] = v;
}
}
@@ -56,16 +62,20 @@ void SpectralProcessor::istftFrame(std::complex<double>* in, float* out, float*
fft::execute_inverse(&plan_, tmp_buf_);
static bool wola_computed = false;
static float wola_norm = 1.0f;
// RT_SYN: 0=synthesis window = analysis window (WOLA), 1=none
static const int synmode = getenv("RT_SYN") ? atoi(getenv("RT_SYN")) : 0;
if (!wola_computed) {
double wola_sum = 0.0;
for (size_t i = 0; i < nfft_; i++) {
wola_sum += window_[i] * window_[i];
double w = (synmode == 1) ? 1.0 : window_[i];
wola_sum += window_[i] * w;
}
wola_norm = static_cast<float>(wola_sum / hop_);
wola_computed = true;
}
for (size_t i = 0; i < nfft_; i++) {
overlap[i] += static_cast<float>(tmp_buf_[i].real() * window_[i]);
double w = (synmode == 1) ? 1.0f : window_[i];
overlap[i] += static_cast<float>(tmp_buf_[i].real() * w);
}
for (size_t i = 0; i < hop_; i++) {
out[i] = overlap[i] / wola_norm;