Skip to content

Algorithms for converting Western notes into Sky piano

Tracey edited this page Jul 8, 2020 · 2 revisions

Algorithms performed on Western / chromatic scale notes

Convert note to major scale interval, relative to a key

  1. Convert note and key into chromatic equivalents. These are defined per noteparser:
# English notation
self.CHROMATIC_SCALE_DICT = {'C': 0, 'C#': 1, 'Db': 1, 'D': 2, 'D#': 3, 'Eb': 3, 'E': 4, 'F': 5, 'F#': 6, 'Gb': 6, 'G': 7, 'G#': 8, 'Ab': 8, 'A': 9, 'A#': 10, 'Bb': 10, 'B': 11}
# Jianpu notation

self.CHROMATIC_SCALE_DICT = {'1': 0, '1#': 1, '2b': 1, '2': 2, '2#': 3, '3b': 3, '3': 4, '4': 5, '4#': 6, '5b': 6, '5': 7, '5#': 8, '6b': 8, '6': 9, '6#': 10, '7b': 10, '7': 11}
  1. Subtract to find the interval in semitones
  2. Convert interval in semitones to a major scale interval if possible
self.SEMITONE_INTERVAL_TO_MAJOR_SCALE_INTERVAL_DICT = {
            0: 0,  # 0 semitones means it’s the root note
            2: 1,  # 2 semitones means it’s a 2nd interval
            4: 2,  # 4 semitones means it’s a 3rd interval
            5: 3,  # 5 semitones means it’s a 4th interval
            7: 4,  # 7 semitones means it’s a 5th interval
            9: 5,  # 9 semitones means it’s a 6th interval
            11: 6  # 11 semitones means it’s a 7th interval
        }

Convert major scale note into Sky 3*5 keyboard

  1. Convert note into base 7, relative to a major scale:
  • where the note name is the digit
  • and note octave is the 7s column
  1. Convert into base 5
  • where note digit gives the column
  • and the 5s digit gives the row

Find key on a series of notes

  1. Try performing calculate_note_for_coordinate using the above algorithm, for each major scale.
  2. Matches are arranged in order of least amount of errors.

Further reading

https://github.com/sky-music/sky-python-music-sheet-maker/blob/687566fe1cbe5deb272615966f4427b6bad8e825/src/skymusic/parsers/noteparsers/noteparser.py

Playing in keys other than C - initial planning - Feedback - Sky: Children of the Light Fan Forum.pdf