From b3385fb08d11cc8fea68026fe9931e11dd591033 Mon Sep 17 00:00:00 2001 From: Houyhnhnm Date: Tue, 5 Jun 2018 15:39:59 +0200 Subject: add harmony, rhythm, utils modules, rendering module stub --- utils.py | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) create mode 100644 utils.py (limited to 'utils.py') diff --git a/utils.py b/utils.py new file mode 100644 index 0000000..afd2537 --- /dev/null +++ b/utils.py @@ -0,0 +1,30 @@ + +def fl(number, precision=6): + formatstring = '{:.'+str(precision)+'f}' + return float(formatstring.format(number)) + + +def depth(myList, counter): + counter += 1 + depthList = [] + for item in myList: + if isinstance(item, list): + depthList.append(depth(item, counter)) + else: + depthList.append(counter) + return depthList + +def flatten(pool): + res = [] + for v in pool: + if isinstance(v, list): + res += flatten(v) + else: + if isinstance(v, int) or isinstance(v, str): + res.append(v) + return res + +def isOversliced(bars): + targets = [bar < 2.5 for bar in bars] + return (True in targets) + -- cgit v1.2.3