jdxi_editor.midi.sysex.request.read_session =========================================== .. py:module:: jdxi_editor.midi.sysex.request.read_session .. autoapi-nested-parse:: Coordinated RQ1 read session with DT1 address matching and section status. Used by Patch Manager and per-editor "Read from JD-Xi" actions so saves are not based on stale UI state without an explicit hardware round-trip. Replies are matched on the raw DT1 bytes from the MIDI input (``midi_message_incoming``). The parsed ``midi_sysex_json`` signal is not used when raw input is available: its ADDRESS field is the command byte plus only three address bytes (e.g. ``"12194200"`` for ``19 42 00 00``), and the same signal also carries JSON from patch files being loaded, which are not replies. Attributes ---------- .. autoapisummary:: jdxi_editor.midi.sysex.request.read_session.DRUM_PARTIAL_COUNT jdxi_editor.midi.sysex.request.read_session.DRUM_FIRST_NOTE jdxi_editor.midi.sysex.request.read_session._DRUM_FIRST_LMB jdxi_editor.midi.sysex.request.read_session._DRUM_PARTIAL_SIZE Classes ------- .. autoapisummary:: jdxi_editor.midi.sysex.request.read_session.SectionStatus jdxi_editor.midi.sysex.request.read_session.ReadSectionResult jdxi_editor.midi.sysex.request.read_session.ReadResult jdxi_editor.midi.sysex.request.read_session.PatchReadSession Functions --------- .. autoapisummary:: jdxi_editor.midi.sysex.request.read_session.normalize_address jdxi_editor.midi.sysex.request.read_session.address_from_rq1_hex jdxi_editor.midi.sysex.request.read_session.address_from_dt1_bytes jdxi_editor.midi.sysex.request.read_session.address_from_parsed_json jdxi_editor.midi.sysex.request.read_session.label_for_address jdxi_editor.midi.sysex.request.read_session.drum_partial_index jdxi_editor.midi.sysex.request.read_session.rq1_hex jdxi_editor.midi.sysex.request.read_session.patch_section_requests jdxi_editor.midi.sysex.request.read_session.sections_from_requests jdxi_editor.midi.sysex.request.read_session.collect_editor_requests jdxi_editor.midi.sysex.request.read_session.start_read_session Module Contents --------------- .. py:class:: SectionStatus Bases: :py:obj:`str`, :py:obj:`enum.Enum` str(object='') -> str str(bytes_or_buffer[, encoding[, errors]]) -> str Create a new string object from the given object. If encoding or errors is specified, then the object must expose a data buffer that will be decoded using the given encoding and error handler. Otherwise, returns the result of object.__str__() (if defined) or repr(object). encoding defaults to sys.getdefaultencoding(). errors defaults to 'strict'. .. py:attribute:: PENDING :value: 'pending' .. py:attribute:: OK :value: 'ok' .. py:attribute:: TIMEOUT :value: 'timeout' .. py:attribute:: ERROR :value: 'error' .. py:class:: ReadSectionResult Status for one expected SysEx section. .. py:attribute:: label :type: str .. py:attribute:: address :type: str .. py:attribute:: request_hex :type: str .. py:attribute:: status :type: SectionStatus .. py:property:: ok :type: bool .. py:class:: ReadResult Outcome of a full or scoped read session. .. py:attribute:: sections :type: List[ReadSectionResult] :value: [] .. py:property:: complete :type: bool .. py:property:: pending_count :type: int .. py:property:: ok_count :type: int .. py:method:: summary() -> str .. py:function:: normalize_address(address: Optional[str]) -> str Normalize an address hex string for comparison (no spaces, lower). .. py:function:: address_from_rq1_hex(request_hex: str) -> str Extract the 4-byte Roland address from an RQ1 SysEx hex string. RQ1 layout after the JD-Xi header: command ``11``, then address (4 bytes), then size (4 bytes), checksum, ``F7``. .. py:function:: address_from_dt1_bytes(data: Sequence[int]) -> Optional[str] 4-byte address of a Roland DT1 (data set) message, or None if *data* is not one. .. py:function:: address_from_parsed_json(address_field: Optional[str]) -> str Normalise the ADDRESS of a parsed-SysEx JSON payload to the 4-byte form. The parser reports ``command + 3 address bytes`` (``"12194200"``); patch JSON written by the composer uses the 4-byte address (``"19420000"``). .. py:function:: label_for_address(address: str) -> str Human-readable label for a common JD-Xi temporary address. .. py:data:: DRUM_PARTIAL_COUNT :value: 38 .. py:data:: DRUM_FIRST_NOTE :value: 36 .. py:data:: _DRUM_FIRST_LMB :value: 46 .. py:data:: _DRUM_PARTIAL_SIZE :value: (0, 0, 1, 67) .. py:function:: drum_partial_index(address: str) -> Optional[int] 0-based drum partial of a 19 70 xx 00 address, or None. .. py:function:: rq1_hex(address: Sequence[int], size: Sequence[int]) -> str JD-Xi RQ1 (data request) for *size* bytes at *address*, as hex. .. py:function:: patch_section_requests() -> List[Tuple[str, str]] (label, RQ1) for every section of a patch, whichever editors are open. Program Common, Vocal FX, Effects, Delay, Reverb, Zones, Arpeggio, both Digital synths (Common, partials, Modify), Analog, Drum Common and all 38 drum partials. .. py:function:: sections_from_requests(requests: Sequence[str], *, labels: Optional[Sequence[str]] = None) -> List[ReadSectionResult] Build section results from RQ1 hex strings. .. py:function:: collect_editor_requests(editors: Iterable[Any], *, skip_types: Optional[Tuple[type, ...]] = None) -> List[Tuple[str, str]] Collect (label, rq1_hex) from editors that expose ``midi_requests``. Deduplicates by address (first wins). .. py:class:: PatchReadSession(midi_helper, sections: Sequence[ReadSectionResult], *, timeout_ms: int = 8000, parent: Optional[PySide6.QtCore.QObject] = None) Bases: :py:obj:`PySide6.QtCore.QObject` Send RQ1s and wait for matching DT1 addresses via ``midi_sysex_json``. Emits ``progress`` as sections update and ``finished`` with the final :class:`ReadResult` (complete, partial, or timed out). .. py:attribute:: progress .. py:attribute:: finished .. py:attribute:: _midi_helper .. py:attribute:: _sections .. py:attribute:: _by_address :type: Dict[str, ReadSectionResult] .. py:attribute:: _timeout_ms :value: 8000 .. py:attribute:: _timer .. py:attribute:: _connected :value: False .. py:attribute:: _connected_signal :value: None .. py:attribute:: _done :value: False .. py:property:: result :type: ReadResult .. py:method:: start() -> None Connect to MIDI input, send RQ1s, and start the timeout timer. .. py:method:: cancel() -> None Stop waiting; mark remaining sections as timeout. .. py:method:: _on_midi_message(message: Any) -> None Raw MIDI input: match DT1 replies by their exact address. .. py:method:: _on_sysex_json(payload: str) -> None Fallback when raw input is unavailable: match parsed-SysEx JSON. .. py:method:: _mark_received(address: str) -> None .. py:property:: pending_count :type: int .. py:method:: _on_timeout() -> None .. py:method:: _finish() -> None .. py:method:: _tell_connection(result: ReadResult) -> None A whole reading: answers arrive; a partial one: some did not (UNSTABLE). .. py:method:: _disconnect() -> None .. py:function:: start_read_session(midi_helper, requests: Sequence[str], *, labels: Optional[Sequence[str]] = None, timeout_ms: int = 8000, on_progress: Optional[Callable[[ReadResult], None]] = None, on_finished: Optional[Callable[[ReadResult], None]] = None, parent: Optional[PySide6.QtCore.QObject] = None) -> PatchReadSession Convenience: build sections, wire callbacks, and start.