int32 note
int32 key
frac32 Scaled
bool32 GateScale
bool32 GateSkip
int32 Skipped
frac32.s.map.kpitch Glide
bool32.tgl Bend
int8_t _scale[12];
int32_t note;
int32_t octave;
int32_t skipped;
int32_t key;
int32_t oldnote;
int32_t Scaled;
int32_t val;
int32_t Bend;
int a;
int trg;
_scale[0] = 0;
_scale[1] = 0;
_scale[2] = 2;
_scale[3] = 2;
_scale[4] = 4;
_scale[5] = 5;
_scale[6] = 5;
_scale[7] = 7;
_scale[8] = 7;
_scale[9] = 9;
_scale[10] = 9;
_scale[11] = 11;
a = 1;
key = (inlet_key * 7);
key = key - ((key / 12) * 12);
octave = (((inlet_note - key) / 12) * 12);
note = inlet_note - key - octave;
octave = note > 0 ? octave : octave - 12;
note = note > 0 ? note : note + 12;
Scaled = _scale[note] + octave + key;
outlet_Scaled = (Scaled << 21) + (val);
outlet_GateScale = ((Scaled) != oldnote);
outlet_GateSkip = inlet_note != Scaled;
if (outlet_GateSkip) {
skipped = inlet_note;
if (param_Bend) {
Bend = (Scaled - outlet_Skipped) + a;
val = ___SMMLA(val - (Bend << 21), (-1 << 26) + (param_Glide >> 1), val);
}
if (trg != 1) {
a = -a;
}
trg = 1;
} else {
Bend = 0;
val = 0;
trg = 0;
}
outlet_Skipped = skipped;
oldnote = Scaled;