jdxi_editor.midi.io.request_queue
jdxi_editor.midi.io.request_queue One paced queue for all SysEx sent with send_with_delay.
The JD-Xi answers one RQ1 (data request) at a time and drops requests that arrive while it is still sending a reply. Editors used to start a thread each on program change, so dozens of requests (many identical) went out within a few milliseconds and about half were never answered.
The queue sends one message at a time from a single worker thread:
an RQ1 is followed by a wait for the DT1 reply at the same address (or a timeout), then a short gap
any other message is followed by MIDI_SLEEP_TIME, as before
a request that is already queued or waiting for its reply is not queued again; the reply reaches every listener anyway
Replies are reported through notify_reply(); the MIDI helper’s JDXiDevice owns the queue and passes on every incoming message.
Example
>>> sent = []
>>> queue = SysExRequestQueue(sent.append, reply_timeout=0.01)
>>> rq1 = bytes.fromhex("F0 41 10 00 00 00 0E 11 19 42 00 00 00 00 00 40 65 F7")
>>> queue.submit([rq1, rq1])
1
>>> queue.wait_idle(1.0)
True
>>> len(sent)
1
Attributes
Classes
Sysex Constants |
|
Send messages one at a time, waiting for each RQ1's reply. |
Functions
|
4-byte address (hex) of a Roland SysEx message with command, else None. |
Module Contents
- jdxi_editor.midi.io.request_queue.roland_address(data: Sequence[int], command: int) str | None[source]
4-byte address (hex) of a Roland SysEx message with command, else None.
Accepts the message with or without F0 (mido’s
sysex.dataomits it). Layout without F0: 41, device, model×4, command, address×4, …
- class jdxi_editor.midi.io.request_queue.SysExRequestQueue(send: Callable[[bytes], Any], *, reply_timeout: float = REPLY_TIMEOUT, reply_gap: float = REPLY_GAP, message_gap: float = MIDI_SLEEP_TIME)[source]
Send messages one at a time, waiting for each RQ1’s reply.
- _items: collections.deque[_Item][source]
- _worker: threading.Thread | None = None[source]
- submit(messages: Iterable[str | bytes | Sequence[int]]) int[source]
Queue messages (hex strings or bytes); returns how many were queued.
- notify_reply(data: Sequence[int]) None[source]
Report incoming SysEx; a DT1 at the awaited address ends the wait.
The request is no longer pending from this moment: the same request made now (a read starting after this reply) is sent again, instead of being dropped as a duplicate while the queue pauses after the reply.
- clear() int[source]
Drop everything not yet sent (e.g. on disconnect); a request awaiting its reply stops waiting. Returns how many messages were dropped.