jdxi_editor.midi.io.device

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.

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

PROGRAM_CHANGE_STATUS

REPLY_WINDOW_S

PROGRAM_CHANGE_AREAS

Classes

JDXiDevice

Request queue, memory mirror and echo guard of one JD-Xi.

Functions

_is_program_change(message) → bool

_roland_body(message) → Optional[list]

The Roland message without F0/F7: 41, device, model×4, command, address×4, data…, checksum.

_area(start_hex, end_hex) → tuple[int, int]

device_for(owner) → JDXiDevice

The JDXiDevice of a MIDI helper (owner.device).

Module Contents

jdxi_editor.midi.io.device.PROGRAM_CHANGE_STATUS = 192[source]
jdxi_editor.midi.io.device.REPLY_WINDOW_S = 2.0[source]
jdxi_editor.midi.io.device._is_program_change(message: Sequence[int]) → bool[source]
jdxi_editor.midi.io.device._roland_body(message: Sequence[int]) → list | None[source]

The Roland message without F0/F7: 41, device, model×4, command, address×4, data…, checksum.

jdxi_editor.midi.io.device._area(start_hex: str, end_hex: str) → tuple[int, int][source]
jdxi_editor.midi.io.device.PROGRAM_CHANGE_AREAS: dict[int, list[tuple[int, int]] | None][source]
class jdxi_editor.midi.io.device.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)[source]

Request queue, memory mirror and echo guard of one JD-Xi.

requests[source]
memory[source]
echo_guard[source]
state[source]
_sequence = 0[source]
_requested: dict[int, tuple[int, float]][source]
_written: dict[int, tuple[int, int, float]][source]
clock: Callable[[], float][source]
request(messages: Iterable[str | bytes | Sequence[int]]) → int[source]

Queue RQ1 (and other) messages; returns how many were queued.

applying_device_data() → contextlib.AbstractContextManager[None][source]

Scope in which this thread applies data received from the JD-Xi.

received(message: Sequence[int]) → None[source]

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.

before_send(message: Sequence[int]) → bool[source]

False if message must not be sent (a DT1 echoing received data).

sent(message: Sequence[int]) → None[source]

A message the editor sent: what the synth now holds.

fresh(message: Sequence[int]) → list | None[source]

A reply (DT1) with the bytes the editor wrote after asking for it put back.

Returns:

the reply without F0/F7 and with its checksum made again, or None when nothing is to change

send_failed(message: Sequence[int]) → None[source]

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.

_program_changed(channel: int) → None[source]

Forget what a program change on channel replaced.

A tone change on one part used to forget the whole program.

jdxi_editor.midi.io.device.device_for(owner: Any) → JDXiDevice[source]

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.