diff options
| author | Houyhnhnm <hykusb@bitmai.la> | 2018-06-07 14:16:34 +0200 |
|---|---|---|
| committer | Houyhnhnm <hykusb@bitmai.la> | 2018-06-07 14:16:34 +0200 |
| commit | 789e7c10bc8765d498ba9f1e4c3eac35b64b41e7 (patch) | |
| tree | 0872e3b8b3c26753579392743789c160d0def095 /utils.py | |
| parent | 2be56d2f3541cedd0c4e872aeb5b7da110d9b260 (diff) | |
render rhythms to score
Diffstat (limited to 'utils.py')
| -rw-r--r-- | utils.py | 35 |
1 files changed, 23 insertions, 12 deletions
@@ -8,23 +8,34 @@ def depth(myList, counter): counter += 1 depthList = [] for item in myList: - if isinstance(item, list): - depthList.append(depth(item, counter)) - else: - depthList.append(counter) + 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 + 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 > 0 and bar < 2.5 for bar in bars] return (True in targets) +def firstNonNegative(lst): + for x in lst: + if x >= 0: + return x + return 0 + +def lastNonPositive(lst): + for x in list(reversed(lst)): + if x <= 0: + return x + return 0
\ No newline at end of file |