bool32 on
bool32 record
bool32 overdub
bool32 clear
bool32 recshift
int32 early
int32 length
int32 sets an offset for writing to the table
int32 polyphony
int32 Qstep
int32 stepunQ
int32 copy
int32 copyR
int32 erasenote
None
spinner bar
spinner voices
spinner channel
objref table
int seqlengthUNQ;
int budd;
int voiceoffset;
int on;
int overdub;
int record;
int offset;
int offsetC;
int offsetunQ1g;
int full;
int copyhold;
int copyR;
int onctrig;
int offctrig;
int inon;
int Anoteon;
int Avel;
int Aon;
int Aoff;
int Anoteoff;
int prevonunQ;
int etrig;
int earlyshift;
int prevoffunQ;
int copystep;
int copytrig;
int i;
int x;
int previ;
int erasenote;
seqlengthUNQ = ((attr_bar << 9) - ((attr_bar << 9) >> 2));
budd = ((seqlengthUNQ + seqlengthUNQ + seqlengthUNQ) * attr_voices);
voiceoffset = seqlengthUNQ + seqlengthUNQ + seqlengthUNQ;
on = inlet_on;
overdub = inlet_overdub;
record = inlet_record;
offset = inlet_offset + (voiceoffset * (inlet_polyphony));
offsetunQ1g = (offset + inlet_stepunQ);
erasenote = inlet_erasenote;
if ((inon) && (!overdub)) {
if (inlet_stepunQ ==
(((inlet_length << 9) - ((inlet_length << 9) >> 2)) - 2)) {
attr_table.array[offsetunQ1g] = Anoteon;
attr_table.array[offsetunQ1g + seqlengthUNQ + seqlengthUNQ] = 1;
inon = 0;
}
}
if (inlet_recshift) {
if (Aon) {
attr_table.array[offset] = Anoteon;
attr_table.array[offset + seqlengthUNQ] = Avel;
Aon = 0;
}
if (Aoff) {
attr_table.array[offset + 11] = Anoteoff;
attr_table.array[offset + seqlengthUNQ + seqlengthUNQ + 11] = Aoff;
Aoff = 0;
}
}
// record to buffer
if (!inlet_recshift) {
// noteon
if (Aon) {
// quantize
if ((inlet_early == 1) && !etrig) {
earlyshift = (12 - inlet_Qstep);
etrig = 1;
} else if ((inlet_early == 0) && !etrig) {
earlyshift = (0 - inlet_Qstep);
etrig = 1;
}
// unquantized
else if ((inlet_early == 3) && !etrig) {
earlyshift = (0);
etrig = 1;
}
attr_table.array[offsetunQ1g + earlyshift] = Anoteon;
attr_table.array[offsetunQ1g + seqlengthUNQ + earlyshift] = Avel;
Aon = 0;
}
// noteoff
if (Aoff) {
attr_table.array[offsetunQ1g + earlyshift] = Anoteoff;
attr_table.array[offsetunQ1g + seqlengthUNQ + seqlengthUNQ + earlyshift] =
Aoff;
Aoff = 0;
etrig = 0;
}
}
// copybuffer to clipslot && clear buffer
if ((inlet_copy != copystep)) {
copyhold = 1;
i = 0;
x = 0;
previ = -1;
copystep = inlet_copy;
copyR = inlet_copyR;
}
if (copyhold) {
// offsetC=inlet_offset+(voiceoffset*(inlet_polyphony));
if (i != previ) {
previ = i;
full = attr_table.array[(copyR + x + (inlet_offset + (voiceoffset * (i))))];
if (!full) {
offsetC = inlet_offset + x + (voiceoffset * (i));
copytrig = 1;
i = -1;
previ = -1;
}
if (full) {
i += 1;
if ((i == attr_voices) && (x == 0)) {
x = 1;
i = 0;
}
if ((i == attr_voices) && (x == 1)) {
i = -1;
previ = -1;
}
}
}
if (copytrig) {
if (inlet_record) {
attr_table.array[(copyR + offsetC)] =
(attr_table.array[copystep + offset]);
attr_table.array[(copyR + offsetC + seqlengthUNQ)] =
(attr_table.array[copystep + offset + seqlengthUNQ]);
attr_table.array[(copyR + offsetC + seqlengthUNQ + seqlengthUNQ)] =
(attr_table.array[copystep + offset + seqlengthUNQ + seqlengthUNQ]);
} else if ((!inlet_record)) {
if ((attr_table.array[copystep + offset]) > 0) {
attr_table.array[(copyR + offsetC)] =
(attr_table.array[copystep + offset]);
attr_table.array[(copyR + offsetC + seqlengthUNQ)] =
(attr_table.array[copystep + offset + seqlengthUNQ]);
attr_table.array[(copyR + offsetC + seqlengthUNQ + seqlengthUNQ)] =
(attr_table.array[copystep + offset + seqlengthUNQ + seqlengthUNQ]);
}
}
attr_table.array[(offset + copystep)] = 0;
attr_table.array[(offset + copystep + seqlengthUNQ)] = 0;
attr_table.array[(offset + copystep + seqlengthUNQ + seqlengthUNQ)] = 0;
copytrig = 0;
copyhold = 0;
}
}
Aon = 0;
Aoff = 0;
if ((dev != MIDI_DEVICE_INTERNAL) && ((record) || (overdub))) {
if ((status == MIDI_NOTE_ON + (attr_channel - 1)) && (data2)) {
if (data1 != erasenote) {
Anoteon = data1;
Avel = data2;
Aon = 1;
if (record) {
inon = 1;
}
}
}
if ((status == MIDI_NOTE_OFF + (attr_channel - 1)) ||
((status == MIDI_NOTE_ON + (attr_channel - 1)) && (!data2))) {
if (data1 == Anoteon) {
if (data1 != erasenote) {
Anoteoff = data1;
Avel = data2;
if (record) {
inon = 0;
}
Aoff = 1;
}
}
}
}