jdxi_editor.ui.widgets.combo_box.synchronizer

ComboBox Synchronizer Module

Manages synchronization between MIDI input/output and combo box selectors. Handles real-time note-to-selector mapping and drum kit selection updates.

Classes

ComboBoxUpdateConfig

Configuration for combo box synchronization.

ComboBoxState

Represents the state of a combo box selector.

ComboBoxSynchronizer

Synchronizes MIDI messages with combo box selectors.

Module Contents

class jdxi_editor.ui.widgets.combo_box.synchronizer.ComboBoxUpdateConfig(silence_logging: bool = False, min_note: int = 36, update_interval_ms: int = 100)[source]

Configuration for combo box synchronization.

silence_logging = False[source]
min_note = 36[source]
update_interval_ms = 100[source]
class jdxi_editor.ui.widgets.combo_box.synchronizer.ComboBoxState(row: int, current_index: int, current_text: str, note: int | None = None)[source]

Represents the state of a combo box selector.

row[source]
current_index[source]
current_text[source]
note = None[source]
class jdxi_editor.ui.widgets.combo_box.synchronizer.ComboBoxSynchronizer(config: ComboBoxUpdateConfig | None = None, midi_converter: jdxi_editor.midi.conversion.note.MidiNoteConverter | None = None, scope: str = 'ComboBoxSynchronizer')[source]

Synchronizes MIDI messages with combo box selectors.

Handles: - Incoming MIDI note-to-selector mapping - Outgoing MIDI message parsing - Drum kit selection updates - Selector state management - Channel-to-selector routing

CHANNEL_TO_ROW[source]
ROW_TO_CHANNEL[source]
config[source]
midi_converter = None[source]
scope = 'ComboBoxSynchronizer'[source]
selectors: Dict[int, PySide6.QtWidgets.QComboBox][source]
row_options: Dict[int, List[str]][source]
last_update_time: Dict[int, float][source]
on_selector_changed: Callable[[ComboBoxState], None] | None = None[source]
on_drum_kit_changed: Callable[[str], None] | None = None[source]
on_note_received: Callable[[int, int], None] | None = None[source]
set_selector(row: int, combo_box: PySide6.QtWidgets.QComboBox) None[source]

Register a selector combo box for a row.

Parameters:
  • row – Row index (0-3)

  • combo_box – QComboBox widget

set_selector_options(row: int, options: List[str]) None[source]

Set the available options for a selector.

Parameters:
  • row – Row index (0-3)

  • options – List of option strings

set_all_selectors(digital1: PySide6.QtWidgets.QComboBox, digital2: PySide6.QtWidgets.QComboBox, analog: PySide6.QtWidgets.QComboBox, drums: PySide6.QtWidgets.QComboBox) None[source]

Set all selector combo boxes at once.

Parameters:
  • digital1 – Digital Synth 1 selector

  • digital2 – Digital Synth 2 selector

  • analog – Analog Synth selector

  • drums – Drum kit selector

process_incoming_midi(message) None[source]

Process an incoming MIDI message.

Updates selectors based on incoming notes.

Parameters:

message – Mido Message object

process_outgoing_midi(message) None[source]

Process an outgoing MIDI message.

Converts raw or partial messages to mido Message and updates selectors.

Parameters:

message – List[int], tuple, or mido.Message

set_selector_by_note(row: int, midi_note: int) bool[source]

Update a selector based on a MIDI note.

Parameters:
  • row – Row index (0-3)

  • midi_note – MIDI note number

Returns:

True if selector was updated

set_selector_by_text(row: int, text: str) bool[source]

Update a selector by text value.

Parameters:
  • row – Row index (0-3)

  • text – Item text to select

Returns:

True if selector was updated

set_drum_kit(kit_name: str) bool[source]

Change the drum kit selection.

Parameters:

kit_name – Name of the drum kit

Returns:

True if drum kit was changed

get_selector_state(row: int) ComboBoxState | None[source]

Get the current state of a selector.

Parameters:

row – Row index (0-3)

Returns:

ComboBoxState or None

get_all_selector_states() Dict[int, ComboBoxState][source]

Get the state of all selectors.

Returns:

Dictionary mapping row to ComboBoxState

get_selected_note(row: int) int | None[source]

Get the MIDI note corresponding to the currently selected item in a selector.

Parameters:

row – Row index (0-3)

Returns:

MIDI note number or None

enable_selector(row: int, enabled: bool = True) None[source]

Enable or disable a selector.

Parameters:
  • row – Row index (0-3)

  • enabled – Whether to enable the selector

enable_all_selectors(enabled: bool = True) None[source]

Enable or disable all selectors.

Parameters:

enabled – Whether to enable selectors

reset_selectors() None[source]

Reset all selectors to their first item.

_handle_note_on(message: mido.Message) None[source]

Handle a NOTE_ON message.

Updates the appropriate selector based on channel and note.

Parameters:

message – Mido NOTE_ON message with velocity > 0

_note_to_combo_index(row: int, midi_note: int) int | None[source]

Convert a MIDI note to a combo box index.

Parameters:
  • row – Row index (0-3)

  • midi_note – MIDI note number

Returns:

Combo box index or None

_text_to_note(row: int, text: str) int | None[source]

Convert selector text to a MIDI note.

Parameters:
  • row – Row index

  • text – Text from selector

Returns:

MIDI note or None

_midi_to_note_name(midi_note: int) str[source]

Convert MIDI note to note name.

Parameters:

midi_note – MIDI note number

Returns:

Note name (e.g., ‘C4’)

_midi_to_drum_name(midi_note: int) str[source]

Convert MIDI note to drum name.

Parameters:

midi_note – MIDI note number

Returns:

Drum name or fallback

_basic_note_name_to_midi(note_name: str) int | None[source]

Basic fallback for note name to MIDI conversion.

Parameters:

note_name – Note name (e.g., ‘C4’)

Returns:

MIDI note or None

_set_selector_index_silent(combo_box: PySide6.QtWidgets.QComboBox, index: int) None[source]

Set combo box index without triggering signals.

Parameters:
  • combo_box – QComboBox to update

  • index – Index to set

set_config(config: ComboBoxUpdateConfig) None[source]

Update synchronizer configuration.

Parameters:

config – New ComboBoxUpdateConfig

set_midi_converter(converter: jdxi_editor.midi.conversion.note.MidiNoteConverter) None[source]

Set the MIDI converter.

Parameters:

converter – MidiNoteConverter instance