Skip to content

Commit

Permalink
Version 1.0 Added new transpose functions
Browse files Browse the repository at this point in the history
  • Loading branch information
asigalov61 authored Aug 10, 2024
1 parent b916bbf commit 1304e4a
Showing 1 changed file with 34 additions and 0 deletions.
34 changes: 34 additions & 0 deletions tegridy-tools/TMIDIX.py
Original file line number Diff line number Diff line change
Expand Up @@ -7000,6 +7000,40 @@ def lists_intersections(src_list, trg_list):

###################################################################################

def transpose_escore_notes(escore_notes,
transpose_value=0,
channel_index=3,
pitches_index=4
):

tr_escore_notes = copy.deepcopy(escore_notes)

for e in tr_escore_notes:
if e[channel_index] != 9:
e[pitches_index] = max(1, min(127, e[pitches_index] + transpose_value))

return tr_escore_notes

###################################################################################

def transpose_escore_notes_to_pitch(escore_notes,
target_pitch_value=60,
channel_index=3,
pitches_index=4
):

tr_escore_notes = copy.deepcopy(escore_notes)

transpose_delta = int(round(target_pitch_value)) - int(round(escore_notes_averages(escore_notes, return_ptcs_and_vels=True)[2]))

for e in tr_escore_notes:
if e[channel_index] != 9:
e[pitches_index] = max(1, min(127, e[pitches_index] + transpose_delta))

return tr_escore_notes

###################################################################################

# This is the end of the TMIDI X Python module

###################################################################################

0 comments on commit 1304e4a

Please sign in to comment.