frac32 root note pitch
int32 mode of the scale constructed on the root note (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 first grade offset
frac32 I
frac32 II
frac32 III
frac32 IV
frac32 V
frac32 VI
frac32 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 =
inlet_root + (((0 + ofs) > 6 ? 12 + o[0 + ofs - 7] : o[0 + ofs]) << 21);
outlet_II =
inlet_root + (((1 + ofs) > 6 ? 12 + o[1 + ofs - 7] : o[1 + ofs]) << 21);
outlet_III =
inlet_root + (((2 + ofs) > 6 ? 12 + o[2 + ofs - 7] : o[2 + ofs]) << 21);
outlet_IV =
inlet_root + (((3 + ofs) > 6 ? 12 + o[3 + ofs - 7] : o[3 + ofs]) << 21);
outlet_V =
inlet_root + (((4 + ofs) > 6 ? 12 + o[4 + ofs - 7] : o[4 + ofs]) << 21);
outlet_VI =
inlet_root + (((5 + ofs) > 6 ? 12 + o[5 + ofs - 7] : o[5 + ofs]) << 21);
outlet_VII =
inlet_root + (((6 + ofs) > 6 ? 12 + o[6 + ofs - 7] : o[6 + ofs]) << 21);