From f315a75d35b2b62b7ce3009d140b2cfa32d85215 Mon Sep 17 00:00:00 2001 From: Paul Ferrand Date: Sat, 30 Nov 2019 00:53:09 +0100 Subject: [PATCH] Documented the midi state --- src/sfizz/MidiState.h | 38 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 38 insertions(+) diff --git a/src/sfizz/MidiState.h b/src/sfizz/MidiState.h index 11c97f7b..6035940d 100644 --- a/src/sfizz/MidiState.h +++ b/src/sfizz/MidiState.h @@ -5,8 +5,20 @@ namespace sfz { +/** + * @brief Holds the current "MIDI state", meaning the known state of all CCs + * currently, as well as the note velocities that triggered the currently + * pressed notes. + * + */ struct MidiState { + /** + * @brief Update the state after a note on event + * + * @param noteNumber + * @param velocity + */ inline void noteOn(int noteNumber, uint8_t velocity) { if (noteNumber >= 0 && noteNumber < 128) { @@ -15,6 +27,12 @@ struct MidiState } } + /** + * @brief Register a note off and get the note duration + * + * @param noteNumber + * @return float + */ inline float getNoteDuration(int noteNumber) const { if (noteNumber >= 0 && noteNumber < 128) { @@ -26,6 +44,12 @@ struct MidiState return 0.0f; } + /** + * @brief Get the note on velocity for a given note + * + * @param noteNumber + * @return uint8_t + */ inline uint8_t getNoteVelocity(int noteNumber) const { if (noteNumber >= 0 && noteNumber < 128) @@ -33,8 +57,22 @@ struct MidiState return 0; } + + /** + * @brief Stores the note on times. + * + */ std::array noteOnTimes { }; + /** + * @brief Stores the velocity of the note ons for currently + * depressed notes. + * + */ std::array lastNoteVelocities { }; + /** + * @brief Current known values for the CCs. + * + */ CCValueArray cc; }; }