jdxi_editor.midi.io.device ========================== .. py:module:: jdxi_editor.midi.io.device .. autoapi-nested-parse:: jdxi_editor.midi.io.device The connected JD-Xi as the editor sees it. One JDXiDevice holds the state that belongs to the synth rather than to any editor: - ``requests``: the SysExRequestQueue that paces RQ1 requests, one reply at a time - ``memory``: the SynthMemory mirror of the synth's parameter bytes, which patches are saved from - ``echo_guard``: the EchoGuard that stops data received from the synth being written straight back to it The MIDI helper owns one (``helper.device``) and reports every message to it: ``received()`` for incoming messages, ``before_send()`` and ``sent()`` for outgoing ones. .. rubric:: Example >>> sent = [] >>> device = JDXiDevice(sent.append) >>> reply = bytes.fromhex("F0 41 10 00 00 00 0E 12 19 42 00 00 01 02 22 F7") >>> device.received(reply) >>> device.memory.read(bytes.fromhex("19 42 00 00"), 2) b'\x01\x02' >>> with device.applying_device_data(): ... device.before_send(reply) # an editor echoing the reply False >>> device.received([0xC0, 0x05]) # program change: the program is replaced >>> device.memory.sections() [] Attributes ---------- .. autoapisummary:: jdxi_editor.midi.io.device.PROGRAM_CHANGE_STATUS jdxi_editor.midi.io.device.REPLY_WINDOW_S jdxi_editor.midi.io.device.PROGRAM_CHANGE_AREAS Classes ------- .. autoapisummary:: jdxi_editor.midi.io.device.JDXiDevice Functions --------- .. autoapisummary:: jdxi_editor.midi.io.device._is_program_change jdxi_editor.midi.io.device._roland_body jdxi_editor.midi.io.device._area jdxi_editor.midi.io.device.device_for Module Contents --------------- .. py:data:: PROGRAM_CHANGE_STATUS :value: 192 .. py:data:: REPLY_WINDOW_S :value: 2.0 .. py:function:: _is_program_change(message: Sequence[int]) -> bool .. py:function:: _roland_body(message: Sequence[int]) -> Optional[list] The Roland message without F0/F7: 41, device, model×4, command, address×4, data…, checksum. .. py:function:: _area(start_hex: str, end_hex: str) -> tuple[int, int] .. py:data:: PROGRAM_CHANGE_AREAS :type: dict[int, Optional[list[tuple[int, int]]]] .. py:class:: JDXiDevice(send: Callable[[Sequence[int]], Any], requests: jdxi_editor.midi.io.request_queue.SysExRequestQueue | None = None, memory: jdxi_editor.midi.io.synth_memory.SynthMemory | None = None, echo_guard: jdxi_editor.midi.io.echo_guard.EchoGuard | None = None) Request queue, memory mirror and echo guard of one JD-Xi. .. py:attribute:: requests .. py:attribute:: memory .. py:attribute:: echo_guard .. py:attribute:: state .. py:attribute:: _sequence :value: 0 .. py:attribute:: _requested :type: dict[int, tuple[int, float]] .. py:attribute:: _written :type: dict[int, tuple[int, int, float]] .. py:attribute:: clock :type: Callable[[], float] .. py:method:: request(messages: Iterable[Union[str, bytes, Sequence[int]]]) -> int Queue RQ1 (and other) messages; returns how many were queued. .. py:method:: applying_device_data() -> contextlib.AbstractContextManager[None] Scope in which this thread applies data received from the JD-Xi. .. py:method:: received(message: Sequence[int]) -> None A message from the JD-Xi (SysEx with or without F0/F7, or channel data). A DT1 reply lets the queue send its next request and is recorded in memory; a program change forgets what it replaced. .. py:method:: before_send(message: Sequence[int]) -> bool False if *message* must not be sent (a DT1 echoing received data). .. py:method:: sent(message: Sequence[int]) -> None A message the editor sent: what the synth now holds. .. py:method:: fresh(message: Sequence[int]) -> Optional[list] A reply (DT1) with the bytes the editor wrote after asking for it put back. :return: the reply without F0/F7 and with its checksum made again, or None when nothing is to change .. py:method:: send_failed(message: Sequence[int]) -> None *message* was recorded by sent() but did not go out. What it would have written is not known any more, so it is forgotten rather than counted as held by the JD-Xi. .. py:method:: _program_changed(channel: int) -> None Forget what a program change on *channel* replaced. A tone change on one part used to forget the whole program. .. py:function:: device_for(owner: Any) -> JDXiDevice The JDXiDevice of a MIDI helper (``owner.device``). For objects that are not MidiIOControllers (tests, tools), a device is created on first use and kept on the object.