jdxi_editor.midi.io.external_controller
MIDI input from a hardware controller such as the Arturia MiniLab 3, separate
from the JD-Xi’s. Its messages are shown in the MIDI Monitor and its control
changes are emitted as ExternalControllerInput.control_changed; they
are not passed to the JD-Xi input handler, so editors do not mistake a knob
turn for the synth reporting a change.
Every port the controller exposes is opened, not just the one that looks like its main port: a MiniLab 3 sends its knobs and faders on the port belonging to its current mode (Arturia, DAW, Analog Lab), so listening to one port means a knob turn is missed whenever the device is in another mode. Each port is parsed separately, because a MIDI parser carries running status from one message to the next and two interleaved streams would corrupt each other.
ExternalControllerInput.rescan() picks up a controller plugged in after
the application started.
RtMidi callbacks must not call into Qt: on macOS, emitting signals (or any Qt work) from the MIDI thread while another port is still opening deadlocks CoreMIDI. Incoming bytes are queued and drained on the GUI thread instead.
Attributes
Classes
MIDI input from a hardware controller. |
Module Contents
- class jdxi_editor.midi.io.external_controller.ExternalControllerInput(parent: PySide6.QtCore.QObject | None = None)[source]
Bases:
PySide6.QtCore.QObjectMIDI input from a hardware controller.
- _pending: collections.deque[tuple[str, mido.Message]][source]
- property port_names: list[str][source]
Names of every controller port being listened to.
- Returns:
list[str]
- property profile: jdxi_editor.midi.io.controller_map.ControllerProfile | None[source]
The supported controller being listened to or, before any port is open, the one that is plugged in.
- Returns:
Optional[ControllerProfile] None if no supported controller is connected
- auto_connect() bool[source]
Open every supported controller port that is connected.
- Returns:
bool True if at least one controller port was opened
- connect_ports(port_names: list[str]) bool[source]
Listen to exactly
port_names, closing any other port already open.New ports are opened one at a time on a timer so CoreMIDI can breathe between opens (opening several back-to-back next to an active JD-Xi input deadlocks on macOS). Callbacks are installed only after each port’s
open_portreturns.ports_changedis emitted when the batch finishes.- Parameters:
port_names – list[str] MIDI input port names
- Returns:
bool True if a port is already open or a batch was started
- _open_next_port() None[source]
Open the next queued controller port, then schedule the rest.
- Returns:
None
- _finish_port_batch() None[source]
Start the GUI pump and announce the ports now listened to.
- Returns:
None
- connect_port(port_name: str) bool[source]
Listen to
port_namealone, closing any port already open.- Parameters:
port_name – str MIDI input port name
- Returns:
bool True if the port was opened
- rescan() list[str][source]
Match the open ports to what is plugged in now.
Opens controller ports that have appeared since the last scan and drops ones that have gone, so a controller connected after startup is picked up.
ports_changedis emitted when the open set changes (after any staggered opens finish).- Returns:
list[str] names of the ports already open (new ones may still be opening)
- _open_port(port_name: str, *, install_callback: bool = True) bool[source]
Open one port and listen to it, if it is not open already.
- Parameters:
port_name – str MIDI input port name
install_callback – bool if False, only open the port; callbacks are installed later once every port in the batch is open
- Returns:
bool True if the port is open afterwards
- _install_callback(port_name: str) None[source]
Attach the shared RtMidi callback to an already-open port.
- Parameters:
port_name – str MIDI input port name
- Returns:
None
- _close_port(port_name: str) None[source]
Close one port.
- Parameters:
port_name – str MIDI input port name
- Returns:
None
- _on_midi(event: tuple[list[int], float], data: Any = None) None[source]
RtMidi callback: parse raw bytes into a queue for the GUI thread.
Must not emit Qt signals or touch widgets — that deadlocks CoreMIDI when ports are still opening.
- Parameters:
event – tuple[list[int], float] raw bytes and delta time
data – Any the port’s name, passed to RtMidi when the port opened
- Returns:
None