int32 mode of the scale (0=ion, 1=dor, 2=phy, 3=lyd, 4=myx, 5=aeo, 6=loc)
int32 scale alteration(0=no alteration, 1=based on harmonic minor, 2= based on melodic minor, 4= based on harmonic major)
int32 offset
int32.positive I
int32.positive II
int32.positive III
int32.positive IV
int32.positive V
int32.positive VI
int32.positive VII
uint32_t scale[4] = {
// these are all ionian scales!
0x024579B0, // no alteration: 0, 2, 4, 5, 7, 9, 11
0x024589B0, // harm min base: 0, 2, 4, 5, 8, 9, 11 (augmented fifth)
0x024689B0, // melo min base: 0, 2, 4, 6, 8, 9, 11 (augmented fourth and
// fifth)
0x024578B0 // harm maj base: 0, 2, 4, 5, 7, 8, 11 (diminished sixth)
};
// every 4 bits represent a note, starting from bits 31-28 -> root note
// bits 3-0 are meaningless
uint32_t mask = 0xF0000000;
uint32_t alt = inlet_alteration & 3;
uint32_t mode = (inlet_mode) < 7 ? (inlet_mode > -1 ? inlet_mode : 0) : 0;
uint32_t ofs = (inlet_offset) < 7 ? (inlet_offset > -1 ? inlet_offset : 0) : 0;
uint32_t first = ((scale[alt] << (mode * 4)) & mask) >> 28;
uint32_t o[7];
for (int i = mode; i < 7; i++)
o[i - mode] = (((scale[alt] << (i * 4)) & mask) >> 28) - first;
for (int i = 0; i < mode; i++)
o[7 + i - mode] = 12 + (((scale[alt] << (i * 4)) & mask) >> 28) - first;
outlet_I = (0 + ofs) > 6 ? 12 + o[0 + ofs - 6] : o[0 + ofs];
outlet_II = (1 + ofs) > 6 ? 12 + o[1 + ofs - 6] : o[1 + ofs];
outlet_III = (2 + ofs) > 6 ? 12 + o[2 + ofs - 6] : o[2 + ofs];
outlet_IV = (3 + ofs) > 6 ? 12 + o[3 + ofs - 6] : o[3 + ofs];
outlet_V = (4 + ofs) > 6 ? 12 + o[4 + ofs - 6] : o[4 + ofs];
outlet_VI = (5 + ofs) > 6 ? 12 + o[5 + ofs - 6] : o[5 + ofs];
outlet_VII = (6 + ofs) > 6 ? 12 + o[6 + ofs - 6] : o[6 + ofs];