Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # Compute fingering required for playing chords on a Ukelele
- # Mike Kerry - Jan 2024
- scale = ["A", "Bb", "B", "C", "C#", "D", "Eb", "E", "F", "F#", "G", "Ab"]
- scale += scale
- base_notes_open = ["G", "C", "E", "A"] # Notes that open strings play
- base_note_offsets = [10, 3, 7, 0] # Open string notes relative to A
- chords = {"1,5,8": "", "1,5,8,10": "6", "1,5,8,11": "7", "1,5,8,12": "maj7",
- "1,4,8": "m", "1,4,8,10": "m6", "1,3,8,11": "m7"}
- strings = [0, 0, 0, 0]
- lastcombo = ""
- lastfullkey = ""
- high_fret = 4 # Highest fret wwe want to use
- chord_list = []
- for off1 in range(high_fret + 1):
- for off2 in range(high_fret + 1):
- for off3 in range(high_fret + 1):
- for off4 in range(high_fret + 1):
- strings[0] = scale[base_note_offsets[0] + off1]
- strings[1] = scale[base_note_offsets[1] + off2]
- strings[2] = scale[base_note_offsets[2] + off3]
- strings[3] = scale[base_note_offsets[3] + off4]
- for first_note in strings:
- first_note_index = scale.index(first_note)
- intervals = [] # compute a list of intervals from one string to all strings
- for second_note in strings:
- second_note_index = scale.index(second_note)
- interval = (second_note_index + 12 - first_note_index) % 12
- intervals.append(interval)
- intervals = list(set(intervals)) # drop duplicate intervals
- intervals.sort() # e.g. for major we want 1, 5, 8 not 5, 1, 8 etc.
- interval_key = ""
- for a in intervals:
- interval_key += str(a + 1) # count notes from 1, not 0
- interval_key += ","
- interval_key = interval_key[:-1] # drop the final comma
- if interval_key in chords: # Does this set of intervals make any desired chord?
- combo = f"{off1},{off2},{off3},{off4}"
- fullkey = f"{first_note}{chords[interval_key]}"
- if combo == lastcombo and fullkey == lastfullkey:
- continue # ignore duplicates
- lastcombo = combo
- lastfullkey = fullkey
- chord_list.append([fullkey, combo])
- chord_list.sort()
- # Print sorted results
- for item in chord_list:
- offsets = item[1]
- offlist = offsets.split(',')
- outline = f"{item[0]: <8} {item[1]: <10} "
- notes = []
- notes_str = ""
- for x, off in enumerate(offlist):
- off = int(off)
- idx = base_note_offsets[x] + off
- notes.append(scale[idx])
- notes_str += scale[idx]
- notes_str += " "
- notes_str += " "
- outline += notes_str[:12]
- if notes[0] in notes[1:] and item[1][0] != '0':
- outline += " or x,"
- outline += item[1][2:]
- print(outline)
Add Comment
Please, Sign In to add comment