Open | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 |
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
E | F | F#/Gb | G | G#/Ab | A | A#/Bb | B | C | C#/Db | D | D#/Eb | E | F | F#/Gb | G | G#/Ab | A | A#/Bb | B | C | C#/Db | D | D#/Eb | E |
B | C | C#/Db | D | D#/Eb | E | F | F#/Gb | G | G#/Ab | A | A#/Bb | B | C | C#/Db | D | D#/Eb | E | F | F#/Gb | G | G#/Ab | A | A#/Bb | B |
G | G#/Ab | A | A#/Bb | B | C | C#/Db | D | D#/Eb | E | F | F#/Gb | G | G#/Ab | A | A#/Bb | B | C | C#/Db | D | D#/Eb | E | F | F#/Gb | G |
D | D#/Eb | E | F | F#/Gb | G | G#/Ab | A | A#/Bb | B | C | C#/Db | D | D#/Eb | E | F | F#/Gb | G | G#/Ab | A | A#/Bb | B | C | C#/Db | D |
A | A#/Bb | B | C | C#/Db | D | D#/Eb | E | F | F#/Gb | G | G#/Ab | A | A#/Bb | B | C | C#/Db | D | D#/Eb | E | F | F#/Gb | G | G#/Ab | A |
E | F | F#/Gb | G | G#/Ab | A | A#/Bb | B | C | C#/Db | D | D#/Eb | E | F | F#/Gb | G | G#/Ab | A | A#/Bb | B | C | C#/Db | D | D#/Eb | E |
Created
February 14, 2021 09:04
-
-
Save mckelvin/9f8ba1a8d05a27a7ae5cfd7d608d1b40 to your computer and use it in GitHub Desktop.
This file contains 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
import csv | |
TWELVE_NOTES = ["C", "C#/Db", "D", "D#/Eb", "E", "F", "F#/Gb", "G", "G#/Ab", "A", "A#/Bb", "B"] | |
OPEN_STRING_NOTES = ["E", "B", "G", "D", "A", "E"] | |
N_FRETS = 24 | |
def generate_fretboard_matrix(): | |
mat = [] | |
headers = ["Open"] + [str(i) for i in range(1, N_FRETS + 1)] | |
mat.append(headers) | |
for string_note in OPEN_STRING_NOTES: | |
fst_idx = TWELVE_NOTES.index(string_note) | |
row = [TWELVE_NOTES[(fst_idx + i) % len(TWELVE_NOTES)] for i in range(N_FRETS + 1)] | |
mat.append(row) | |
return mat | |
class MarkDownTable: | |
""" | |
https://github.com/lzakharov/csv2md/blob/master/csv2md/table.py | |
""" | |
def __init__(self, cells): | |
self.cells = cells | |
self.widths = list(map(max, zip(*[list(map(len, row)) for row in cells]))) | |
def markdown(self, center_aligned_columns=None, right_aligned_columns=None): | |
def format_row(row): | |
return '| ' + ' | '.join(row) + ' |' | |
rows = [format_row([cell.ljust(width) for cell, width in zip(row, self.widths)]) for row in self.cells] | |
separators = ['-' * width for width in self.widths] | |
if right_aligned_columns is not None: | |
for column in right_aligned_columns: | |
separators[column] = ('-' * (self.widths[column] - 1)) + ':' | |
if center_aligned_columns is not None: | |
for column in center_aligned_columns: | |
separators[column] = ':' + ('-' * (self.widths[column] - 2)) + ':' | |
rows.insert(1, format_row(separators)) | |
return '\n'.join(rows) | |
def main(): | |
print(MarkDownTable(generate_fretboard_matrix()).markdown()) | |
if __name__ == "__main__": | |
main() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment