minor fixes
This commit is contained in:
@ -1539,25 +1539,14 @@ def note_from_pc(
|
|||||||
modifier: int = 0) -> int:
|
modifier: int = 0) -> int:
|
||||||
"""Resolve a pitch class into a note from a scale"""
|
"""Resolve a pitch class into a note from a scale"""
|
||||||
|
|
||||||
if isinstance(root, str):
|
# Initialization
|
||||||
root = note_to_midi(root)
|
root = note_to_midi(root) if isinstance(root, str) else root
|
||||||
|
intervals = get_scale(intervals) if isinstance(
|
||||||
|
intervals, str) else intervals
|
||||||
|
intervals = list(map(lambda x: x / 100), intervals) if cents else intervals
|
||||||
|
|
||||||
if isinstance(intervals, str):
|
# Computing the result
|
||||||
intervals = get_scale(intervals)
|
interval_sum = sum(intervals[0:pitch_class % len(intervals)])
|
||||||
|
|
||||||
if cents:
|
|
||||||
intervals = list(map(lambda x: x / 100), intervals)
|
|
||||||
|
|
||||||
interval_sum = sum(intervals[0:pitch_class])
|
|
||||||
|
|
||||||
note = (root + interval_sum if pitch_class >= 0 else root - interval_sum)
|
note = (root + interval_sum if pitch_class >= 0 else root - interval_sum)
|
||||||
return note + octave*sum(intervals) + modifier
|
return note + octave*sum(intervals) + modifier
|
||||||
|
|
||||||
|
|
||||||
if __name__ == "__main__":
|
|
||||||
print(get_scale("Godatic"))
|
|
||||||
|
|
||||||
# Taking the fifth from the chromatic scale
|
|
||||||
user_scale = get_scale("chromatic")
|
|
||||||
note = note_from_pc(60, -7, user_scale)
|
|
||||||
print(f"Note: {note} from {user_scale}")
|
|
||||||
|
|||||||
Reference in New Issue
Block a user