Browse Source

Cleanup

master
cancel 5 years ago
parent
commit
acc598bd8e
  1. 8
      sim.c

8
sim.c

@ -99,12 +99,12 @@ ORCA_PURE static bool oper_has_neighboring_bang(Glyph const *gbuf, Usz h, Usz w,
// Returns UINT8_MAX if not a valid note.
static U8 midi_note_number_of(Glyph g) {
int deg, sharp = (g & 1 << 5) >> 5; // sharp=1 if lowercase
g &= ~(1 << 5); // make uppercase
if (g < 'A' || g > 'Z') // A through Z only
int sharp = (g & 1 << 5) >> 5; // sharp=1 if lowercase
g &= ~(1 << 5); // make uppercase
if (g < 'A' || g > 'Z') // A through Z only
return UINT8_MAX;
// We want C=0, D=1, E=2, etc. A and B are equivalent to H and I.
deg = g <= 'B' ? 'G' - 'B' + g - 'A' : g - 'C';
int deg = g <= 'B' ? 'G' - 'B' + g - 'A' : g - 'C';
return (U8)(deg / 7 * 12 + (I8[]){0, 2, 4, 5, 7, 9, 11}[deg % 7] + sharp);
}

Loading…
Cancel
Save