From 11dac5c0f2c8d49ce1034866b3b12d2776417eca Mon Sep 17 00:00:00 2001 From: Alex Date: Fri, 6 Sep 2024 00:25:30 -0700 Subject: [PATCH] Version 1.0 Code improvements and new function --- tegridy-tools/TMIDIX.py | 25 ++++++++++++++++++------- 1 file changed, 18 insertions(+), 7 deletions(-) diff --git a/tegridy-tools/TMIDIX.py b/tegridy-tools/TMIDIX.py index e7c6737..1668231 100644 --- a/tegridy-tools/TMIDIX.py +++ b/tegridy-tools/TMIDIX.py @@ -8834,33 +8834,44 @@ def escore_notes_middle(escore_notes, def escore_notes_to_parsons_code(escore_notes, times_index=1, - pitches_index=4 + pitches_index=4, + return_as_list=False ): - parsons = "" + parsons = "*" + parsons_list = [] prev = ['note', -1, -1, -1, -1, -1, -1] for e in escore_notes: if e[times_index] != prev[times_index]: - if parsons == "": - parsons += "*" - - elif e[pitches_index] > prev[pitches_index]: + if e[pitches_index] > prev[pitches_index]: parsons += "U" + parsons_list.append(1) elif e[pitches_index] < prev[pitches_index]: parsons += "D" + parsons_list.append(-1) elif e[pitches_index] == prev[pitches_index]: parsons += "R" + parsons_list.append(0) prev = e - return parsons + if return_as_list: + return parsons_list + + else: + return parsons ################################################################################### + +def all_consequtive(list_of_values): + return all(b > a for a, b in zip(list_of_values[:-1], list_of_values[1:])) + +################################################################################### # # This is the end of the TMIDI X Python module #