Skip to content

Commit

Permalink
fix bug with clipping
Browse files Browse the repository at this point in the history
  • Loading branch information
Josh Symes committed Jul 23, 2023
1 parent c5ddff5 commit 7a82bb5
Showing 1 changed file with 19 additions and 11 deletions.
30 changes: 19 additions & 11 deletions henon2midi/data_point_to_midi_conversion.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,21 +28,21 @@ def create_midi_messages_from_data_point(
if (x > source_range_x[1] or x < source_range_x[0]) and not clip:
midi_values["velocity"] = 0
else:
midi_values[x_midi_parameter_mapping] = midi_value_from_data_point_value(
x,
source_range=source_range_x,
midi_range=midi_range_x,
)
midi_values[x_midi_parameter_mapping] = midi_value_from_data_point_value(
x,
source_range=source_range_x,
midi_range=midi_range_x,
)

for y_midi_parameter_mapping in y_midi_parameter_mappings:
if (y > source_range_y[1] or y < source_range_y[0]) and not clip:
midi_values["velocity"] = 0
else:
midi_values[y_midi_parameter_mapping] = midi_value_from_data_point_value(
y,
source_range=source_range_y,
midi_range=midi_range_y,
)
midi_values[y_midi_parameter_mapping] = midi_value_from_data_point_value(
y,
source_range=source_range_y,
midi_range=midi_range_y,
)

note_on = Message(
"note_on",
Expand All @@ -56,7 +56,15 @@ def create_midi_messages_from_data_point(
time=duration_ticks,
)

note_messages = [note_on, note_off]
if (
x > source_range_x[1]
or x < source_range_x[0]
or y > source_range_y[1]
or y < source_range_y[0]
) and not clip:
note_messages = [note_off]
else:
note_messages = [note_on, note_off]
pre_note_messages = []
post_note_messages = []

Expand Down

0 comments on commit 7a82bb5

Please sign in to comment.