int32 select
int32 key
int32 chordOct
int32 chordmode
int32 inverse
int32 bass
int32 arp
bool32 minor
int32 chord1
int32 chord2
int32 chord3
int32 chord4
int32 bass
int32 arp
int32 chordOct
int32 stepchord
int32 chordmode
int32 stepmode
int32 bassOct
int32 BassMax
int32 arpOct
int32 ArpMax
frac32.u.map inverse
bool32.tgl sel
int note[14] = {0, 2, 4, 5, 7, 9, 11, 0, 2, 3, 5, 7, 8, 10};
int i;
int nt[8];
int32_t select[4];
int offset[60] = {2, 4, 6, 2, 4, 5, 1, 3, 6, 2, 3, 6, 2, 3, 5, 3, 4, 6, 1, 3,
5, 1, 4, 6, 1, 3, 4, 1, 4, 5, 1, 2, 5, 1, 2, 4, 1, 5, 6, 2,
5, 6, 2, 3, 4, 1, 2, 3, 3, 4, 5, 3, 5, 6, 4, 5, 6, 1, 2, 6};
int chordmode = (param_chordmode + inlet_chordmode) * param_stepmode;
chordmode = chordmode - (chordmode / 20) * 20;
select[0] = (inlet_select * param_stepchord + (inlet_select >> 2));
select[1] = (inlet_select * param_stepchord + (inlet_select >> 2)) +
offset[chordmode * 3];
select[2] = (inlet_select * param_stepchord + (inlet_select >> 2)) +
offset[chordmode * 3 + 1];
select[3] = (inlet_select * param_stepchord + (inlet_select >> 2)) +
offset[chordmode * 3 + 2];
for (i = 0; i < 4; i++) {
select[i] = select[i] - (select[i] / 7) * 7;
nt[i] = note[select[i] + inlet_minor * 7] - inlet_minor * 3;
}
int32_t inverse = (inlet_inverse + (param_inverse >> 19));
nt[0] = nt[0] + (inverse & 1 ? 12 : 0);
nt[1] = nt[1] + (inverse & 3 ? 12 : 0);
nt[2] = nt[2] + (inverse & 7 ? 12 : 0);
nt[3] = nt[3] + (inverse & 15 ? 12 : 0);
nt[0] = nt[0] + (inverse & 31 ? +24 : 0);
nt[1] = nt[1] + (inverse & 63 ? +24 : 0);
nt[2] = nt[2] + (inverse & 127 ? +24 : 0);
nt[3] = nt[3] + (inverse & 255 ? +24 : 0);
int key = inlet_key * 7 - (inlet_key * 7 / 12) * 12;
key = key > 0 ? key : key + 12;
int ns = nt[0];
ns = ns - (ns / 12) * 12;
ns = ns > 0 ? ns : ns + 12;
int arp = inlet_arp + select[0];
arp = arp > 0 ? arp : -arp;
int arpOct = arp / 7;
arp = arp - arpOct * 7;
arpOct = arpOct - (arpOct / param_ArpMax) * param_ArpMax;
int bass = inlet_bass / 12;
bass = bass - (bass / param_BassMax) * param_BassMax;
bass = bass > 0 ? bass : bass + param_BassMax;
bass += param_bassOct;
int chordoctave = (inlet_chordOct + param_chordOct) * 12 + key;
outlet_chord1 = nt[0] + chordoctave;
outlet_chord2 = nt[1] + chordoctave;
outlet_chord3 = nt[2] + chordoctave;
outlet_chord4 = nt[3] + chordoctave;
int br = nt[(inlet_bass + select[0]) & 3] -
(nt[(inlet_bass + select[0]) & 3] / 12) * 12;
br = br > 0 ? br : br + 12;
outlet_bass = br + key + bass * 12;
if (param_sel) {
outlet_arp = note[arp + inlet_minor * 7] + (arpOct + param_arpOct) * 12 +
key - inlet_minor * 3;
} else {
int nr = nt[arp & 3] - (nt[arp & 3] / 12) * 12;
nr = nr > 0 ? nr : nr + 12;
outlet_arp = nr + (arpOct + param_arpOct) * 12 + key;
}