diff --git a/Source/PS_Source/ProcessedStretch.h b/Source/PS_Source/ProcessedStretch.h index 3a12640..ea28951 100644 --- a/Source/PS_Source/ProcessedStretch.h +++ b/Source/PS_Source/ProcessedStretch.h @@ -188,6 +188,109 @@ inline REALTYPE profile(REALTYPE fi, REALTYPE bwi) { }; +inline void spectrum_spread(int nfreq, double samplerate, + std::vector& tmpfreq1, + REALTYPE *freq1, REALTYPE *freq2, REALTYPE spread_bandwidth) { + //convert to log spectrum + REALTYPE minfreq = 20.0f; + REALTYPE maxfreq = 0.5f*samplerate; + + REALTYPE log_minfreq = log(minfreq); + REALTYPE log_maxfreq = log(maxfreq); + + for (int i = 0; i= nfreq) x0 = nfreq - 1; + int x1 = x0 + 1; if (x1 >= nfreq) x1 = nfreq - 1; + REALTYPE xp = x - x0; + if (x0; i--) { + tmpfreq1[i] = tmpfreq1[i + 1] * a + tmpfreq1[i] * (1.0f - a); + }; + }; + + freq2[0] = 0; + REALTYPE log_maxfreq_d_minfreq = log(maxfreq / minfreq); + for (int i = 1; i0.0) && (x= nfreq) x0 = nfreq - 1; + int x1 = x0 + 1; if (x1 >= nfreq) x1 = nfreq - 1; + REALTYPE xp = x - x0; + y = tmpfreq1[x0] * (1.0f - xp) + tmpfreq1[x1] * xp; + }; + freq2[i] = y; + }; + + +}; + + +inline void spectrum_do_compressor(ProcessParameters& pars, int nfreq, REALTYPE *freq1, REALTYPE *freq2) { + REALTYPE rms = 0.0; + for (int i = 0; i& tmpfreq1, + REALTYPE *freq1, REALTYPE *freq2) { + spectrum_spread(nfreq, samplerate, tmpfreq1, freq1, tmpfreq1.data(), pars.tonal_vs_noise.bandwidth); + + if (pars.tonal_vs_noise.preserve >= 0.0) { + REALTYPE mul = (pow(10.0f, pars.tonal_vs_noise.preserve) - 1.0f); + for (int i = 0; i& tmpfreq1, int nfreq, double samplerate, REALTYPE *freq1, REALTYPE *freq2) { REALTYPE freq = pars.harmonics.freq; REALTYPE bandwidth = pars.harmonics.bandwidth;