jdxi_editor.midi.io.synth_memory

jdxi_editor.midi.io.synth_memory What the editor knows of the JD-Xi’s parameter memory, byte by byte.

Every DT1 (data set) that passes through the MIDI helper is recorded: replies from the JD-Xi and the parameter changes the editor sends. A patch can then be saved as the synth’s own bytes, i.e. raw MIDI values, rather than from the editor’s controls, whose display units (ms, fractions, ±63) differ per widget and lose precision.

Roland addresses and sizes are 7-bit per byte; they are kept as linear offsets so a section can cross a byte boundary (Effect 1 is 145 bytes from 18 00 02 00, ending at 18 00 03 10).

Example

>>> memory = SynthMemory()
>>> memory.record_dt1(bytes.fromhex("F0 41 10 00 00 00 0E 12 19 42 00 00 01 02 22 F7"))
True
>>> memory.read(bytes.fromhex("19 42 00 00"), 2)
b'\x01\x02'
>>> memory.read(bytes.fromhex("19 42 00 00"), 3) is None   # third byte unknown
True

Attributes

JDXI_DT1_HEADER

SYSEX_END

Classes

SynthMemory

Thread-safe byte map of the JD-Xi's memory, filled from DT1 messages.

Functions

address_to_linear(address) → int

4 bytes of 7 bits -> linear offset.

linear_to_address(value) → bytes

Linear offset -> 4 bytes of 7 bits.

roland_checksum(data) → int

build_dt1(address, data) → bytes

A JD-Xi DT1 message writing data at address.

Module Contents

jdxi_editor.midi.io.synth_memory.JDXI_DT1_HEADER[source]
jdxi_editor.midi.io.synth_memory.SYSEX_END = 247[source]
jdxi_editor.midi.io.synth_memory.address_to_linear(address: Sequence[int]) → int[source]

4 bytes of 7 bits -> linear offset.

jdxi_editor.midi.io.synth_memory.linear_to_address(value: int) → bytes[source]

Linear offset -> 4 bytes of 7 bits.

jdxi_editor.midi.io.synth_memory.roland_checksum(data: Sequence[int]) → int[source]
jdxi_editor.midi.io.synth_memory.build_dt1(address: Sequence[int], data: Sequence[int]) → bytes[source]

A JD-Xi DT1 message writing data at address.

class jdxi_editor.midi.io.synth_memory.SynthMemory[source]

Thread-safe byte map of the JD-Xi’s memory, filled from DT1 messages.

SECTION_MIN_BYTES = 8[source]
_bytes: dict[int, int][source]
_sections: dict[int, int][source]
_lock[source]
record_dt1(message: Sequence[int]) → bool[source]

Record a DT1 message (with or without F0/F7); returns False if it is not one.

Layout without F0: 41, device, model×4, 12, address×4, data…, checksum[, F7]

sections() → list[tuple[bytes, int]][source]

(address, size) of every section seen as a whole, in address order.

read(address: Sequence[int], size: int) → bytes | None[source]

The size bytes from address, or None if any of them is unknown.

section_dt1(address: Sequence[int], size: int) → bytes | None[source]

The section as one DT1 message, as the JD-Xi would send it, or None.

clear() → None[source]
forget(ranges: Sequence[tuple[int, int]]) → None[source]

Forget the bytes (and sections) in linear [start, end) ranges.