frac32 stretch
bool32 track
int32 p1
int32 p2
int32 p3
int32 p4
int32 key
int32 scale
int32 temper
frac32 n1
frac32 n2
frac32 n3
frac32 n4
objref scale
int32_t out;
int key;
int scale;
int32_t STR;
int32_t temper;
int32_t N[4];
int32_t scalar(int NT) {
int32_t pitch = NT + 64;
int32_t octave = pitch / 7;
int semitone = pitch - octave * 7;
int32_t note = (attr_scale.note[semitone + scale] + octave * 12) - 112 + key
<< 21;
int mn = (note + (1 << 20) >> 21) + 8;
int32_t stretch = mn / 12;
stretch = stretch * (STR / 1000);
int oct = mn / 12 * 12;
oct = note < 0 ? oct - 12 : oct;
mn = mn - oct;
int tmpr = temper;
tmpr = tmpr - tmpr / 137 * 137;
tmpr += tmpr < 0 ? 137 : 0;
tmpr = tmpr * 12;
return out = attr_scale.TMPR[mn + tmpr] * 0 + note + stretch;
};
N[0] = 0;
N[1] = 0;
N[2] = 0;
N[3] = 0;
scale = inlet_scale;
scale = scale - scale / 46 * 46;
scale = scale < 0 ? scale + 46 : scale;
scale = scale * 7;
key = (inlet_key)*5 - 4;
key = key - (key / 12) * 12;
key = key < 0 ? key + 12 : key;
temper = inlet_temper;
STR = inlet_stretch;
if (inlet_track > 0) {
N[0] = scalar(inlet_p1);
N[1] = scalar(inlet_p2);
N[2] = scalar(inlet_p3);
N[3] = scalar(inlet_p4);
}
outlet_n1 = N[0];
outlet_n2 = N[1];
outlet_n3 = N[2];
outlet_n4 = N[3];