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);
108void Processor::onOnset(
function<
void(
float)> callback) {
109 auto detector = getBeatDetector();
110 detector->onOnset.add(callback);
113void Processor::onTempoChange(function<
void(
float,
float)> callback) {
114 auto detector = getBeatDetector();
115 detector->onTempoChange.add(callback);
118void Processor::onTempo(
function<
void(
float)> callback) {
119 auto detector = getTempoAnalyzer();
120 detector->onTempo.add(callback);
123void Processor::onTempoWithConfidence(
function<
void(
float,
float)> 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);
143void Processor::onMid(
function<
void(
float)> callback) {
144 auto detector = getFrequencyBands();
145 detector->onMidLevel.add(callback);
148void Processor::onTreble(function<
void(
float)> callback) {
149 auto detector = getFrequencyBands();
150 detector->onTrebleLevel.add(callback);
153void Processor::onFrequencyBands(
function<
void(
float,
float,
float)> callback) {
154 auto detector = getFrequencyBands();
155 detector->onLevelsUpdate.add(callback);
160 detector->onEqualizer.add(callback);
164 auto detector = getEnergyAnalyzer();
168void Processor::onNormalizedEnergy(
function<
void(
float)> callback) {
169 auto detector = getEnergyAnalyzer();
170 detector->onNormalizedEnergy.add(callback);
173void Processor::onPeak(function<
void(
float)> callback) {
174 auto detector = getEnergyAnalyzer();
175 detector->onPeak.add(callback);
178void Processor::onAverageEnergy(
function<
void(
float)> callback) {
179 auto detector = getEnergyAnalyzer();
180 detector->onAverageEnergy.add(callback);
185 detector->onTransient.add(callback);
189 auto detector = getTransientDetector();
190 detector->onTransientWithStrength.add(callback);
193void Processor::onAttack(
function<
void(
float)> callback) {
194 auto detector = getTransientDetector();
195 detector->onAttack.add(callback);
198void Processor::onSilence(function<
void(
u8)> callback) {
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);
233void Processor::onCompressionRatio(
function<
void(
float)> callback) {
234 auto detector = getDynamicsAnalyzer();
235 detector->onCompressionRatio.add(callback);
238void Processor::onPitch(function<
void(
float)> callback) {
239 auto detector = getPitchDetector();
240 detector->onPitch.add(callback);
243void Processor::onPitchWithConfidence(
function<
void(
float,
float)> callback) {
244 auto detector = getPitchDetector();
245 detector->onPitchWithConfidence.add(callback);
248void Processor::onPitchChange(
function<
void(
float)> callback) {
249 auto detector = getPitchDetector();
250 detector->onPitchChange.add(callback);
253void Processor::onVoiced(
function<
void(
u8)> callback) {
254 auto detector = getPitchDetector();
255 detector->onVoiced.add(callback);
258void Processor::onNoteOn(
function<
void(
u8,
u8)> callback) {
259 auto detector = getNoteDetector();
260 detector->onNoteOn.add(callback);
263void Processor::onNoteOff(
function<
void(
u8)> callback) {
264 auto detector = getNoteDetector();
265 detector->onNoteOff.add(callback);
268void Processor::onNoteChange(
function<
void(
u8,
u8)> callback) {
269 auto detector = getNoteDetector();
270 detector->onNoteChange.add(callback);
279 auto detector = getDownbeatDetector();
280 detector->onMeasureBeat.add(callback);
283void Processor::onMeterChange(
function<
void(
u8)> callback) {
284 auto detector = getDownbeatDetector();
285 detector->onMeterChange.add(callback);
288void Processor::onMeasurePhase(function<
void(
float)> callback) {
289 auto detector = getDownbeatDetector();
290 detector->onMeasurePhase.add(callback);
305 detector->onVocalStart.add(callback);
319 callback(
detector->getConfidence());
324void Processor::onPercussion(
function<
void(detector::PercussionType)> callback) {
325 auto detector = getPercussionDetector();
326 detector->onPercussionHit.add(callback);
354void Processor::onChordChange(
function<
void(
const detector::Chord&)> callback) {
355 auto detector = getChordDetector();
356 detector->onChordChange.add(callback);
369void Processor::onKeyChange(
function<
void(
const detector::Key&)> callback) {
370 auto detector = getKeyDetector();
371 detector->onKeyChange.add(callback);
384void Processor::onMoodChange(
function<
void(
const detector::Mood&)> callback) {
385 auto detector = getMoodAnalyzer();
386 detector->onMoodChange.add(callback);
389void Processor::onValenceArousal(function<
void(
float,
float)> callback) {
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 onBuildupProgress(function< void(float progress)> callback) FL_NOEXCEPT
void onBuildupPeak(function< void()> callback) FL_NOEXCEPT
void onTempoUnstable(function< void()> callback) FL_NOEXCEPT
float getEqDominantFreqHz() FL_NOEXCEPT
Frequency of strongest bin (Hz)
void onBuildup(function< void(const detector::Buildup &)> callback) FL_NOEXCEPT
float getMoodArousal() FL_NOEXCEPT
shared_ptr< detector::Vocal > mVocalDetector
float getVibeVol() FL_NOEXCEPT
void onVibeBassSpike(function< void()> callback) FL_NOEXCEPT
float getMidLevel() FL_NOEXCEPT
shared_ptr< detector::Percussion > getPercussionDetector() FL_NOEXCEPT
static fl::shared_ptr< Processor > createWithAutoInput(fl::shared_ptr< IInput > input) FL_NOEXCEPT
bool isSilent() FL_NOEXCEPT
shared_ptr< detector::DropDetector > getDropDetector() FL_NOEXCEPT
float getVibeBassAtt() FL_NOEXCEPT
shared_ptr< detector::DynamicsAnalyzer > mDynamicsAnalyzer
void onSnare(function< void()> callback) FL_NOEXCEPT
shared_ptr< detector::FrequencyBands > getFrequencyBands() FL_NOEXCEPT
void onVocalEnd(function< void()> callback) FL_NOEXCEPT
int getSampleRate() const FL_NOEXCEPT
shared_ptr< detector::BuildupDetector > getBuildupDetector() FL_NOEXCEPT
shared_ptr< detector::TempoAnalyzer > mTempoAnalyzer
u32 getSilenceDuration() FL_NOEXCEPT
void onTransientWithStrength(function< void(float strength)> callback) FL_NOEXCEPT
float getNoteVelocity() FL_NOEXCEPT
float getEqTreble() FL_NOEXCEPT
void onKick(function< void()> callback) FL_NOEXCEPT
float getEqBass() FL_NOEXCEPT
void updateFromContext(shared_ptr< Context > externalContext) FL_NOEXCEPT
float getEqVolumeNormFactor() FL_NOEXCEPT
float getBassRaw() FL_NOEXCEPT
bool isVibeBassSpike() FL_NOEXCEPT
SignalConditioner mSignalConditioner
shared_ptr< detector::Downbeat > mDownbeatDetector
shared_ptr< detector::Percussion > mPercussionDetector
shared_ptr< detector::Note > getNoteDetector() FL_NOEXCEPT
void onChordEnd(function< void()> callback) FL_NOEXCEPT
shared_ptr< detector::EqualizerDetector > getEqualizerDetector() FL_NOEXCEPT
bool isVibeTrebSpike() FL_NOEXCEPT
float getEnergy() FL_NOEXCEPT
float getDownbeatConfidence() FL_NOEXCEPT
float getTrebleRaw() FL_NOEXCEPT
shared_ptr< detector::ChordDetector > mChordDetector
float getChordConfidence() FL_NOEXCEPT
void onDropImpact(function< void(float impact)> callback) FL_NOEXCEPT
shared_ptr< detector::Note > mNoteDetector
void onBass(function< void(float level)> callback) FL_NOEXCEPT
void onSilenceDuration(function< void(u32 durationMs)> callback) FL_NOEXCEPT
void onBackbeat(function< void(u8 beatNumber, float confidence, float strength)> callback) FL_NOEXCEPT
void onEqualizer(function< void(const detector::Equalizer &)> callback) FL_NOEXCEPT
void onBuildupStart(function< void()> callback) FL_NOEXCEPT
void onVocal(function< void(u8 active)> callback) FL_NOEXCEPT
void onDropEvent(function< void(const detector::Drop &)> callback) FL_NOEXCEPT
shared_ptr< detector::Vibe > getVibeDetector() FL_NOEXCEPT
bool isHiHat() FL_NOEXCEPT
shared_ptr< detector::EnergyAnalyzer > getEnergyAnalyzer() FL_NOEXCEPT
float getEqBin(int index) FL_NOEXCEPT
void onSilenceStart(function< void()> callback) FL_NOEXCEPT
void onBeat(function< void()> callback) FL_NOEXCEPT
u8 getCurrentNote() FL_NOEXCEPT
void setNoiseFloorTrackingEnabled(bool enabled) FL_NOEXCEPT
Enable/disable noise floor tracking.
shared_ptr< detector::EqualizerDetector > mEqualizerDetector
shared_ptr< detector::Beat > mBeatDetector
float getNoteConfidence() FL_NOEXCEPT
float getEqZcf() FL_NOEXCEPT
u8 getCurrentBeatNumber() FL_NOEXCEPT
float getBackbeatStrength() FL_NOEXCEPT
shared_ptr< Context > mContext
shared_ptr< detector::Backbeat > mBackbeatDetector
bool getEqIsSilence() FL_NOEXCEPT
bool isCrescendo() FL_NOEXCEPT
void onVibeTrebSpike(function< void()> callback) FL_NOEXCEPT
shared_ptr< detector::Silence > getSilenceDetector() FL_NOEXCEPT
void onTempoStable(function< void()> callback) FL_NOEXCEPT
void onDiminuendo(function< void()> callback) FL_NOEXCEPT
float getVibeMid() FL_NOEXCEPT
float getBassLevel() FL_NOEXCEPT
float getMoodValence() FL_NOEXCEPT
shared_ptr< detector::KeyDetector > mKeyDetector
float getDropImpact() FL_NOEXCEPT
bool isDiminuendo() FL_NOEXCEPT
float getTrebleLevel() FL_NOEXCEPT
void onDrop(function< void()> callback) FL_NOEXCEPT
void onCrescendo(function< void()> callback) FL_NOEXCEPT
void setMicProfile(MicProfile profile) FL_NOEXCEPT
Set microphone correction profile for frequency response compensation.
void setGain(float gain) FL_NOEXCEPT
Set a simple digital gain multiplier applied to each sample before detector.
void onEnergy(function< void(float rms)> callback) FL_NOEXCEPT
float getEqMid() FL_NOEXCEPT
float getEqVolume() FL_NOEXCEPT
shared_ptr< detector::Vibe > mVibeDetector
shared_ptr< detector::Transient > getTransientDetector() FL_NOEXCEPT
void onBuildupEnd(function< void()> callback) FL_NOEXCEPT
float getDynamicTrend() FL_NOEXCEPT
shared_ptr< detector::TempoAnalyzer > getTempoAnalyzer() FL_NOEXCEPT
float getKeyConfidence() FL_NOEXCEPT
void setSampleRate(int sampleRate) FL_NOEXCEPT
Set the sample rate for all frequency-based calculations.
shared_ptr< detector::Downbeat > getDownbeatDetector() FL_NOEXCEPT
shared_ptr< detector::BuildupDetector > mBuildupDetector
void onKey(function< void(const detector::Key &key)> callback) FL_NOEXCEPT
bool mNoiseFloorTrackingEnabled
void onBeatPhase(function< void(float phase)> callback) FL_NOEXCEPT
shared_ptr< detector::KeyDetector > getKeyDetector() FL_NOEXCEPT
float getTransientStrength() FL_NOEXCEPT
void onChord(function< void(const detector::Chord &chord)> callback) FL_NOEXCEPT
float getTempoConfidence() FL_NOEXCEPT
float getEqVolumeDb() FL_NOEXCEPT
Volume in approximate dB.
const Sample & getSample() const FL_NOEXCEPT
void configureNoiseFloorTracker(const NoiseFloorTrackerConfig &config) FL_NOEXCEPT
Configure noise floor tracker.
void onSilenceEnd(function< void()> callback) FL_NOEXCEPT
void onKeyEnd(function< void()> callback) FL_NOEXCEPT
float getGain() const FL_NOEXCEPT
float getPitch() FL_NOEXCEPT
shared_ptr< detector::Transient > mTransientDetector
float getMidRaw() FL_NOEXCEPT
void onHiHat(function< void()> callback) FL_NOEXCEPT
void onVocalStart(function< void()> callback) FL_NOEXCEPT
float getBPM() FL_NOEXCEPT
void onDynamicTrend(function< void(float trend)> callback) FL_NOEXCEPT
float getMeasurePhase() FL_NOEXCEPT
bool isVibeMidSpike() FL_NOEXCEPT
float getVibeTreb() FL_NOEXCEPT
void onVibeLevels(function< void(const detector::VibeLevels &)> callback) FL_NOEXCEPT
void onVocalConfidence(function< void(float confidence)> callback) FL_NOEXCEPT
float getTempoBPM() FL_NOEXCEPT
shared_ptr< detector::Pitch > getPitchDetector() FL_NOEXCEPT
float getEqAutoGain() FL_NOEXCEPT
vector< shared_ptr< Detector > > mActiveDetectors
void setSignalConditioningEnabled(bool enabled) FL_NOEXCEPT
Enable/disable signal conditioning pipeline (DC removal, spike filter, noise gate)
void onTransient(function< void()> callback) FL_NOEXCEPT
shared_ptr< detector::EnergyAnalyzer > mEnergyAnalyzer
shared_ptr< detector::Beat > getBeatDetector() FL_NOEXCEPT
NoiseFloorTracker mNoiseFloorTracker
float getBuildupIntensity() FL_NOEXCEPT
shared_ptr< detector::Pitch > mPitchDetector
void update(const Sample &sample) FL_NOEXCEPT
float getVibeTrebAtt() FL_NOEXCEPT
void configureSignalConditioner(const SignalConditionerConfig &config) FL_NOEXCEPT
Configure signal conditioner.
float getEqDominantMagnitude() FL_NOEXCEPT
Magnitude of strongest bin (0.0-1.0)
void onTom(function< void()> callback) FL_NOEXCEPT
float getBuildupProgress() FL_NOEXCEPT
void onMood(function< void(const detector::Mood &mood)> callback) FL_NOEXCEPT
void onDownbeat(function< void()> callback) FL_NOEXCEPT
bool mSignalConditioningEnabled
shared_ptr< detector::Vocal > getVocalDetector() FL_NOEXCEPT
shared_ptr< detector::MoodAnalyzer > getMoodAnalyzer() FL_NOEXCEPT
shared_ptr< detector::FrequencyBands > mFrequencyBands
bool isSnare() FL_NOEXCEPT
float getBeatConfidence() FL_NOEXCEPT
float getVibeBass() FL_NOEXCEPT
bool isKick() FL_NOEXCEPT
shared_ptr< detector::Silence > mSilenceDetector
shared_ptr< detector::ChordDetector > getChordDetector() FL_NOEXCEPT
void registerDetector(shared_ptr< Detector > detector) FL_NOEXCEPT
shared_ptr< detector::DropDetector > mDropDetector
float getBackbeatConfidence() FL_NOEXCEPT
float getPitchConfidence() FL_NOEXCEPT
void onMeasureBeat(function< void(u8 beatNumber)> callback) FL_NOEXCEPT
float getVibeMidAtt() FL_NOEXCEPT
float getVibeVolAtt() FL_NOEXCEPT
float getPeakLevel() FL_NOEXCEPT
shared_ptr< detector::MoodAnalyzer > mMoodAnalyzer
shared_ptr< detector::Backbeat > getBackbeatDetector() FL_NOEXCEPT
void onVibeMidSpike(function< void()> callback) FL_NOEXCEPT
float getVocalConfidence() FL_NOEXCEPT
void configureEqualizer(const detector::EqualizerConfig &config) FL_NOEXCEPT
Configure equalizer detector tuning parameters.
shared_ptr< detector::DynamicsAnalyzer > getDynamicsAnalyzer() FL_NOEXCEPT
bool isValid() const FL_NOEXCEPT
Handle & then(function< void()> on_then) FL_NOEXCEPT
shared_ptr< T > lock() const FL_NOEXCEPT
Configuration for the equalizer detector.
static float clamp01(float v)
MicProfile
Microphone frequency response correction profile.
@ None
No correction (flat response assumed)
static float clampNeg1To1(float v)
bool enabled
Enable noise floor tracking.
Configuration for signal conditioning pipeline.
Configuration for noise floor tracking.
Handle every_ms(int interval_ms)
CRGB sample(const CRGB *grid, const XYMap &xyMap, float x, float y, SampleMode mode)
Sample a pixel from a 2D CRGB grid at floating-point coordinates.
shared_ptr< T > make_shared(Args &&... args) FL_NOEXCEPT
VectorN< T, INLINED_SIZE > vector_inlined
Base definition for an LED controller.
Snapshot of equalizer state, passed to onEqualizer callbacks.