summaryrefslogtreecommitdiffstats
path: root/src/transient_spectral_upsampler.cpp
Commit message (Collapse)AuthorAgeFilesLines
* Add CalcCurve and TSpectralUpsampler for transient detectionDaniil Cherednik2026-03-061-0/+182
CalcCurve (transient_detector.cpp/h): - Recursive divide-and-conquer FindTransients scans the gain vector for monotonic 3-subframe windows (rising or falling); kMinScore=2.0 filters out oscillations smaller than a factor of 2 (no-op at Level 4). - RelationToIdx maps an amplitude ratio to an ATRAC3 gain Level index. - TCurveBuilderCtx carries LastLevel across frames; CalcCurve prepends it as a virtual boundary element to detect Location=0 attacks. - budget=8 matches ATRAC3 SubbandInfo::MaxGainPointsNum. TSpectralUpsampler (transient_spectral_upsampler.cpp/h): - Applies a Planck-taper window (ε=0.15) to a 512-sample context window, forward-FFTs, applies a 3-bin raised-cosine HPF, zero-pads to 4096 bins, and inverse-FFTs to give an 8× upsampled output. - Returns highFreqRatio = Σ|X[k]·H[k]|²/Σ|X[k]|²; callers skip CalcCurve when this is below kHighFreqThreshold=0.05, preventing false transients from Planck noise-floor variation in sub-cutoff frames. Tests: - gain_processor_ut: upsampled-path blocks added to all FreqDomain tests; CalcCurve negative tests (NegativeTests suite). - transient_spectral_upsampler_ut: OutputSize, DCIsRemovedByLowCutFilter, HighFreqSinePreservesRMS (parametrised), ChirpNoTransient (0→5510 Hz sweep at 689 Hz low-cut, Len1024/16384/262144). Co-Authored-By: Claude Sonnet 4.6 <[email protected]>