jdxi_editor.ui.windows.midi.config_dialog

MIDIConfigDialog is a dialog class that allows users to configure MIDI input and output ports.

It provides the following functionality: - Display available MIDI input and output ports in combo boxes (the JD-Xi first). - Allow users to select and change MIDI input and output ports. - Refresh the list of available MIDI ports. - Test the connection: an Identity Request, and what answered. - Retrieve the selected MIDI port settings.

The dialog opens at once: the MIDI ports, the audio outputs and the SoundFonts are listed on a worker thread, and FluidSynth starts there too (loading a SoundFont of 140 MB kept Windows from drawing the dialog for seconds).

jdxi_editor.ui.windows.midi.config_dialog.input_ports

List of available MIDI input ports.

Type:

list

jdxi_editor.ui.windows.midi.config_dialog.output_ports

List of available MIDI output ports.

Type:

list

jdxi_editor.ui.windows.midi.config_dialog.current_in

Currently selected MIDI input port (optional).

Type:

str

jdxi_editor.ui.windows.midi.config_dialog.current_out

Currently selected MIDI output port (optional).

Type:

str

jdxi_editor.ui.windows.midi.config_dialog.midi_helper

Instance of the MIDIHelper class to interact with MIDI devices.

Type:

MidiIOHelper

jdxi_editor.ui.windows.midi.config_dialog.refresh_ports()

Refresh the list of available MIDI ports.

jdxi_editor.ui.windows.midi.config_dialog.get_input_port()

Returns the currently selected MIDI input port.

jdxi_editor.ui.windows.midi.config_dialog.get_output_port()

Returns the currently selected MIDI output port.

jdxi_editor.ui.windows.midi.config_dialog.get_settings()

Returns a dictionary containing the selected MIDI input and output ports.

Attributes

HW_PORT_HINT

SF2_DIR

SF2_PATH

IDENTITY_REQUEST

IDENTITY_TIMEOUT_MS

JDXI_MARK

_fluidsynth_err_msg

_fluidsynth_module

_RELAYS

Classes

_Relay

Delivers a background result on the UI thread, if its owner still exists.

_SoundfontRouteWatch

Reopen a SoundFont that follows the system output when that route changes.

MIDIConfigDialog

Functions

_get_output_devices() → list[tuple[str, int]]

Output devices as (display name, sounddevice index).

run_in_background(fn, callback, parent) → None

fn() on a worker thread, then callback(result, error) on parent's thread.

list_midi_ports(midi_helper) → tuple[list[str], list[str]]

The MIDI ports, listed through ports of its own.

list_audio_outputs() → Optional[list[tuple[str, int]]]

The audio outputs FluidSynth can play on; None without sounddevice.

find_soundfonts([folder]) → list[str]

The .sf2 and .sf3 files under folder.

parse_identity_reply(data) → Optional[dict]

Identity Reply (mido sysex data, without F0/F7) -> details, else None.

Module Contents

jdxi_editor.ui.windows.midi.config_dialog.HW_PORT_HINT = 'Roland JDXi'[source]
jdxi_editor.ui.windows.midi.config_dialog.SF2_DIR[source]
jdxi_editor.ui.windows.midi.config_dialog.SF2_PATH[source]
jdxi_editor.ui.windows.midi.config_dialog.IDENTITY_REQUEST = [240, 126, 127, 6, 1, 247][source]
jdxi_editor.ui.windows.midi.config_dialog.IDENTITY_TIMEOUT_MS = 1500[source]
jdxi_editor.ui.windows.midi.config_dialog.JDXI_MARK = '★ '[source]
jdxi_editor.ui.windows.midi.config_dialog._fluidsynth_err_msg = ''[source]
jdxi_editor.ui.windows.midi.config_dialog._fluidsynth_module = None[source]
jdxi_editor.ui.windows.midi.config_dialog._get_output_devices() → list[tuple[str, int]][source]

Output devices as (display name, sounddevice index).

Returns:

list

class jdxi_editor.ui.windows.midi.config_dialog._Relay(callback: Callable, owner: PySide6.QtCore.QObject)[source]

Bases: PySide6.QtCore.QObject

Delivers a background result on the UI thread, if its owner still exists.

Not a child of the owner: the dialog may be deleted (closed) while the work runs, and the worker must never emit on a deleted object.

finished[source]
_callback[source]
_owner[source]
_deliver(result, error) → None[source]
jdxi_editor.ui.windows.midi.config_dialog._RELAYS: set[source]
jdxi_editor.ui.windows.midi.config_dialog.run_in_background(fn: Callable, callback: Callable, parent: PySide6.QtCore.QObject) → None[source]

fn() on a worker thread, then callback(result, error) on parent’s thread.

A plain Python thread (not a QRunnable, whose wrapper PySide may free while it runs); the result crosses back through a queued Qt signal.

jdxi_editor.ui.windows.midi.config_dialog.list_midi_ports(midi_helper) → tuple[list[str], list[str]][source]

The MIDI ports, listed through ports of its own.

This runs in the background while the app uses the helper’s ports (rtmidi is not thread-safe, and with a device gone Windows crashed listing through them). Without a MIDI backend the helper’s lists are used.

