From 5c8605e27e27a45852e0c81a0de35618a4d02b05 Mon Sep 17 00:00:00 2001 From: Josh Symes Date: Thu, 9 Nov 2023 00:21:47 +0000 Subject: [PATCH] fixstyle --- henon2midi/ascii_art.py | 3 ++- henon2midi/base.py | 2 +- henon2midi/cli.py | 10 ++++----- henon2midi/data_point_to_midi_conversion.py | 25 +++++++++++---------- henon2midi/midi.py | 17 +++++++++++--- 5 files changed, 34 insertions(+), 23 deletions(-) diff --git a/henon2midi/ascii_art.py b/henon2midi/ascii_art.py index 080e4b6..6bda96c 100644 --- a/henon2midi/ascii_art.py +++ b/henon2midi/ascii_art.py @@ -2,6 +2,7 @@ from henon2midi.math import rescale_number_to_range + class AsciiArtCanvas: RESET_COLOR = "\033[0m" @@ -93,4 +94,4 @@ def draw_data_point_on_canvas( except ValueError: pass else: - ascii_art_canvas.draw_point(x_canvas_coord, y_canvas_coord, character) \ No newline at end of file + ascii_art_canvas.draw_point(x_canvas_coord, y_canvas_coord, character) diff --git a/henon2midi/base.py b/henon2midi/base.py index 5815ebb..4d7c34b 100644 --- a/henon2midi/base.py +++ b/henon2midi/base.py @@ -1,4 +1,4 @@ -from mido import MidiFile, Message +from mido import Message, MidiFile from henon2midi.data_point_to_midi_conversion import ( create_midi_messages_from_data_point, diff --git a/henon2midi/cli.py b/henon2midi/cli.py index 08c92ee..f8208cc 100644 --- a/henon2midi/cli.py +++ b/henon2midi/cli.py @@ -336,7 +336,7 @@ def cli( art_string = ascii_art_canvas.generate_string() else: art_string = "" - + current_state_string = ( f"Current iteration: {current_iteration}\n" f"Current orbit: {current_orbit}\n" @@ -361,11 +361,9 @@ def cli( def refresh_terminal_screen( version_string: str, options_string: str, - current_state_string: str="", - art_string: str="", + current_state_string: str = "", + art_string: str = "", ): click.clear() - screen_render = ( - version_string + options_string + current_state_string + art_string - ) + screen_render = version_string + options_string + current_state_string + art_string click.echo(screen_render) diff --git a/henon2midi/data_point_to_midi_conversion.py b/henon2midi/data_point_to_midi_conversion.py index 63bfa57..3ae327e 100644 --- a/henon2midi/data_point_to_midi_conversion.py +++ b/henon2midi/data_point_to_midi_conversion.py @@ -1,21 +1,22 @@ +from typing import List, Tuple, Set from mido import Message from henon2midi.math import rescale_number_to_range def create_midi_messages_from_data_point( - datapoint: tuple[float, float], + datapoint: Tuple[float, float], duration_ticks: float = 960, clip: bool = False, - x_midi_parameter_mappings: set[str] = {"note"}, - y_midi_parameter_mappings: set[str] = {"velocity"}, - source_range_x: tuple[float, float] = (-1.0, 1.0), - source_range_y: tuple[float, float] = (-1.0, 1.0), - midi_range_x: tuple[int, int] = (0, 127), - midi_range_y: tuple[int, int] = (0, 127), + x_midi_parameter_mappings: Set[str] = {"note"}, + y_midi_parameter_mappings: Set[str] = {"velocity"}, + source_range_x: Tuple[float, float] = (-1.0, 1.0), + source_range_y: Tuple[float, float] = (-1.0, 1.0), + midi_range_x: Tuple[int, int] = (0, 127), + midi_range_y: Tuple[int, int] = (0, 127), default_note: int = 64, default_velocity: int = 64, -) -> list[Message]: +) -> List[Message]: x = datapoint[0] y = datapoint[1] @@ -46,7 +47,7 @@ def create_midi_messages_from_data_point( "portamento": 37, "data_entry": 38, "sustain": 64, - "portamento": 65, + "portamento_65": 65, "sostenuto": 66, "soft_pedal": 67, "legato_footswitch": 68, @@ -71,7 +72,7 @@ def create_midi_messages_from_data_point( "effects_2_depth": 92, "effects_3_depth": 93, "effects_4_depth": 94, - "effects_5_depth": 95 + "effects_5_depth": 95, } for x_midi_parameter_mapping in x_midi_parameter_mappings: @@ -109,8 +110,8 @@ def create_midi_messages_from_data_point( note_messages = [note_off] else: note_messages = [note_on, note_off] - pre_note_messages = [] - post_note_messages = [] + pre_note_messages: List[Message] = [] + post_note_messages: List[Message] = [] for midi_value_name, midi_value in midi_values.items(): if midi_value_name == "note" or midi_value_name == "velocity": diff --git a/henon2midi/midi.py b/henon2midi/midi.py index 28284b7..9516c19 100644 --- a/henon2midi/midi.py +++ b/henon2midi/midi.py @@ -50,9 +50,20 @@ def reset(self): reset_pan_msg = Message("control_change", control=10, value=64) reset_all_controllers_msg = Message("control_change", control=121, value=0) all_notes_off_msg = Message("control_change", control=123, value=0) - note_off_msgs = [Message("note_off", note=note, velocity=0) for note in range(128)] - - self.send([sustain_off_msg, reset_modulation_msg, reset_pan_msg, reset_all_controllers_msg, all_notes_off_msg] + note_off_msgs) + note_off_msgs = [ + Message("note_off", note=note, velocity=0) for note in range(128) + ] + + self.send( + [ + sustain_off_msg, + reset_modulation_msg, + reset_pan_msg, + reset_all_controllers_msg, + all_notes_off_msg, + ] + + note_off_msgs + ) def get_available_midi_output_names():