Documented the midi state
This commit is contained in:
parent
5a62509789
commit
f315a75d35
1 changed files with 38 additions and 0 deletions
|
|
@ -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<std::chrono::steady_clock::time_point, 128> noteOnTimes { };
|
||||
/**
|
||||
* @brief Stores the velocity of the note ons for currently
|
||||
* depressed notes.
|
||||
*
|
||||
*/
|
||||
std::array<uint8_t, 128> lastNoteVelocities { };
|
||||
/**
|
||||
* @brief Current known values for the CCs.
|
||||
*
|
||||
*/
|
||||
CCValueArray cc;
|
||||
};
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue