#pragma once #include #include #include "../globals.h" //Expected upper bound of synths given that max polyphony is hit #define EXPECTED_USAGE 3 struct LegatoParams; class NotePool { public: typedef uint8_t note_t; //Currently this wastes a ton of bits due ot the legatoMirror flag struct NoteDescriptor { //acceptable overlap after 2 minutes //run time at 48kHz 8 samples per buffer //19 bit minimum uint32_t age; uint8_t note; uint8_t sendto; //max of 16 kit elms and 3 kit items per uint8_t size; uint8_t status; bool legatoMirror; bool operator==(NoteDescriptor); }; //To be pedantic this wastes 2 or 6 bytes per descriptor //depending on 32bit/64bit alignment rules struct SynthDescriptor { SynthNote *note; uint8_t type; uint8_t kit; }; //Pool of notes NoteDescriptor ndesc[POLYPHONY]; SynthDescriptor sdesc[POLYPHONY*EXPECTED_USAGE]; bool needs_cleaning; //Iterators struct activeNotesIter { SynthDescriptor *begin() {return _b;}; SynthDescriptor *end() {return _e;}; SynthDescriptor *_b; SynthDescriptor *_e; }; struct activeDescIter { activeDescIter(NotePool &_np):np(_np) { int off=0; for(int i=0; i