#pragma once #include #include #include #include #define SYNTH_NOTE_QUEUE_SIZE 128 enum class NoteEventType { NoteOn, NoteOff }; struct NoteEvent { NoteEventType type; // noteOn or noteOff uint8_t note; // 0-128, a keyboard goes 0-87 float velocity; // 0-1, from a midi instrument its 0-127 though std::chrono::time_point timestamp; }; // the queue is to keep track of note events from the UI/input thread to the audio engine thread class NoteQueue { public: NoteQueue() = default; ~NoteQueue() = default; bool push(const NoteEvent& event); bool pop(NoteEvent& event); private: std::array buffer_; std::atomic head_{ 0 }; std::atomic tail_{ 0 }; };