Added parsing for monzos and support for escaped pitch_classes

Syntax for monzos supported in scala scales: [-1 1> etc.

Support for escaped pitches: {q12 e23 26}
This commit is contained in:
2023-03-16 22:29:24 +02:00
parent 882a9a7b4b
commit 5d122a90e0
11 changed files with 284 additions and 102 deletions

View File

@ -2,6 +2,7 @@
import re
from copy import deepcopy
def flatten(arr: list) -> list:
"""Flattens array"""
return (
@ -23,14 +24,16 @@ def rotate(arr, k):
arr = arr[-k:] + arr[:-k]
return arr
def repeat_text(pos,neg,times):
def repeat_text(pos, neg, times):
"""Helper to repeat text"""
if times>0:
return pos*times
if times<0:
return neg*abs(times)
if times > 0:
return pos * times
if times < 0:
return neg * abs(times)
return ""
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]
@ -110,4 +113,4 @@ def cyclic_zip(first: list, second: list) -> list:
f_length = len(first)
for i in range(s_length):
result.append([first[i % f_length], second[i]])
return [deepcopy(item) for sublist in result for item in sublist]
return [deepcopy(item) for sublist in result for item in sublist]