Some refactoring

This commit is contained in:
2023-02-15 19:44:40 +02:00
parent 726dc42902
commit 10f66d0027
3 changed files with 1631 additions and 1583 deletions

View File

@ -77,9 +77,20 @@ def get_scale(name: str) -> list[int]:
Returns:
list: List of intervals in the scale
"""
scale = SCALES.get(name.lower().capitalize(), SCALES["Chromatic"])
return list(map(int, str(scale)))
scale = SCALES.get(name.lower().capitalize(), SCALES["Ionian"])
return scale
def get_scale_length(name: str) -> int:
"""Get length of the scale
Args:
name (str): Name of the scale
Returns:
int: Length of the scale
"""
scale = SCALES.get(name.lower().capitalize(), SCALES["Ionian"])
return len(scale)
# pylint: disable=locally-disabled, too-many-arguments
def note_from_pc(
@ -186,7 +197,7 @@ def midi_to_tpc(note: int, key: str | int):
_type_: Tonal Pitch Class value for the note
"""
if isinstance(key, str):
acc = accidentals_from_note_name(key)
acc = accidentals_from_note_name(key[0])
else:
acc = accidentals_from_midi_note(key)
return (note * 7 + 26 - (11 + acc)) % 12 + (11 + acc)