The goal of this notebook is to generate the altered scales. That is, for the C altered scale, you want to implement a function generate the notes (only for octave 3 and above, since only predicting for melody notes with octave > 3)
[C3 D-3 E-3 F-3 (or E?) G-3 A-3 B-3 C4 D-4 E-4 ...]
This notebook isn't meant to have input or output for other files -- here you just want to brainstorm the function so you can put it in Predictive Chord Modeling (to better train the classifier). Not for use with N-Gram Pipeline!
# Generates the altered scale from octaves 3 to 6 for a pitch (e.g. G-)
# for a given note (e.g. G-3) in music21 style.
# Returns altered scale as list of music21 notes.
def genAltered(note='C3'):
# In case you have to convert a note (e.g. F#) into form below
def convertSharps(note):
pitch = ''.join([i for i in note if i.isdigit() is False])
enharmonic = {"C#" : "D-", "D#" : "E-", "E#" : "F", "F#" : "G-", "G#" : "A-", "A#" : "B-", "B#" : "C"}
if '#' in pitch: return enharmonic[pitch]
return pitch
# Get scale with dictionary. For example: allscales[note[:-1]]
allscales = {
"C" : ["C3", "D-3", "E-3", "E3", "G-3", "A-3", "B-3",
"C4", "D-4", "E-4", "E4", "G-4", "A-4", "B-4",
"C5", "D-5", "E-5", "E5", "G-5", "A-5", "B-5",
"C6", "D-6", "E-6", "E6", "G-6", "A-6", "B-6"],
"D-" : ["D-3", "D3", "E3", "F3", "G3", "A3", "B3",
"D-4", "D4", "E4", "F4", "G4", "A4", "B4",
"D-5", "D5", "E5", "F5", "G5", "A5", "B5",
"D-6", "D6", "E6", "F6", "G6", "A6", "B6"],
"D" : ["D3", "E-3", "F3", "G-3", "A-3", "B-3", "C4", "D4",
"E-4", "F4", "G-4", "A-4", "B-4", "C5", "D5",
"E-5", "F5", "G-5", "A-5", "B-5", "C6", "D6",
"E-6", "F6", "G-6", "A-6", "B-6"],
"E-" : ["D-3",
"E-3", "E3", "G-3", "G3", "A3", "B3", "D-4",
"E-4", "E4", "G-4", "G4", "A4", "B4", "D-5",
"E-5", "E5", "G-5", "G5", "A5", "B5", "D-6",
"E-6", "E6", "G-6", "G6", "A6", "B6"],
"F" : ["D-3", "E-3",
"F3", "G-3", "A-3", "A3", "B3", "D-4", "E-4",
"F4", "G-4", "A-4", "A4", "B4", "D-5", "E-5",
"F5", "G-5", "A-5", "A5", "B5", "D-6", "E-6",
"F6", "G-6", "A-6", "A6", "B6"],
"G-" : ["C3", "D3", "E3",
"G-3", "G3", "A3", "B-3", "C4", "D4", "E4",
"G-4", "G4", "A4", "B-4", "C5", "D5", "E5",
"G-5", "G5", "A5", "B-5", "C6", "D6", "E6",
"G-6", "G6", "A6", "B-6"],
"G" : ["D-3", "E-3", "F3",
"G3", "A-3", "B-3", "B3", "D-4", "E-4", "F4",
"G4", "A-4", "B-4", "B4", "D-5", "E-5", "F5",
"G5", "A-5", "B-5", "B5", "D-6", "E-6", "F6",
"G6", "A-6", "B-6", "B6"],
"A-" : ["C3", "D3", "E3", "G-3",
"A-3", "A3", "B3", "C4", "D4", "E4", "G-4",
"A-4", "A4", "B4", "C5", "D5", "E5", "G-5",
"A-5", "A5", "B5", "C6", "D6", "E6", "G-6",
"A-6", "A6", "B6"],
"A" : ["C3", "D-3", "E-3", "F3", "G3",
"A3", "B-3", "C4", "D-4", "E-4", "F4", "G4",
"A4", "B-4", "C5", "D-5", "E-5", "F5", "G5",
"A5", "B-5", "C6", "D-6", "E-6", "F6", "G6",
"A6", "B-6", "C7"],
"B-" : ["D-3", "D3", "E3", "G-3", "A-3",
"B-3", "B3", "D-4", "D4", "E4", "G-4", "A-4",
"B-4", "B4", "D-5", "D5", "E5", "G-5", "A-5",
"B-5", "B5", "D-6", "D6", "E6", "G-6", "A-6",
"B-6", "B6"],
"B" : ["C3", "D3", "E-3", "F3", "G3", "A3",
"B3", "C4", "D4", "E-4", "F4", "G4", "A4",
"B4", "C5", "D5", "E-5", "F5", "G5", "A5",
"B5", "C6", "D6", "E-6", "F6", "G6", "A6",
"B6"]}
pitch = ''.join([i for i in note if i.isdigit() is False])
pitch = convertSharps(note) # Rm. octaveinfo, eg. G-5 --> G-, G5->G
return allscales[pitch]
G-
['C3', 'D3', 'E3', 'G-3', 'G3', 'A3', 'B-3', 'C4', 'D4', 'E4', 'G-4', 'G4', 'A4', 'B-4', 'C5', 'D5', 'E5', 'G-5', 'G5', 'A5', 'B-5', 'C6', 'D6', 'E6', 'G-6', 'G6', 'A6', 'B-6']