This commit is contained in:
2023-02-05 21:31:03 +01:00
2 changed files with 13 additions and 5 deletions

View File

@ -10,7 +10,7 @@ def sum_dict(arr: list[dict]) -> dict:
"""Sums a list of dicts: [{a:3,b:3},{b:1}] -> {a:3,b:4}"""
result = arr[0]
for element in arr[1:]:
for key in hash.keys():
for key in element.keys():
if key in result:
result[key] = result[key] + element[key]
else:

View File

@ -1,6 +1,7 @@
#!/usr/bin/env python3
import re
from math import floor
SCALES = {
"Minoric": 444,
@ -1536,9 +1537,16 @@ def note_from_pc(
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
scale_length = len(intervals)
# Resolve pitch classes to the scale and calculate octave
if pitch_class>=scale_length or pitch_class<0:
octave += floor(pitch_class/scale_length)
pitch_class = scale_length-(abs(pitch_class)%scale_length) if pitch_class<0 else pitch_class%scale_length
if pitch_class == scale_length:
pitch_class = 0
# Computing the result
interval_sum = sum(intervals[0 : pitch_class % len(intervals)])
note = root + interval_sum if pitch_class >= 0 else root - interval_sum
return note + octave * sum(intervals) + modifier
note = root + sum(intervals[0 : pitch_class])
return note + (octave * sum(intervals)) + modifier