Skip to content

Commit

Permalink
Version 1.0 Code improvements and new function
Browse files Browse the repository at this point in the history
  • Loading branch information
asigalov61 authored Sep 6, 2024
1 parent 9d07f9d commit 11dac5c
Showing 1 changed file with 18 additions and 7 deletions.
25 changes: 18 additions & 7 deletions tegridy-tools/TMIDIX.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
#
Expand Down

0 comments on commit 11dac5c

Please sign in to comment.