45 conditioned = mSignalConditioner.processSample(conditioned);
46 if (!conditioned.isValid()) {
52 if (mGain != 1.0f && conditioned.isValid()) {
53 conditioned.applyGain(mGain);
57 if (mNoiseFloorTrackingEnabled && conditioned.isValid()) {
58 mNoiseFloorTracker.update(conditioned.rms());
61 mContext->setSample(conditioned);
71 if (mNoiseFloorTrackingEnabled && conditioned.isValid()) {
72 constexpr float kSilenceRmsThreshold = 10.0f;
73 mContext->setSilent(conditioned.rms() < kSilenceRmsThreshold);
77 for (
auto& d : mActiveDetectors) {
82 for (
auto& d : mActiveDetectors) {
91 d->update(externalContext);
105 detector->onBeatPhase.add(callback);
109 auto detector = getBeatDetector();
110 detector->onOnset.add(callback);
113void Processor::onTempoChange(function<
void(
float,
float)> callback)
FL_NO_EXCEPT {
114 auto detector = getBeatDetector();
115 detector->onTempoChange.add(callback);
119 auto detector = getTempoAnalyzer();
120 detector->onTempo.add(callback);
124 auto detector = getTempoAnalyzer();
125 detector->onTempoWithConfidence.add(callback);
130 detector->onTempoStable.add(callback);
135 detector->onTempoUnstable.add(callback);
139 auto detector = getFrequencyBands();
140 detector->onBassLevel.add(callback);
144 auto detector = getFrequencyBands();
145 detector->onMidLevel.add(callback);
148void Processor::onTreble(function<
void(
float)> callback)
FL_NO_EXCEPT {
149 auto detector = getFrequencyBands();
150 detector->onTrebleLevel.add(callback);
154 auto detector = getFrequencyBands();
155 detector->onLevelsUpdate.add(callback);
160 detector->onEqualizer.add(callback);
164 auto detector = getEnergyAnalyzer();
169 auto detector = getEnergyAnalyzer();
170 detector->onNormalizedEnergy.add(callback);
173void Processor::onPeak(function<
void(
float)> callback)
FL_NO_EXCEPT {
174 auto detector = getEnergyAnalyzer();
175 detector->onPeak.add(callback);
179 auto detector = getEnergyAnalyzer();
180 detector->onAverageEnergy.add(callback);
185 detector->onTransient.add(callback);
189 auto detector = getTransientDetector();
190 detector->onTransientWithStrength.add(callback);
194 auto detector = getTransientDetector();
195 detector->onAttack.add(callback);
198void Processor::onSilence(function<
void(
u8)> callback)
FL_NO_EXCEPT {
199 auto detector = getSilenceDetector();
200 detector->onSilence.add(callback);
205 detector->onSilenceStart.add(callback);
210 detector->onSilenceEnd.add(callback);
214 auto detector = getSilenceDetector();
215 detector->onSilenceDuration.add(callback);
220 detector->onCrescendo.add(callback);
225 detector->onDiminuendo.add(callback);
229 auto detector = getDynamicsAnalyzer();
230 detector->onDynamicTrend.add(callback);
234 auto detector = getDynamicsAnalyzer();
235 detector->onCompressionRatio.add(callback);
238void Processor::onPitch(function<
void(
float)> callback)
FL_NO_EXCEPT {
239 auto detector = getPitchDetector();
240 detector->onPitch.add(callback);
244 auto detector = getPitchDetector();
245 detector->onPitchWithConfidence.add(callback);
249 auto detector = getPitchDetector();
250 detector->onPitchChange.add(callback);
254 auto detector = getPitchDetector();
255 detector->onVoiced.add(callback);
259 auto detector = getNoteDetector();
260 detector->onNoteOn.add(callback);
264 auto detector = getNoteDetector();
265 detector->onNoteOff.add(callback);
269 auto detector = getNoteDetector();
270 detector->onNoteChange.add(callback);
279 auto detector = getDownbeatDetector();
280 detector->onMeasureBeat.add(callback);
284 auto detector = getDownbeatDetector();
285 detector->onMeterChange.add(callback);
288void Processor::onMeasurePhase(function<
void(
float)> callback)
FL_NO_EXCEPT {
289 auto detector = getDownbeatDetector();
290 detector->onMeasurePhase.add(callback);
305 detector->onVocalStart.add(callback);
319 callback(
detector->getConfidence());
325 auto detector = getPercussionDetector();
326 detector->onPercussionHit.add(callback);
355 auto detector = getChordDetector();
356 detector->onChordChange.add(callback);
370 auto detector = getKeyDetector();
371 detector->onKeyChange.add(callback);
385 auto detector = getMoodAnalyzer();
386 detector->onMoodChange.add(callback);
389void Processor::onValenceArousal(function<
void(
float,
float)> callback)
FL_NO_EXCEPT {
390 auto detector = getMoodAnalyzer();
391 detector->onValenceArousal.add(callback);
396 detector->onBuildupStart.add(callback);
400 auto detector = getBuildupDetector();
401 detector->onBuildupProgress.add(callback);
406 detector->onBuildupPeak.add(callback);
411 detector->onBuildupEnd.add(callback);
426 detector->onDropEvent.add(callback);
431 detector->onDropImpact.add(callback);
436 detector->onVibeLevels.add(callback);
441 detector->onBassSpike.add(callback);
451 detector->onTrebSpike.add(callback);
458 if (v < 0.0f)
return 0.0f;
459 if (v > 1.0f)
return 1.0f;
465 if (v < -1.0f)
return -1.0f;
466 if (v > 1.0f)
return 1.0f;
724 mContext->setSampleRate(sampleRate);
728 d->setSampleRate(sampleRate);
983 processor->mAudioInput = input;
988 auto proc = weak.
lock();
989 auto inp = weakInput.
lock();
994 inp->readAll(&samples);
995 for (
const auto&
sample : samples) {
void update(const Sample &sample) FL_NO_EXCEPT
float getEqVolumeNormFactor() FL_NO_EXCEPT
float getEqVolumeDb() FL_NO_EXCEPT
Volume in approximate dB.
void onBuildupProgress(function< void(float progress)> callback) FL_NO_EXCEPT
void onKick(function< void()> callback) FL_NO_EXCEPT
float getBPM() FL_NO_EXCEPT
void onBuildupEnd(function< void()> callback) FL_NO_EXCEPT
float getChordConfidence() FL_NO_EXCEPT
shared_ptr< detector::Vocal > mVocalDetector
void onBeat(function< void()> callback) FL_NO_EXCEPT
void onTempoStable(function< void()> callback) FL_NO_EXCEPT
float getVocalConfidence() FL_NO_EXCEPT
shared_ptr< detector::Vocal > getVocalDetector() FL_NO_EXCEPT
shared_ptr< detector::EnergyAnalyzer > getEnergyAnalyzer() FL_NO_EXCEPT
~Processor() FL_NO_EXCEPT
float getEqAutoGain() FL_NO_EXCEPT
float getPitch() FL_NO_EXCEPT
shared_ptr< detector::Transient > getTransientDetector() FL_NO_EXCEPT
shared_ptr< detector::DynamicsAnalyzer > mDynamicsAnalyzer
float getEqDominantMagnitude() FL_NO_EXCEPT
Magnitude of strongest bin (0.0-1.0)
void registerDetector(shared_ptr< Detector > detector) FL_NO_EXCEPT
float getEqBass() FL_NO_EXCEPT
void onEqualizer(function< void(const detector::Equalizer &)> callback) FL_NO_EXCEPT
shared_ptr< detector::TempoAnalyzer > mTempoAnalyzer
bool getEqIsSilence() FL_NO_EXCEPT
shared_ptr< detector::Backbeat > getBackbeatDetector() FL_NO_EXCEPT
float getMoodArousal() FL_NO_EXCEPT
void configureNoiseFloorTracker(const NoiseFloorTrackerConfig &config) FL_NO_EXCEPT
Configure noise floor tracker.
void onVibeMidSpike(function< void()> callback) FL_NO_EXCEPT
float getTrebleRaw() FL_NO_EXCEPT
void onBeatPhase(function< void(float phase)> callback) FL_NO_EXCEPT
float getVibeMidAtt() FL_NO_EXCEPT
void onMood(function< void(const detector::Mood &mood)> callback) FL_NO_EXCEPT
void configureEqualizer(const detector::EqualizerConfig &config) FL_NO_EXCEPT
Configure equalizer detector tuning parameters.
shared_ptr< detector::DropDetector > getDropDetector() FL_NO_EXCEPT
void onEnergy(function< void(float rms)> callback) FL_NO_EXCEPT
float getPitchConfidence() FL_NO_EXCEPT
void onTransientWithStrength(function< void(float strength)> callback) FL_NO_EXCEPT
void onDynamicTrend(function< void(float trend)> callback) FL_NO_EXCEPT
void onBackbeat(function< void(u8 beatNumber, float confidence, float strength)> callback) FL_NO_EXCEPT
float getNoteVelocity() FL_NO_EXCEPT
void onDropImpact(function< void(float impact)> callback) FL_NO_EXCEPT
float getMidLevel() FL_NO_EXCEPT
float getVibeBass() FL_NO_EXCEPT
SignalConditioner mSignalConditioner
float getTempoBPM() FL_NO_EXCEPT
void setNoiseFloorTrackingEnabled(bool enabled) FL_NO_EXCEPT
Enable/disable noise floor tracking.
shared_ptr< detector::Downbeat > mDownbeatDetector
shared_ptr< detector::Percussion > mPercussionDetector
float getEqDominantFreqHz() FL_NO_EXCEPT
Frequency of strongest bin (Hz)
void onTempoUnstable(function< void()> callback) FL_NO_EXCEPT
float getDropImpact() FL_NO_EXCEPT
float getDownbeatConfidence() FL_NO_EXCEPT
shared_ptr< detector::ChordDetector > mChordDetector
float getDynamicTrend() FL_NO_EXCEPT
bool isSnare() FL_NO_EXCEPT
void onVocalStart(function< void()> callback) FL_NO_EXCEPT
shared_ptr< detector::Note > mNoteDetector
float getVibeTreb() FL_NO_EXCEPT
float getGain() const FL_NO_EXCEPT
void onMeasureBeat(function< void(u8 beatNumber)> callback) FL_NO_EXCEPT
void setGain(float gain) FL_NO_EXCEPT
Set a simple digital gain multiplier applied to each sample before detector.
shared_ptr< detector::FrequencyBands > getFrequencyBands() FL_NO_EXCEPT
float getBassRaw() FL_NO_EXCEPT
void configureSignalConditioner(const SignalConditionerConfig &config) FL_NO_EXCEPT
Configure signal conditioner.
float getTrebleLevel() FL_NO_EXCEPT
shared_ptr< detector::EqualizerDetector > mEqualizerDetector
shared_ptr< detector::Beat > mBeatDetector
bool isDiminuendo() FL_NO_EXCEPT
float getMeasurePhase() FL_NO_EXCEPT
float getTransientStrength() FL_NO_EXCEPT
shared_ptr< Context > mContext
float getEqVolume() FL_NO_EXCEPT
shared_ptr< detector::Backbeat > mBackbeatDetector
shared_ptr< detector::EqualizerDetector > getEqualizerDetector() FL_NO_EXCEPT
float getVibeVol() FL_NO_EXCEPT
void onDownbeat(function< void()> callback) FL_NO_EXCEPT
void onTransient(function< void()> callback) FL_NO_EXCEPT
float getNoteConfidence() FL_NO_EXCEPT
shared_ptr< detector::Percussion > getPercussionDetector() FL_NO_EXCEPT
void onVibeBassSpike(function< void()> callback) FL_NO_EXCEPT
shared_ptr< detector::Beat > getBeatDetector() FL_NO_EXCEPT
void onBuildupStart(function< void()> callback) FL_NO_EXCEPT
void setSampleRate(int sampleRate) FL_NO_EXCEPT
Set the sample rate for all frequency-based calculations.
shared_ptr< detector::KeyDetector > mKeyDetector
float getBassLevel() FL_NO_EXCEPT
shared_ptr< detector::Downbeat > getDownbeatDetector() FL_NO_EXCEPT
bool isVibeMidSpike() FL_NO_EXCEPT
void onHiHat(function< void()> callback) FL_NO_EXCEPT
shared_ptr< detector::Silence > getSilenceDetector() FL_NO_EXCEPT
shared_ptr< detector::Note > getNoteDetector() FL_NO_EXCEPT
shared_ptr< detector::Vibe > mVibeDetector
bool isVibeBassSpike() FL_NO_EXCEPT
bool isKick() FL_NO_EXCEPT
float getKeyConfidence() FL_NO_EXCEPT
const Sample & getSample() const FL_NO_EXCEPT
float getVibeVolAtt() FL_NO_EXCEPT
float getBackbeatConfidence() FL_NO_EXCEPT
shared_ptr< detector::TempoAnalyzer > getTempoAnalyzer() FL_NO_EXCEPT
shared_ptr< detector::MoodAnalyzer > getMoodAnalyzer() FL_NO_EXCEPT
shared_ptr< detector::BuildupDetector > mBuildupDetector
float getMidRaw() FL_NO_EXCEPT
float getEqMid() FL_NO_EXCEPT
void setSignalConditioningEnabled(bool enabled) FL_NO_EXCEPT
Enable/disable signal conditioning pipeline (DC removal, spike filter, noise gate)
bool mNoiseFloorTrackingEnabled
shared_ptr< detector::DynamicsAnalyzer > getDynamicsAnalyzer() FL_NO_EXCEPT
float getPeakLevel() FL_NO_EXCEPT
float getVibeMid() FL_NO_EXCEPT
void reset() FL_NO_EXCEPT
void onBuildup(function< void(const detector::Buildup &)> callback) FL_NO_EXCEPT
shared_ptr< detector::Vibe > getVibeDetector() FL_NO_EXCEPT
u32 getSilenceDuration() FL_NO_EXCEPT
float getEqZcf() FL_NO_EXCEPT
u8 getCurrentBeatNumber() FL_NO_EXCEPT
shared_ptr< detector::Transient > mTransientDetector
bool isCrescendo() FL_NO_EXCEPT
float getTempoConfidence() FL_NO_EXCEPT
void updateFromContext(shared_ptr< Context > externalContext) FL_NO_EXCEPT
void onChordEnd(function< void()> callback) FL_NO_EXCEPT
void onVibeLevels(function< void(const detector::VibeLevels &)> callback) FL_NO_EXCEPT
void onBass(function< void(float level)> callback) FL_NO_EXCEPT
float getEqBin(int index) FL_NO_EXCEPT
float getEqTreble() FL_NO_EXCEPT
void onCrescendo(function< void()> callback) FL_NO_EXCEPT
float getEnergy() FL_NO_EXCEPT
shared_ptr< detector::ChordDetector > getChordDetector() FL_NO_EXCEPT
vector< shared_ptr< Detector > > mActiveDetectors
shared_ptr< detector::EnergyAnalyzer > mEnergyAnalyzer
void onVocal(function< void(u8 active)> callback) FL_NO_EXCEPT
static fl::shared_ptr< Processor > createWithAutoInput(fl::shared_ptr< IInput > input) FL_NO_EXCEPT
void onKeyEnd(function< void()> callback) FL_NO_EXCEPT
float getBuildupProgress() FL_NO_EXCEPT
void setMicProfile(MicProfile profile) FL_NO_EXCEPT
Set microphone correction profile for frequency response compensation.
void onDropEvent(function< void(const detector::Drop &)> callback) FL_NO_EXCEPT
shared_ptr< detector::KeyDetector > getKeyDetector() FL_NO_EXCEPT
NoiseFloorTracker mNoiseFloorTracker
shared_ptr< detector::Pitch > mPitchDetector
void onSilenceDuration(function< void(u32 durationMs)> callback) FL_NO_EXCEPT
void onSnare(function< void()> callback) FL_NO_EXCEPT
shared_ptr< detector::Pitch > getPitchDetector() FL_NO_EXCEPT
float getVibeBassAtt() FL_NO_EXCEPT
void onTom(function< void()> callback) FL_NO_EXCEPT
bool mSignalConditioningEnabled
void onVocalEnd(function< void()> callback) FL_NO_EXCEPT
shared_ptr< detector::FrequencyBands > mFrequencyBands
void onDrop(function< void()> callback) FL_NO_EXCEPT
void onDiminuendo(function< void()> callback) FL_NO_EXCEPT
float getVibeTrebAtt() FL_NO_EXCEPT
shared_ptr< detector::BuildupDetector > getBuildupDetector() FL_NO_EXCEPT
shared_ptr< detector::Silence > mSilenceDetector
void onVibeTrebSpike(function< void()> callback) FL_NO_EXCEPT
shared_ptr< detector::DropDetector > mDropDetector
void onChord(function< void(const detector::Chord &chord)> callback) FL_NO_EXCEPT
int getSampleRate() const FL_NO_EXCEPT
bool isSilent() FL_NO_EXCEPT
void onKey(function< void(const detector::Key &key)> callback) FL_NO_EXCEPT
bool isTom() FL_NO_EXCEPT
float getBackbeatStrength() FL_NO_EXCEPT
float getBeatConfidence() FL_NO_EXCEPT
void onSilenceStart(function< void()> callback) FL_NO_EXCEPT
void onBuildupPeak(function< void()> callback) FL_NO_EXCEPT
bool isVibeTrebSpike() FL_NO_EXCEPT
void onSilenceEnd(function< void()> callback) FL_NO_EXCEPT
float getMoodValence() FL_NO_EXCEPT
shared_ptr< detector::MoodAnalyzer > mMoodAnalyzer
bool isHiHat() FL_NO_EXCEPT
float getBuildupIntensity() FL_NO_EXCEPT
void onVocalConfidence(function< void(float confidence)> callback) FL_NO_EXCEPT
u8 getCurrentNote() FL_NO_EXCEPT
bool isValid() const FL_NO_EXCEPT
Handle & then(function< void()> on_then) FL_NO_EXCEPT
Sets the callback invoked when the task runs successfully.
shared_ptr< T > lock() const FL_NO_EXCEPT
shared_ptr< T > make_shared(Args &&... args) FL_NO_EXCEPT
Configuration for the equalizer detector.
MicProfile
Microphone frequency response correction profile.
@ None
No correction (flat response assumed)
static float clampNeg1To1(float v) FL_NO_EXCEPT
static float clamp01(float v) FL_NO_EXCEPT
Configuration for signal conditioning pipeline.
Configuration for noise floor tracking.
Handle every_ms(int interval_ms) FL_NO_EXCEPT
Creates a task that runs at a fixed millisecond interval.
u8 u8 fract8 blur_amount FL_NO_EXCEPT
CRGB sample(const CRGB *grid, const XYMap &xyMap, float x, float y, SampleMode mode) FL_NO_EXCEPT
Sample a pixel from a 2D CRGB grid at floating-point coordinates.
VectorN< T, INLINED_SIZE > vector_inlined
Base definition for an LED controller.
Snapshot of equalizer state, passed to onEqualizer callbacks.