pinobatch / pently

Scalable music engine for NES games
zlib License
72 stars 4 forks source link

Arpeggio inversion #14

Closed pinobatch closed 7 years ago

pinobatch commented 7 years ago

Once arpeggios have names, the next step is to derive names for a chord's first inversion and second inversion. These move notes from the bottom of a chord to the top.

To calculate an inversion of an arpeggio whose low nibble is zero, such as 70, subtract it from C0. This preserves the ratio for 50:50 2-note arpeggios. Otherwise:

  1. Calculate all three nibbles of the arpeggio.
  2. Replace all 0 nibbles with C.
  3. Subtract the nibble with the lowest value from all nibbles.
  4. Rotate left by nibbles until a 0 is in the top position, and drop it.

Three worked examples:

Arp  3nib  Cify  Sub   Rot
47   047   C47   803   038
07   007   CC7   550   055
77   077   C77   500   005

Inserting /1 or /2 after an arpeggio should perform inversion once or twice.

orelative
# this
EN47 c4. EN47/1 e EN47/1 g2.
# does the same as this
EN47 c4. EN38 e EN59 g2.