FastLED 3.9.15
Loading...
Searching...
No Matches
vocal_detector.h
Go to the documentation of this file.
1#pragma once
2
3#include "fl/stl/function.h"
4#include "fl/stl/noexcept.h"
5
6namespace fl {
7namespace audio {
8namespace detector {
9
10class Vocal {
11public:
14
15 void update(shared_ptr<Context> context);
16 void reset();
17
18 // Vocal state change callbacks (multiple listeners supported)
19 function_list<void(u8 active)> onVocal; // Called when vocal state changes
20 function_list<void()> onVocalStart; // Called when vocals start
21 function_list<void()> onVocalEnd; // Called when vocals end
22
23 // Configuration
24 void setThreshold(float threshold) { mThreshold = threshold; }
25
26 // Getters
27 bool isVocalActive() const { return mVocalActive; }
28 float getConfidence() const { return mConfidence; }
29 float getSpectralCentroid() const { return mSpectralCentroid; }
30 float getSpectralRolloff() const { return mSpectralRolloff; }
31 float getFormantRatio() const { return mFormantRatio; }
32
33private:
34 // Vocal detection state
35 bool mVocalActive;
37 float mConfidence;
39
40 // Spectral features
41 float mSpectralCentroid; // Measure of frequency distribution
42 float mSpectralRolloff; // Frequency point where energy is concentrated
43 float mFormantRatio; // Relationship between key formant frequencies
44
45 // Spectral feature calculations
49
50 // Vocal detection algorithm
51 bool detectVocal(float centroid, float rolloff, float formantRatio);
52};
53
54} // namespace detector
55} // namespace audio
56} // namespace fl
function_list< void(u8 active)> onVocal
Definition vocal.h:35
float estimateFormantRatio(const fft::Bins &fft)
bool detectVocal(float centroid, float rolloff, float formantRatio)
void setThreshold(float threshold)
Definition vocal.h:42
function_list< void()> onVocalStart
Definition vocal.h:36
float calculateSpectralCentroid(const fft::Bins &fft)
function_list< void()> onVocalEnd
Definition vocal.h:37
void update(shared_ptr< Context > context) override
Definition vocal.cpp.hpp:26
float getSpectralCentroid() const
float calculateSpectralRolloff(const fft::Bins &fft)
unsigned char u8
Definition stdint.h:131
Base definition for an LED controller.
Definition crgb.hpp:179
#define FL_NOEXCEPT