From 98ea64640d7b11aa26e97a423281de0bd8c773cb Mon Sep 17 00:00:00 2001 From: Kenneth Reitz Date: Tue, 5 Nov 2024 11:20:43 -0500 Subject: [PATCH] Refactor hello.py to rename it to examples/chord_charts.py and improve chord chart display and playback --- hello.py => examples/chord_charts.py | 6 +++++- song.py => examples/song.py | 0 2 files changed, 5 insertions(+), 1 deletion(-) rename hello.py => examples/chord_charts.py (95%) rename song.py => examples/song.py (100%) diff --git a/hello.py b/examples/chord_charts.py similarity index 95% rename from hello.py rename to examples/chord_charts.py index fb3dd54..bd741be 100644 --- a/hello.py +++ b/examples/chord_charts.py @@ -25,6 +25,7 @@ all_chords = sorted(CHARTS["western"].keys()) print("Standard Guitar Chord Charts:") print("-" * 30) + def fingering_to_tab(fingering): if not fingering: return "" @@ -39,7 +40,9 @@ def fingering_to_tab(fingering): if fret == 0: strings[string_num] = "0" + strings[string_num][1:] else: - strings[string_num] = "-" * (fret - 1) + str(fret) + strings[string_num][fret:] + strings[string_num] = ( + "-" * (fret - 1) + str(fret) + strings[string_num][fret:] + ) # Combine strings with newlines, and add string names tab = "e|" + strings[0] + "\n" @@ -50,6 +53,7 @@ def fingering_to_tab(fingering): tab += "E|" + strings[5] + "\n" return tab + for chord_name in all_chords: # Store original chord name for lookup lookup_name = chord_name diff --git a/song.py b/examples/song.py similarity index 100% rename from song.py rename to examples/song.py