62 u32 timestamp = context->getTimestamp();
63 float energy = context->getRMS();
165 int midiNote =
static_cast<int>(
A4_MIDI_NOTE + semitones + 0.5f);
171 if (midiNote > 127) {
175 return static_cast<u8>(midiNote);
184 float semitones =
static_cast<float>(note) -
A4_MIDI_NOTE;
189 if (note ==
NO_NOTE || hz <= 0.0f) {
194 if (noteFrequency <= 0.0f) {
215 float weightedVelocity = normalizedEnergy * confidence;
218 int velocity =
static_cast<int>(weightedVelocity * 126.0f) + 1;
220 return static_cast<u8>(
fl::clamp(velocity, 1, 127));
243 int semitoneDistance =
fl::abs(
static_cast<int>(newNote) -
static_cast<int>(currentNote));
function_list< void(u8 note, u8 velocity)> onNoteOn
float calculatePitchBend(float hz, u8 note) const
void fireCallbacks() override
float mVelocitySensitivity
~Note() FL_NOEXCEPT override
static constexpr u8 A4_MIDI_NOTE
float midiNoteToFrequency(u8 note) const
bool shouldTriggerNoteOn(float confidence, float pitch) const
bool shouldTriggerNoteOff(float confidence, bool voiced) const
function_list< void(u8 note, u8 velocity)> onNoteChange
function_list< void(u8 note)> onNoteOff
shared_ptr< Pitch > mPitchDetector
u8 frequencyToMidiNote(float hz) const
u8 calculateVelocity(float energy, float confidence) const
void update(shared_ptr< Context > context) override
static constexpr float A4_FREQUENCY
bool shouldTriggerNoteChange(u8 newNote, u8 currentNote) const
static constexpr u8 NO_NOTE
Pitch - Continuous pitch tracking using autocorrelation.
float powf(float base, float exponent) FL_NOEXCEPT
shared_ptr< T > make_shared(Args &&... args) FL_NOEXCEPT
constexpr enable_if< is_fixed_point< T >::value, T >::type abs(T x) FL_NOEXCEPT
float logf(float value) FL_NOEXCEPT
constexpr enable_if< is_fixed_point< T >::value, T >::type clamp(T x, T lo, T hi) FL_NOEXCEPT
Base definition for an LED controller.