Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Is there a connection between keys and number representation? #115

Open
tomsocoolsky opened this issue Aug 30, 2023 · 1 comment
Open

Is there a connection between keys and number representation? #115

tomsocoolsky opened this issue Aug 30, 2023 · 1 comment

Comments

@tomsocoolsky
Copy link

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

@RxoMTH
Copy link

RxoMTH commented Sep 23, 2023

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.")

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants