diff options
| author | Houyhnhnm <hykusb@bitmai.la> | 2018-06-05 15:39:59 +0200 |
|---|---|---|
| committer | Houyhnhnm <hykusb@bitmai.la> | 2018-06-05 15:39:59 +0200 |
| commit | b3385fb08d11cc8fea68026fe9931e11dd591033 (patch) | |
| tree | de5041299bc5c871fe6ab2be3f5532209f7b42e3 /utils.py | |
| parent | fb85212cbc8e7a2866c6dda916e810df2a4ea4e0 (diff) | |
add harmony, rhythm, utils modules, rendering module stub
Diffstat (limited to 'utils.py')
| -rw-r--r-- | utils.py | 30 |
1 files changed, 30 insertions, 0 deletions
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) + |