Skip to content

Instantly share code, notes, and snippets.

@ricardo-valerio
Last active October 20, 2018 01:48
Show Gist options
  • Save ricardo-valerio/fe3acc7503fc6dc956e44a7488986a12 to your computer and use it in GitHub Desktop.
Save ricardo-valerio/fe3acc7503fc6dc956e44a7488986a12 to your computer and use it in GitHub Desktop.
Circle Progression in Music Theory
#!/usr/bin/python3
from termcolor import colored
from time import sleep as wait_a_few_seconds_between_chords
scales = {
"C" : ["C" , "D" , "E" , "F" , "G" , "A" , "B" ],
"Db": ["Db", "Eb", "F" , "Gb", "Ab", "Bb", "C" ],
"D" : ["D" , "E" , "Gb", "G" , "A" , "B" , "Db"],
"Eb": ["Eb", "F" , "G" , "Ab", "Bb", "C" , "D" ],
"E" : ["E" , "Gb", "Ab", "A" , "B" , "Db", "Eb"],
"F" : ["F" , "G" , "A" , "Bb", "C" , "D" , "E" ],
"Gb": ["Gb", "Ab", "Bb", "B" , "Db", "Eb", "F" ],
"G" : ["G" , "A" , "B" , "C" , "D" , "E" , "Gb"],
"Ab": ["Ab", "Bb", "C" , "Db", "Eb", "F" , "G" ],
"A" : ["A" , "B" , "Db", "D" , "E" , "Gb", "Ab"],
"Bb": ["Bb", "C" , "D" , "Eb", "F" , "G" , "A" ],
"B" : ["B" , "Db", "Eb", "E" , "Gb", "Ab", "Bb"]
}
circle_progression_roman_numerals = {
"I" : 1 , "IV" : 4,
"viiº": 7 , "iii": 3,
"vi" : 6 , "ii" : 2,
"V" : 5
}
def append_quality(scale_degree):
if scale_degree in {1, 4, 5}:
return " Maj"
elif scale_degree in {2, 3, 6}:
return " min"
else:
return " dim"
def attribute_color(scale_degree):
if scale_degree in {1, 4, 5}:
return "green"
elif scale_degree in {2, 3, 6}:
return "blue"
else:
return "red"
def main():
print() # initial separator
for key in scales:
print("----------------- Circle Progression in the Key of", key, "-----------------" )
for chord in circle_progression_roman_numerals:
print(colored(scales[key][circle_progression_roman_numerals[chord] - 1] +
append_quality(circle_progression_roman_numerals[chord]), color=attribute_color(circle_progression_roman_numerals[chord])), end=" | ")
print(colored(scales[key][circle_progression_roman_numerals["I"] - 1] +
append_quality(circle_progression_roman_numerals["I"]), color=attribute_color(circle_progression_roman_numerals["I"])), end=" | \n")
print() # separator
wait_a_few_seconds_between_chords(5)
if __name__ == "__main__":
main()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment