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.end() + count; }
71 NoteArray::size_type enableNote(uint8_t note, uint8_t velocity,
bool generatedNote =
false,
72 int16_t* mpeValues =
nullptr) {
73 if (noteEnabled(note)) {
74 for (
auto i = 0; i < notes.size(); ++i) {
75 auto& noteState = notes[i];
76 if (noteState.note == note) {
77 noteState.activationCount++;
82 if (count == kMaxNumActiveNotes) {
86 NoteArray::size_type idx = count++;
89 state.velocity = velocity;
91 if (mpeValues !=
nullptr) {
92 memcpy(&state.mpeValues, mpeValues,
sizeof(state.mpeValues));
100 [[nodiscard]]
constexpr bool noteEnabled(uint8_t note)
const {
return states[note]; }