Last active
August 2, 2019 19:30
-
-
Save caseypeter10/d247eeb95f7a9f6ae244 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def note_filter(key): | |
if key in ['C','G','D','A','E','B','F#','C#']: | |
return ['C','C#','D','D#','E','F','F#','G','G#','A','A#','B',] | |
else: | |
return ['C','Db','D','Eb','E','F','Gb','G','Ab','A','Bb','B'] | |
def string_prep(start, notes): | |
#This function is intended to provide an organized string of notes that can be used to generate the | |
#note values for a guitar string | |
prepared_notes = [] | |
note_counter = 0 | |
found_note = 0 | |
while note_counter < len(notes): | |
if notes[note_counter] == start: | |
found_note = note_counter #records the location of the open string note in the raw note list | |
while note_counter < len(notes): | |
prepared_notes.append(notes[note_counter]) | |
#not sure where to up the note_counter seems to cause scale_on_board | |
#to just return first note of each string | |
note_counter = note_counter + 1 | |
if note_counter > 11: | |
#following if statement necessary for handling key of C | |
if start == 'C': | |
return prepared_notes | |
note_counter = 0 #starts over at beginning of notes | |
elif note_counter == found_note :#breaks out of prepared list creation | |
return prepared_notes | |
#note_counter = note_counter + 1 | |
else: | |
note_counter = note_counter + 1 | |
def scale_finder(key,notes): | |
#generates major_scale based on filtering a list returned by the string_prep | |
#function | |
organized_on_key = string_prep(key, notes) | |
note_number = 0 | |
major_scale = [] | |
while note_number < len(organized_on_key): | |
if note_number == 0: | |
major_scale.append(organized_on_key[note_number]) | |
elif note_number == 2: | |
major_scale.append(organized_on_key[note_number]) | |
elif note_number == 4: | |
major_scale.append(organized_on_key[note_number]) | |
elif note_number == 5: | |
major_scale.append(organized_on_key[note_number]) | |
elif note_number == 7: | |
major_scale.append(organized_on_key[note_number]) | |
elif note_number == 9: | |
major_scale.append(organized_on_key[note_number]) | |
elif note_number == 11: | |
major_scale.append(organized_on_key[note_number]) | |
note_number = note_number + 1 | |
return major_scale | |
def fretboard(tunings,key): | |
fretboard = [] | |
# takes in a list of tunings and then strings are generated from those tunings | |
# using the string prep function and appending the result of each string creation | |
# to the list fretboard | |
for i in tunings: | |
fretboard.append(string_prep(i,note_filter(key))) | |
return fretboard | |
def fretboard_printer(fretboard): | |
#formats the printing of the fretboard nicely | |
for i in fretboard: | |
print i | |
return | |
def scale_on_board(scale,fretboard): | |
#adds a * to list values that are also in the scale | |
for string_index, string in enumerate(fretboard): | |
for fret, pitch in enumerate(string): | |
if pitch in scale: | |
fretboard[string_index][fret] += '*' | |
return fretboard | |
standard_fretboard = fretboard(['E','A','D','G','B','E'],'C') | |
#print standard_fretboard | |
#print scale_finder('B',note_filter('B')) | |
#print string_prep('C',note_filter('C')) | |
#print note_filter('C') | |
#print standard_fretboard | |
fretboard_w_scale = scale_on_board(scale_finder('C',note_filter('C')),standard_fretboard) | |
fretboard_printer(fretboard_w_scale) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment