57 using NoteArray = std::array<NoteState, kMaxNumActiveNotes>;
59 std::bitset<kHighestKeyboardNote> states;
63 [[nodiscard]] NoteArray::iterator begin() {
return notes.begin(); }
65 [[nodiscard]] NoteArray::iterator end() {
return notes.begin() + count; }
67 [[nodiscard]] NoteArray::const_iterator begin()
const {
return notes.begin(); }
69 [[nodiscard]] NoteArray::const_iterator end()
const {
return notes.begin() + count; }
71 NoteArray::size_type enableNote(uint8_t note, uint8_t velocity,
bool generatedNote =
false,
72 int16_t* mpeValues =
nullptr) {
75 if (note >= kHighestKeyboardNote) {
78 if (noteEnabled(note)) {
79 for (
auto i = 0; i < notes.size(); ++i) {
80 auto& noteState = notes[i];
81 if (noteState.note == note) {
82 noteState.activationCount++;
87 if (count == kMaxNumActiveNotes) {
91 NoteArray::size_type idx = count++;
94 state.velocity = velocity;
96 if (mpeValues !=
nullptr) {
97 memcpy(&state.mpeValues, mpeValues,
sizeof(state.mpeValues));
105 [[nodiscard]]
constexpr bool noteEnabled(uint8_t note)
const {
return note < kHighestKeyboardNote && states[note]; }