int32 count
frac32 P1
frac32 A1
frac32 B1
frac32 N2
frac32 V2
frac32 P2
frac32 A2
frac32 B2
frac32 N3
frac32 V3
frac32 P3
frac32 A3
frac32 B3
frac32 N4
frac32 V4
frac32 P4
frac32 A4
frac32 B4
bool32 key pressed, no retrigger legato
bool32 G2
bool32 G3
bool32 G4
frac32.bipolar midi note number (-64..63)
frac32.positive note-on velocity
int8_t N[4];
int32_t G[4];
uint8_t V[4];
int i;
int32_t c0[4];
int32_t c1[4];
int32_t c2[4];
int8_t T[4];
outlet_N1 = N[0] << 21;
outlet_G1 = G[0];
outlet_V1 = V[0] << 20;
outlet_P1 = c0[0];
outlet_A1 = c1[0];
outlet_B1 = c2[0];
outlet_N2 = N[1] << 21;
outlet_G2 = G[1];
outlet_V2 = V[1] << 20;
outlet_P2 = c0[1];
outlet_A2 = c1[1];
outlet_B2 = c2[1];
outlet_N3 = N[2] << 21;
outlet_G3 = G[2];
outlet_V3 = V[2] << 20;
outlet_P3 = c0[2];
outlet_A3 = c1[2];
outlet_B3 = c2[2];
outlet_N4 = N[3] << 21;
outlet_G4 = G[3];
outlet_V4 = V[3] << 20;
outlet_P4 = c0[3];
outlet_A4 = c1[3];
outlet_B4 = c2[3];
if ((status == MIDI_NOTE_ON + attr_midichannel) && (data2)) {
int S = 1;
i = -1;
while ((S == 1) && (i < 4)) {
i += S > 0 ? 1 : 0;
S = G[i];
}
if (i == 4) {
i = (int32_t)GenerateRandomNumber() & 3;
}
V[i] = data2;
N[i] = data1 - 64;
G[i] = 1;
T[i] = (data1 - 36);
T[i] = (T[i] - T[i] / 16 * 16) * 3;
} else if (((status == MIDI_NOTE_ON + attr_midichannel) && (!data2)) ||
(status == MIDI_NOTE_OFF + attr_midichannel)) {
for (i = 0; i < 4; i++) {
if (N[i] == data1 - 64) {
G[i] = 0;
}
}
} else if ((status == attr_midichannel + MIDI_CONTROL_CHANGE) &&
(data1 == MIDI_C_ALL_NOTES_OFF)) {
for (i = 0; i < 4; i++) {
G[i] = 0;
}
}
for (i = 0; i < 4; i++) {
if ((status == attr_midichannel + MIDI_CONTROL_CHANGE) &&
(data1 == (T[i] + 23)) && (G[i])) {
c0[i] = data2 << 20;
}
if ((status == attr_midichannel + MIDI_CONTROL_CHANGE) &&
(data1 == (T[i] + 24)) && (G[i])) {
c1[i] = data2 << 20;
}
if ((status == attr_midichannel + MIDI_CONTROL_CHANGE) &&
(data1 == (T[i] + 25)) && (G[i])) {
c2[i] = data2 << 20;
}
}