jdxi_editor.ui.windows.midi.config_dialog.list_audio_outputs() → list[tuple[str, int]] | None[source]

The audio outputs FluidSynth can play on; None without sounddevice.

jdxi_editor.ui.windows.midi.config_dialog.find_soundfonts(folder: str = SF2_DIR) → list[str][source]

The .sf2 and .sf3 files under folder.

jdxi_editor.ui.windows.midi.config_dialog.parse_identity_reply(data) → dict | None[source]

Identity Reply (mido sysex data, without F0/F7) -> details, else None.

class jdxi_editor.ui.windows.midi.config_dialog._SoundfontRouteWatch(helper)[source]

Bases: PySide6.QtCore.QObject

Reopen a SoundFont that follows the system output when that route changes.

_helper[source]
_busy = False[source]
_timer[source]
sync() → None[source]

Run while the open SoundFont is following the system output.

_check() → None[source]
class jdxi_editor.ui.windows.midi.config_dialog.MIDIConfigDialog(midi_helper=MidiIOHelper, parent=None)[source]

Bases: PySide6.QtWidgets.QDialog

midi_helper[source]
current_in = None[source]
current_out = None[source]
input_ports[source]
output_ports[source]
fs[source]
sfid[source]
_refreshing_outputs = False[source]
_outputs_listed = False[source]
_start_when_listed = False[source]
_busy_synth = False[source]
_identity_timer[source]
_listening = False[source]
status_kind = 'idle'[source]
sf2_path = ''[source]
showEvent(event)[source]
_bring_to_front()[source]
_create_ui()[source]

Create the dialog UI

_update_midi_port_combo(midi_port_combo: PySide6.QtWidgets.QComboBox, midi_ports: list, current_port: str) → None[source]

Populate a MIDI port combo box, omitting virtual/loopback ports.

The JD-Xi comes first, marked, so it is easy to spot; it is chosen when current_port is not listed.

_create_button_row_specs(btn_row: PySide6.QtWidgets.QHBoxLayout) → list[picoui.specs.widgets.ButtonSpec][source]

create button row specs

_refresh_hardware_devices(devices: list | None = None) → None[source]

Fill the audio outputs.

Parameters:

devices – (name, index) as list_audio_outputs() gives them (None: sounddevice not installed)

_on_audio_output_changed(index: int) → None[source]

Remember the output, and reopen it when playback is already running.

_on_input_combo_changed() → None[source]

On input ComboBox changed, set the DigitalTitle text.

_on_output_combo_changed() → None[source]

On output ComboBox changed, set the DigitalTitle text.

refresh_ports()[source]

List the MIDI ports again, in the background.

_ports_listed(result, error) → None[source]
_fill_ports(inputs: list[str], outputs: list[str]) → None[source]

The ports listed, keeping the ports chosen in the dialog where they still exist.

select_jdxi_ports() → None[source]

Choose the ports whose name contains JD-Xi.

_on_port_choice_changed(_index: int = 0) → None[source]
_ports_changed() → bool[source]
_ports_open() → bool[source]
_set_status(kind: str, text: str) → None[source]
_apply_ports() → bool[source]

Open the chosen ports (an excluded one stays closed).

test_connection() → None[source]

Use the chosen ports and send an Identity Request; the reply arrives later.

_on_midi_message(message) → None[source]
_identity_timed_out() → None[source]
_stop_listening() → None[source]
_load_synth_choices() → None[source]

Audio outputs and SoundFonts, listed in the background.

_synth_choices_loaded(result, error) → None[source]
_toggle_fluidsynth_controls(enabled: bool) → None[source]
_on_soundfont_list_toggled(checked: bool) → None[source]

Handle SoundFont list checkbox toggle - save immediately and notify listeners.

Data requests follow the mode until chosen: off for SoundFont, on for the JD-Xi lists; the box can still be changed afterwards.

_browse_sf2() → None[source]
_start_fluidsynth() → None[source]

Start FluidSynth and load the SoundFont, in the background.

_set_synth_buttons_enabled(enabled: bool) → None[source]
_fluidsynth_started(result, error) → None[source]
_note_opened_output() → None[source]

Name the output PortAudio actually opened.

_ensure_route_watch() → None[source]
closeEvent(event)[source]
_close_soundfont() → None[source]
_stop_fluidsynth() → None[source]
_test_fluidsynth() → None[source]
_populate_sf2_combo(found: list[str]) → None[source]

Fill the combo box with the SoundFonts found (find_soundfonts).

_on_sf2_combo_changed(index: int) → None[source]
_ensure_sf2_in_combo(path: str) → None[source]
_select_sf2_in_combo(path: str) → None[source]
accept()[source]
reject()[source]
get_undesirable_midi_port(midi_port_text: str) → str[source]
get_input_port() → str[source]

Get selected input port name

Returns:

Selected input port name or empty string if none selected

get_output_port() → str[source]

Get selected output port name

Returns:

Selected output port name or empty string if none selected

get_settings() → dict[source]

Get all selected settings

Returns:

Dictionary containing input_port and output_port selections