#๐Ÿ”’ Get a scale based on the number of sharps of flats

27 messages ยท Page 1 of 1 (latest)

lusty current
#

https://github.com/nautrw/mtheorypy
I am trying to reinvent the wheel and make a library to programatically manipulate music. In the keys.py file, I have a dataclass for keys, which holds the number of sharps or flats. I also have a function to get the key signature of a key. How can I get the notes in a specific scale according to the key signature? (The file contains my failed attempt at implementing it)

GitHub

A python library for music theory. Contribute to nautrw/mtheorypy development by creating an account on GitHub.

molten ravenBOT
#

@lusty current

Python help channel opened

Remember to:

  • Ask your Python question, not if you can ask or if there's an expert who can help.
  • Show a code sample as text (rather than a screenshot) and the error message, if you've got one.
  • Explain what you expect to happen and what actually happens.

:warning: Do not pip install anything that isn't related to your question, especially if asked to over DMs.

small crow
lusty current
lusty current
#

bump

austere holly
lusty current
#

thats probably the way i should do it but

#

ive seen other libraries do it programatically

thick hound
#

Would it not just be a case of working out each scale's procession in semitone values then mapping keys to offsets?

lusty current
#

hm

thick hound
#

Major, minor, harmonic, melodic, etc, then plus offset.

austere holly
#

A sharp/flat is just a modifier, so you can make a scale using just the base note, a list of offsets for the scale type, and apply the sharps/flats.

lusty current
#

but i still need the flats and sharps

#

if i bring down the c scale a step down i get bcdefgab but they are all natural

#

so how do i apply the sharps and flats

austere holly
#

Like usual? Sharp = +1 half step, flat = -1

thick hound
#

Apply the naming from the key sig.

lusty current
#

how would i go about that

#

the key sig function just gives a list of numbers corresponding to notes

thick hound
#

My music theory is very rusty. But if you have a given absolute note in a scale and it matches an accidental in the sig, you'd be able to have another mapping of absolute notes:names per key.

#

I don't think I'm explaining very well.

#

If you write out a dictionary mapping of keys to scale notes manually, you might start to be able to see patterns you can condense into algorithms.

lusty current
#

ig

lusty current
#

thx for the help

#

!solved

molten ravenBOT
#
Python help channel closed

This help channel has been closed and it's no longer possible to send messages here. If your question wasn't answered, feel free to create a new post in #1035199133436354600. To maximize your chances of getting a response, check out this guide on asking good questions.