None
int32 step
int32 maxStep
int32.label step
const int32_t NOTE_GROUPING_LAG = (int32_t)(0.1f * 3000);
const int32_t SILENCE_RESET_DURATION = (int32_t)(0.2f * 3000);
int32_t lag = 0;
uint32_t step = 0; //[0, attr_maxStep] (attr_maxStep included)
uint32_t silence = 0;
bool gate;
bool trig;
bool np[128];
gate = false;
trig = false;
for (int j = 0; j < 128; j++)
np[j] = false;
if (lag > 0)
lag--;
if (trig) {
if (lag <= 0 && step < param_maxStep)
step++;
lag = NOTE_GROUPING_LAG;
}
if (!gate) {
if (silence > 20)
lag = 0;
silence++;
} else {
silence = 0;
}
if (silence >= SILENCE_RESET_DURATION)
step = 0;
disp_step = step;
outlet_step = step;
trig = false;
if ((status == MIDI_NOTE_ON + attr_midichannel) && (data2)) {
trig = true;
np[data1] = true;
} else if (((status == MIDI_NOTE_ON + attr_midichannel) && (!data2)) ||
(status == MIDI_NOTE_OFF + attr_midichannel)) {
np[data1] = false;
} else if ((status == attr_midichannel + MIDI_CONTROL_CHANGE) &&
(data1 == MIDI_C_ALL_NOTES_OFF)) {
for (int j = 0; j < 128; j++)
np[j] = false;
}
gate = false;
for (int j = 0; j < 128; j++) {
if (np[j]) {
gate = true;
break;
}
}