minor fixes

This commit is contained in:
2023-02-05 16:13:02 +01:00
parent 09553c539b
commit 79a336887c
2 changed files with 11 additions and 7 deletions

View File

@ -19,7 +19,7 @@ classifiers = [
dependencies = [
"lark>=1.1.5",
"rich>=12.6.0",
"pytest=>7.2.1",
"pytest>=7.2.1",
]
[project.urls]

View File

@ -1531,21 +1531,25 @@ def get_scale(name: str) -> list:
def note_from_pc(
root: int|str,
root: int | str,
pitch_class: int,
intervals: str | list[int|float],
cents: bool = False,
octave: int = 0,
modifier: int = 0
) -> int:
modifier: int = 0) -> int:
"""Resolve a pitch class into a note from a scale"""
if type(root)==str:
if isinstance(root, str):
root = note_to_midi(root)
if isinstance(intervals, str):
intervals = get_scale(intervals)
if cents:
intervals = list(map(lambda x: x / 100), intervals)
if type(intervals) == str:
intervals = get_scale(intervals)
interval_sum = sum(intervals[0:pitch_class])
note = (root + interval_sum if pitch_class >= 0 else root - interval_sum)
return note + octave*sum(intervals) + modifier