Skip to content

Commit

Permalink
fixstyle
Browse files Browse the repository at this point in the history
  • Loading branch information
Josh Symes committed Nov 9, 2023
1 parent e93f42b commit 5c8605e
Show file tree
Hide file tree
Showing 5 changed files with 34 additions and 23 deletions.
3 changes: 2 additions & 1 deletion henon2midi/ascii_art.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

from henon2midi.math import rescale_number_to_range


class AsciiArtCanvas:
RESET_COLOR = "\033[0m"

Expand Down Expand Up @@ -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)
ascii_art_canvas.draw_point(x_canvas_coord, y_canvas_coord, character)
2 changes: 1 addition & 1 deletion henon2midi/base.py
Original file line number Diff line number Diff line change
@@ -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,
Expand Down
10 changes: 4 additions & 6 deletions henon2midi/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -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)
25 changes: 13 additions & 12 deletions henon2midi/data_point_to_midi_conversion.py
Original file line number Diff line number Diff line change
@@ -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]

Expand Down Expand Up @@ -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,
Expand All @@ -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:
Expand Down Expand Up @@ -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":
Expand Down
17 changes: 14 additions & 3 deletions henon2midi/midi.py
Original file line number Diff line number Diff line change
Expand Up @@ -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():
Expand Down

0 comments on commit 5c8605e

Please sign in to comment.