python-mingus icon indicating copy to clipboard operation
python-mingus copied to clipboard

Is there a connection between keys and number representation?

Open tomsocoolsky opened this issue 2 years ago • 1 comments

Hi! I'm total beginner to Python, a little bit more knowledge about music theory, but I'm learning both, and have so much fun and excitement! :)

Let's say I would like a program to move clockwise circle of fifths, and at first in world of only major keys. I would like user to input a number, let's say it would be accidentals number, i.e: 1, which is associated with key of G major.

And I would like then a program to print 3 following major keys, which would be: G major, D major and A major, and notes for these keys.

Is it possible?

Is it possible to somehow connect keys with numbers and operate them for creating matrixes with notes?

Thank you a lot for your help! Tommy

tomsocoolsky avatar Aug 30 '23 19:08 tomsocoolsky

If I understand your question correctly, do you want a program like this?

import mingus.core.chords as chords

circle_of_fifths = ['G', 'D', 'A', 'E', 'B', 'Gb', 'Db', 'Ab', 'Eb', 'Bb', 'F', 'C']

while True:
  try:
    input_number = int(input("Input a number: "))
    output_chords = [circle_of_fifths[(input_number + i)] for i in range(3)]
    chord_dict = {f"{chord} major": chords.major_triad(chord) for chord in output_chords}
    for key, value in chord_dict.items():
      print(key, value)
  except ValueError:
    print("Please input a number.")

RxoMTH avatar Sep 23 '23 13:09 RxoMTH