19#define SUSTAIN_BIT 0x04
82 const int off_d1 = &
n-
ndesc;
85 for(
int i=0;
i<off_d1; ++
i)
102 if(
ndesc[desc_id].off())
106 auto &nd =
ndesc[desc_id-1];
107 if(nd.age == 0 && nd.note == note && nd.sendto == sendto
108 && nd.playing() && nd.legatoMirror == legato && nd.canSustain())
150 cnt += (
bool)
sdesc[
i].note;
160 ndesc[desc_id].note = note;
161 ndesc[desc_id].sendto = sendto;
162 ndesc[desc_id].size += 1;
164 ndesc[desc_id].legatoMirror = legato;
173 sdesc[sdesc_id] = desc;
190 }
catch (std::bad_alloc &ba) {
191 std::cerr <<
"failed to insert legato note: " << ba.what() << std::endl;
202 synth.note->legatonote(par);
203 }
catch (std::bad_alloc& ba) {
204 std::cerr <<
"failed to create legato note: " << ba.what() << std::endl;
212 if(desc.note == note) {
213 desc.makeUnsustainable();
230 int actually_free=
sizeof(
sdesc)/
sizeof(
sdesc[0]);
232 actually_free -= desc.size;
234 return actually_free < sdesc_count;
246 bool running[256] = {0};
249 if(desc.playing() || desc.sustained())
250 running[desc.note] =
true;
253 int running_count = 0;
254 for(
int i=0;
i<256; ++
i)
255 running_count += running[
i];
257 return running_count;
262 if(notes_to_kill <= 0)
268 if(to_kill ==
NULL) {
272 }
else if(to_kill->
released() && nd.playing()) {
276 }
else if(nd.age > oldest && !(to_kill->
playing() && nd.released())) {
285 if(tk.released() || tk.sustained())
295 if(
d.playing() ||
d.sustained()) {
298 s.note->releasekey();
307 s.note->releasekey();
334 s.note->memory.dealloc(
s.note);
349 case 0:
return "OFF ";
350 case 1:
return "PLAY";
351 case 2:
return "SUST";
352 case 3:
return "RELA";
353 default:
return "INVD";
370 int last_valid_desc = 0;
379 for(
int i=0;
i<=last_valid_desc; ++
i) {
382 new_length[
i] += (
bool)
sdesc[cum_old++].note;
390 for(
int i=0;
i<=last_valid_desc; ++
i) {
392 if(new_length[
i] != 0)
403 for(
int i=0;
i<=last_valid_desc; ++
i)
404 total_notes+=cur_length[
i];
407 for(
int i=0;
i<total_notes; ++
i)
418 printf(
"NotePool::dump<\n");
420 " Note %d:%d age(%d) note(%d) sendto(%d) status(%s) legato(%d) type(%d) kit(%d) ptr(%p)\n";
428 note_id, descriptor_id,
429 d.age,
d.note,
d.sendto,
433 printf(
">NotePool::dump\n");
#define POLYPHONY
Definition globals.h:114
#define NOTE_MASK
Definition NotePool.cpp:20
#define SUSTAIN_BIT
Definition NotePool.cpp:19
#define EXPECTED_USAGE
Definition NotePool.h:18
int usedSynthDesc(void) const
Definition NotePool.cpp:143
void insertLegatoNote(uint8_t note, uint8_t sendto, SynthDescriptor desc)
Definition NotePool.cpp:184
void enforceKeyLimit(int limit)
Definition NotePool.cpp:259
void applyLegato(LegatoParams &par)
Definition NotePool.cpp:196
SynthDescriptor sdesc[POLYPHONY *EXPECTED_USAGE]
Definition NotePool.h:66
void killNote(note_t note)
Definition NotePool.cpp:316
bool existsRunningNote(void) const
Definition NotePool.cpp:238
bool full(void) const
Definition NotePool.cpp:220
void insertNote(uint8_t note, uint8_t sendto, SynthDescriptor desc, bool legato=false)
Definition NotePool.cpp:154
int getRunningNotes(void) const
Definition NotePool.cpp:244
void entomb(NoteDescriptor &d)
Definition NotePool.cpp:338
NotePool(void)
Definition NotePool.cpp:32
NoteDescriptor ndesc[POLYPHONY]
Definition NotePool.h:65
void dump(void)
Definition NotePool.cpp:416
int usedNoteDesc(void) const
Definition NotePool.cpp:132
void kill(NoteDescriptor &d)
Definition NotePool.cpp:324
activeNotesIter activeNotes(NoteDescriptor &n)
Definition NotePool.cpp:80
void cleanup(void)
Definition NotePool.cpp:357
bool synthFull(int sdesc_count) const
Definition NotePool.cpp:228
bool needs_cleaning
Definition NotePool.h:67
void upgradeToLegato(void)
Definition NotePool.cpp:176
void releasePlayingNotes(void)
Definition NotePool.cpp:292
void killAllNotes(void)
Definition NotePool.cpp:310
void release(NoteDescriptor &d)
Definition NotePool.cpp:303
activeDescIter activeDesc(void)
Definition NotePool.cpp:120
void makeUnsustainable(uint8_t note)
Definition NotePool.cpp:209
virtual SynthNote * cloneLegato(void)=0
register unsigned j
Definition inflate.c:1576
unsigned d
Definition inflate.c:940
register unsigned i
Definition inflate.c:1575
unsigned s
Definition inflate.c:1555
unsigned char uint8_t
Definition mid.cpp:98
Definition zynaddsubfx-src.cpp:569
T limit(T val, T min, T max)
Definition Util.h:85
NoteStatus
Definition NotePool.cpp:24
@ KEY_OFF
Definition NotePool.cpp:25
@ KEY_RELEASED_AND_SUSTAINED
Definition NotePool.cpp:27
@ KEY_RELEASED
Definition NotePool.cpp:28
@ KEY_PLAYING
Definition NotePool.cpp:26
const SYNTH_T & synth
Definition PADnoteParameters.h:210
const char * getStatus(int status_bits)
Definition NotePool.cpp:345
static int getMergeableDescriptor(uint8_t note, uint8_t sendto, bool legato, NotePool::NoteDescriptor *ndesc)
Definition NotePool.cpp:97
Definition SynthNote.h:35
int midinote
Definition SynthNote.h:39
bool off(void) const
Definition NotePool.cpp:54
uint32_t age
Definition NotePool.h:32
bool operator==(NoteDescriptor)
Definition NotePool.cpp:90
bool released(void) const
Definition NotePool.cpp:49
uint8_t size
Definition NotePool.h:36
void doSustain(void)
Definition NotePool.cpp:65
bool playing(void) const
Definition NotePool.cpp:39
bool canSustain(void) const
Definition NotePool.cpp:70
uint8_t status
Definition NotePool.h:37
void setStatus(uint8_t s)
Definition NotePool.cpp:59
void makeUnsustainable(void)
Definition NotePool.cpp:75
bool sustained(void) const
Definition NotePool.cpp:44
uint8_t note
Definition NotePool.h:33
uint8_t sendto
Definition NotePool.h:34
SynthNote * note
Definition NotePool.h:58
int n
Definition crypt.c:458
_WDL_CSTRING_PREFIX void INT_PTR const char * format
Definition wdlcstring.h:263