| 14 | namespace audio { |
| 15 | |
| 16 | Reactive::Reactive() |
| 17 | : mConfig{}, mContext(fl::make_shared<Context>(Sample())), mFFTBins(16) // Initialize with 16 frequency bins |
| 18 | { |
| 19 | // Initialize enhanced beat detection components |
| 20 | mSpectralFluxDetector = fl::make_unique<SpectralFluxDetector>(); |
| 21 | mPerceptualWeighting = fl::make_unique<PerceptualWeighting>(); |
| 22 | |
| 23 | // Initialize previous magnitudes array to zero |
| 24 | for (fl::size i = 0; i < mPreviousMagnitudes.size(); ++i) { |
| 25 | mPreviousMagnitudes[i] = 0.0f; |
| 26 | } |
| 27 | |
| 28 | // Configure spectral silence envelopes — tau=0.2s chosen because FFT noise |
| 29 | // floor is brittle; these metrics should snap to zero quickly in silence. |
| 30 | SilenceEnvelope::Config envCfg; |
| 31 | envCfg.decayTauSeconds = 0.2f; |
| 32 | envCfg.targetValue = 0.0f; |
| 33 | mDominantFrequencyEnvelope.configure(envCfg); |
| 34 | mMagnitudeEnvelope.configure(envCfg); |
| 35 | mSpectralFluxEnvelope.configure(envCfg); |
| 36 | } |
| 37 | |
| 38 | Reactive::~Reactive() FL_NOEXCEPT = default; |
| 39 | |