frac32.bipolar pitch input
int32 sel
bool32 enable
frac32 p1
frac32 p2
frac32 p3
frac32 p4
frac32 p5
frac32 p6
frac32 p7
frac32 p8
bool32 t1
bool32 t2
bool32 t3
bool32 t4
bool32 t5
bool32 t6
bool32 t7
bool32 t8
bin16 chord1
bin16 chord2
bin16 chord3
bin16 chord4
bin16 chord5
bin16 chord6
bin16 chord7
bin16 chord8
int32 shift1
int32 shift2
int32 shift3
int32 shift4
int32 shift5
int32 shift6
int32 shift7
int32 shift8
int32_t PARAMETER;
int32_t pitch_out[8];
bool trig_out[8];
int shift_even;
int shift_odd;
int shift_even2;
int shift_odd2;
int addpitch;
for (int ii = 0; ii < 8; ii += 1) {
pitch_out[ii] = 0;
trig_out[ii] = 0;
}
switch (inlet_sel) {
case 0:
PARAMETER = param_chord1;
addpitch = param_shift1;
break;
case 1:
PARAMETER = param_chord2;
addpitch = param_shift2;
break;
case 2:
PARAMETER = param_chord3;
addpitch = param_shift3;
break;
case 3:
PARAMETER = param_chord4;
addpitch = param_shift4;
break;
case 4:
PARAMETER = param_chord5;
addpitch = param_shift5;
break;
case 5:
PARAMETER = param_chord6;
addpitch = param_shift6;
break;
case 6:
PARAMETER = param_chord7;
addpitch = param_shift7;
break;
case 7:
PARAMETER = param_chord8;
addpitch = param_shift8;
break;
default:
PARAMETER = 0;
}
if (PARAMETER &
(1 << 14)) // shift all odd pitches (I, III, V, VII, IX) by 12 semitones
shift_odd = 12;
else
shift_odd = 0;
if (PARAMETER &
(1 << 15)) // shift all even pitches (II, IV, VI, VIII, X) by 12 semitones
shift_even = 12;
else
shift_even = 0;
if (PARAMETER &
(1 << 12)) // shift all odd pitches (I, III, V, VII, IX) by 12 semitones
shift_odd2 = 12 << 21;
else
shift_odd2 = 0;
if (PARAMETER &
(1 << 13)) // shift all even pitches (II, IV, VI, VIII, X) by 12 semitones
shift_even2 = 12 << 21;
else
shift_even2 = 0;
int outc = 0;
bool outb = 1; // start from odd
for (int ii = 0; ii < 6; ii += 1) {
if (PARAMETER & (1 << (2 * ii)) && outc < 8) {
pitch_out[outc] = inlet_pitch + ((2 * ii + shift_odd + addpitch) << 21);
trig_out[outc] = 1;
if (outb)
pitch_out[outc] += shift_odd2;
else
pitch_out[outc] += shift_even2;
outc += 1;
outb = !outb;
}
if (PARAMETER & (1 << (2 * ii + 1)) && outc < 8) {
pitch_out[outc] =
inlet_pitch + ((2 * ii + 1 + shift_even + addpitch) << 21);
trig_out[outc] = 1;
if (outb)
pitch_out[outc] += shift_odd2;
else
pitch_out[outc] += shift_even2;
outc += 1;
outb = !outb;
}
}
while (outc < 8) {
trig_out[outc] = 0;
outc += 1;
}
outlet_p1 = pitch_out[0];
outlet_p2 = pitch_out[1];
outlet_p3 = pitch_out[2];
outlet_p4 = pitch_out[3];
outlet_p5 = pitch_out[4];
outlet_p6 = pitch_out[5];
outlet_p7 = pitch_out[6];
outlet_p8 = pitch_out[7];
if (inlet_enable) {
outlet_t1 = trig_out[0];
outlet_t2 = trig_out[1];
outlet_t3 = trig_out[2];
outlet_t4 = trig_out[3];
outlet_t5 = trig_out[4];
outlet_t6 = trig_out[5];
outlet_t7 = trig_out[6];
outlet_t8 = trig_out[7];
} else {
outlet_t1 = 0;
outlet_t2 = 0;
outlet_t3 = 0;
outlet_t4 = 0;
outlet_t5 = 0;
outlet_t6 = 0;
outlet_t7 = 0;
outlet_t8 = 0;
}