jdxi_editor.ui.widgets.combo_box.synchronizer ============================================= .. py:module:: jdxi_editor.ui.widgets.combo_box.synchronizer .. autoapi-nested-parse:: 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 ------- .. autoapisummary:: jdxi_editor.ui.widgets.combo_box.synchronizer.ComboBoxUpdateConfig jdxi_editor.ui.widgets.combo_box.synchronizer.ComboBoxState jdxi_editor.ui.widgets.combo_box.synchronizer.ComboBoxSynchronizer Module Contents --------------- .. py:class:: ComboBoxUpdateConfig(silence_logging: bool = False, min_note: int = 36, update_interval_ms: int = 100) Configuration for combo box synchronization. .. py:attribute:: silence_logging :value: False .. py:attribute:: min_note :value: 36 .. py:attribute:: update_interval_ms :value: 100 .. py:class:: ComboBoxState(row: int, current_index: int, current_text: str, note: Optional[int] = None) Represents the state of a combo box selector. .. py:attribute:: row .. py:attribute:: current_index .. py:attribute:: current_text .. py:attribute:: note :value: None .. py:class:: ComboBoxSynchronizer(config: Optional[ComboBoxUpdateConfig] = None, midi_converter: Optional[jdxi_editor.midi.conversion.note.MidiNoteConverter] = None, scope: str = 'ComboBoxSynchronizer') 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 .. py:attribute:: CHANNEL_TO_ROW .. py:attribute:: ROW_TO_CHANNEL .. py:attribute:: config .. py:attribute:: midi_converter :value: None .. py:attribute:: scope :value: 'ComboBoxSynchronizer' .. py:attribute:: selectors :type: Dict[int, PySide6.QtWidgets.QComboBox] .. py:attribute:: row_options :type: Dict[int, List[str]] .. py:attribute:: last_update_time :type: Dict[int, float] .. py:attribute:: on_selector_changed :type: Optional[Callable[[ComboBoxState], None]] :value: None .. py:attribute:: on_drum_kit_changed :type: Optional[Callable[[str], None]] :value: None .. py:attribute:: on_note_received :type: Optional[Callable[[int, int], None]] :value: None .. py:method:: set_selector(row: int, combo_box: PySide6.QtWidgets.QComboBox) -> None Register a selector combo box for a row. :param row: Row index (0-3) :param combo_box: QComboBox widget .. py:method:: set_selector_options(row: int, options: List[str]) -> None Set the available options for a selector. :param row: Row index (0-3) :param options: List of option strings .. py:method:: set_all_selectors(digital1: PySide6.QtWidgets.QComboBox, digital2: PySide6.QtWidgets.QComboBox, analog: PySide6.QtWidgets.QComboBox, drums: PySide6.QtWidgets.QComboBox) -> None Set all selector combo boxes at once. :param digital1: Digital Synth 1 selector :param digital2: Digital Synth 2 selector :param analog: Analog Synth selector :param drums: Drum kit selector .. py:method:: process_incoming_midi(message) -> None Process an incoming MIDI message. Updates selectors based on incoming notes. :param message: Mido Message object .. py:method:: process_outgoing_midi(message) -> None Process an outgoing MIDI message. Converts raw or partial messages to mido Message and updates selectors. :param message: List[int], tuple, or mido.Message .. py:method:: set_selector_by_note(row: int, midi_note: int) -> bool Update a selector based on a MIDI note. :param row: Row index (0-3) :param midi_note: MIDI note number :return: True if selector was updated .. py:method:: set_selector_by_text(row: int, text: str) -> bool Update a selector by text value. :param row: Row index (0-3) :param text: Item text to select :return: True if selector was updated .. py:method:: set_drum_kit(kit_name: str) -> bool Change the drum kit selection. :param kit_name: Name of the drum kit :return: True if drum kit was changed .. py:method:: get_selector_state(row: int) -> Optional[ComboBoxState] Get the current state of a selector. :param row: Row index (0-3) :return: ComboBoxState or None .. py:method:: get_all_selector_states() -> Dict[int, ComboBoxState] Get the state of all selectors. :return: Dictionary mapping row to ComboBoxState .. py:method:: get_selected_note(row: int) -> Optional[int] Get the MIDI note corresponding to the currently selected item in a selector. :param row: Row index (0-3) :return: MIDI note number or None .. py:method:: enable_selector(row: int, enabled: bool = True) -> None Enable or disable a selector. :param row: Row index (0-3) :param enabled: Whether to enable the selector .. py:method:: enable_all_selectors(enabled: bool = True) -> None Enable or disable all selectors. :param enabled: Whether to enable selectors .. py:method:: reset_selectors() -> None Reset all selectors to their first item. .. py:method:: _handle_note_on(message: mido.Message) -> None Handle a NOTE_ON message. Updates the appropriate selector based on channel and note. :param message: Mido NOTE_ON message with velocity > 0 .. py:method:: _note_to_combo_index(row: int, midi_note: int) -> Optional[int] Convert a MIDI note to a combo box index. :param row: Row index (0-3) :param midi_note: MIDI note number :return: Combo box index or None .. py:method:: _text_to_note(row: int, text: str) -> Optional[int] Convert selector text to a MIDI note. :param row: Row index :param text: Text from selector :return: MIDI note or None .. py:method:: _midi_to_note_name(midi_note: int) -> str Convert MIDI note to note name. :param midi_note: MIDI note number :return: Note name (e.g., 'C4') .. py:method:: _midi_to_drum_name(midi_note: int) -> str Convert MIDI note to drum name. :param midi_note: MIDI note number :return: Drum name or fallback .. py:method:: _basic_note_name_to_midi(note_name: str) -> Optional[int] Basic fallback for note name to MIDI conversion. :param note_name: Note name (e.g., 'C4') :return: MIDI note or None .. py:method:: _set_selector_index_silent(combo_box: PySide6.QtWidgets.QComboBox, index: int) -> None Set combo box index without triggering signals. :param combo_box: QComboBox to update :param index: Index to set .. py:method:: set_config(config: ComboBoxUpdateConfig) -> None Update synchronizer configuration. :param config: New ComboBoxUpdateConfig .. py:method:: set_midi_converter(converter: jdxi_editor.midi.conversion.note.MidiNoteConverter) -> None Set the MIDI converter. :param converter: MidiNoteConverter instance