jdxi_editor.midi.io.input_handler

This module provides the MIDIInHandler class for handling MIDI communication with the Roland JD-Xi. It supports processing of SysEx, Control Change, Program Change, Note On/Off, and Clock messages. The handler decodes incoming MIDI messages, routes them to appropriate sub-handlers, and emits Qt signals for integration with PySide6-based applications.

Classes:
MIDIInHandler: Processes incoming MIDI messages, handles SysEx tone data parsing, and emits signals

for further processing in the application.

Usage:

Instantiate MIDIInHandler and connect to its signals to integrate MIDI data handling with your application.

Dependencies:
  • PySide6.QtCore.Signal for signal emission.

  • pubsub for publish/subscribe messaging.

  • jdxi_manager modules for data handling, parsing, and MIDI processing.

Classes

MidiInHandler

Helper class for MIDI communication with the JD-Xi.

Functions

add_or_replace_program_and_save(→ bool)

Add a new program to the list, replacing any with matching ID or PC.

add_or_replace_program_and_save_old(→ bool)

add_or_replace_program_and_save

load_programs(→ List[Dict[str, str]])

save_programs(→ None)

Save the program list to USER_PROGRAMS_FILE, creating the file and directory if needed.

save_programs_old(→ None)

save_programs

Module Contents

jdxi_editor.midi.io.input_handler.add_or_replace_program_and_save(new_program: jdxi_editor.jdxi.program.program.JDXiProgram) bool[source]

Add a new program to the list, replacing any with matching ID or PC. Uses SQLite database for reliable storage.

Parameters:

new_program – JDXiProgram to add or replace.

Returns:

True if successfully added/replaced and saved, False otherwise.

jdxi_editor.midi.io.input_handler.add_or_replace_program_and_save_old(new_program: jdxi_editor.jdxi.program.program.JDXiProgram) bool[source]

add_or_replace_program_and_save

Parameters:

new_program

Returns:

jdxi_editor.midi.io.input_handler.load_programs() List[Dict[str, str]][source]
jdxi_editor.midi.io.input_handler.save_programs(program_list: List[Dict[str, str]]) None[source]

Save the program list to USER_PROGRAMS_FILE, creating the file and directory if needed.

Parameters:

program_list – List of program dictionaries.

jdxi_editor.midi.io.input_handler.save_programs_old(program_list: List[Dict[str, str]]) None[source]

save_programs

Parameters:

program_list – List[Dict[str, str]]

Returns:

None

class jdxi_editor.midi.io.input_handler.MidiInHandler(parent: Any | None = None)[source]

Bases: jdxi_editor.midi.io.controller.MidiIOController

Helper class for MIDI communication with the JD-Xi.

This class listens to incoming MIDI messages, processes them based on their preset_type, and emits corresponding signals. It handles SysEx, Control Change, Program Change, Note On/Off, and Clock messages.

update_tone_name[source]
update_program_name[source]
midi_message_incoming[source]
midi_program_changed[source]
midi_control_changed[source]
midi_sysex_json[source]
parent = None[source]
callbacks: List[Callable] = [][source]
channel: int = 1[source]
preset_number: int = 0[source]
cc_msb_value: int = 0[source]
cc_lsb_value: int = 0[source]
sysex_parser[source]
_incoming_preset_data[source]
midi_callback(message: list[Any], data: Any) None[source]

callback for rtmidi mido doesn’t have callbacks, so we convert :param message: list[Any] :param data: Any

reopen_input_port_name(in_port: str) bool[source]

Reopen the current MIDI input port and reattach the callback.

Parameters:

in_port – str

Returns:

bool

set_callback(callback: Callable) None[source]

Set address callback for MIDI messages.

Parameters:

callback – The callback function to be set.

_handle_midi_message(message: Any) None[source]

Routes MIDI messages to appropriate handlers

Parameters:

message – Any

Returns:

None

_handle_note_change(message: mido.Message, preset_data: dict) None[source]

Handle Note On and Note Off MIDI messages.

Parameters:
  • message – Any The MIDI message.

  • preset_data – Dictionary for preset data modifications.

_handle_clock(message: mido.Message, preset_data: dict) None[source]

Handle MIDI Clock messages quietly.

Parameters:
  • message – mido.Message The MIDI message.

  • preset_data – Dictionary for preset data modifications.

_handle_sysex_message(message: mido.Message, preset_data: dict) None[source]

Handle SysEx MIDI messages from the Roland JD-Xi.

Processes SysEx data, attempts to parse tone data, and extracts command and parameter information for further processing.

Parameters:
  • message – mido.Message The MIDI SysEx message.

  • preset_data – Dictionary for preset data modifications.

_handle_control_change(message: mido.Message, preset_data: dict) None[source]

Handle Control Change (CC) MIDI messages.

Parameters:
  • message – mido.Message The MIDI Control Change message.

  • preset_data – Dictionary for preset data modifications.

_handle_program_change(message: mido.Message, preset_data: dict) None[source]

Handle Program Change (PC) MIDI messages.

Processes program changes and maps them to preset changes based on CC values.

Parameters:
  • message – mido.Message The MIDI Program Change message.

  • preset_data – Dictionary for preset data modifications.

_emit_program_or_tone_name(parsed_data: dict) None[source]

Emits the appropriate Qt signal for the extracted tone name. :param parsed_data: dict

_auto_add_current_program()[source]

_auto_add_current_program

Returns:

None

For reference: BANK SELECT| PROGRAM | GROUP| NUMBER MSB | LSB | NUMBER | | —–+———–+———–+—————————-+———– 085 | 064 | 001 - 064 | Preset Bank Program (A) | A01 - A64 Banks to 64 085 | 064 | 065 - 128 | Preset Bank Program (B) | B01 - B64 Banks to 128 085 | 065 | 001 - 064 | Preset Bank Program (C) | C01 - C64 Banks to 192 085 | 065 | 065 - 128 | Preset Bank Program (D) | D01 - D64 Banks to 256 —–+———–+———–+—————————-+———– 085 | 000 | 001 - 064 | User Bank Program (E) | E01 - E64 Banks to 320 085 | 000 | 065 - 128 | User Bank Program (F) | F01 - F64 Banks to 384 085 | 001 | 001 - 064 | User Bank Program (G) | G01 - G64 Banks to 448 085 | 001 | 065 - 128 | User Bank Program (H) | H01 - H64 Banks to 512 —–+———–+———–+—————————-+———– 085 | 096 | 001 - 064 | Extra Bank Program (S) | S01 - S64 Banks to 576 | : | : | : | : 085 | 103 | 001 - 064 | Extra Bank Program (Z) | Z01 - Z64 Banks to 1024

_emit_program_name_signal(area: str, tone_name: str) None[source]

Emits the appropriate Qt signal for a given tone name

Parameters:
  • area – str

  • tone_name – str

Returns:

None

_emit_tone_name_signal(area: str, tone_name: str) None[source]

Emits the appropriate Qt signal for a given tone name

Parameters:
  • area – str

  • tone_name – str

Returns:

None