Skip to content

Commit

Permalink
small test for midi message handling
Browse files Browse the repository at this point in the history
  • Loading branch information
cpmpercussion committed Aug 15, 2024
1 parent ec4f6bc commit 99da2e5
Showing 1 changed file with 17 additions and 1 deletion.
18 changes: 17 additions & 1 deletion impsy/tests/test_impsio.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,10 @@ def midi_output_mapping(default_config):
"""get the default MIDI output mapping."""
return(default_config["midi"]["output"])

@pytest.fixture(scope="session")
def midi_input_mapping(default_config):
"""get the default MIDI input mapping."""
return(default_config["midi"]["input"])

@pytest.fixture(scope="session")
def output_values(default_config):
Expand All @@ -34,7 +38,6 @@ def last_midi_notes_dict(midi_output_mapping):
return last_midi_notes



@pytest.fixture(scope="session")
def sparse_callback():
def callback():
Expand All @@ -51,6 +54,19 @@ def callback():

# test utils.

def test_midi_message_handling():
# notes
input_mapping = [['note_on', 1]]
note_msg = mido.Message('note_on', channel=0, note=12, velocity=64)
index, value = utils.midi_message_to_index_value(note_msg, input_mapping)
assert(index == 0 and value == 12/127)
# cc
input_mapping = [['control_change', 1, 1]]
cc_msg = mido.Message("control_change", channel=0, control=1, value=64)
index, value = utils.midi_message_to_index_value(cc_msg, input_mapping)
assert(index == 0 and value == 64/127)



def test_midi_mapping_to_output(output_values, midi_output_mapping):
output_messages = utils.output_values_to_midi_messages(output_values, midi_output_mapping)
Expand Down

0 comments on commit 99da2e5

Please sign in to comment.