-
Notifications
You must be signed in to change notification settings - Fork 10
Algorithms for converting Western notes into Sky piano
Tracey edited this page Jul 8, 2020
·
2 revisions
- 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}
- Subtract to find the interval in semitones
- 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 note into base 7, relative to a major scale:
- where the note name is the digit
- and note octave is the 7s column
- Convert into base 5
- where note digit gives the column
- and the 5s digit gives the row
- Try performing calculate_note_for_coordinate using the above algorithm, for each major scale.
- Matches are arranged in order of least amount of errors.