jdxi_editor.ui.windows.midi.helpers.sysex_decode

Turns a line of hex into the byte list the debugger decodes, and decodes JD-Xi parameter dumps of any length: a 15-byte message sets one parameter, a longer one (a DT1 bulk dump, as the JD-Xi sends in reply to a data request) carries a whole parameter block.

Lines copied from the log file are accepted as they are: the log prints the message without its F0/F7 frame and follows it with the parsed dictionary, so parse_hex_line() stops at the first token that is not a hex byte and frame_sysex() restores F0/F7.

Example

>>> parse_hex_line("41 10 00 00 00 0E 12 19 01 50 00 07 {'SYNTH_TONE': 'MODIFY'}")
[65, 16, 0, 0, 0, 14, 18, 25, 1, 80, 0, 7]
>>> frame_sysex([0x41, 0x10])
[240, 65, 16, 247]
>>> roland_checksum([0x19, 0x01, 0x50, 0x00, 0x07, 0x0B])
4

Attributes

SYSEX_START

SYSEX_END

ROLAND_ID

DATA_START

_HEX_BYTE

Functions

parse_hex_line(line) → list[int]

Leading hex bytes of line, stopping at the first token that is not one.

frame_sysex(message) → list[int]

message with its F0 and F7, adding whichever is missing.

roland_checksum(address_and_data) → int

Roland checksum: the value that makes address + data + checksum a multiple of 128.

is_roland_dump(message) → bool

Whether a framed message is a Roland address message longer than one parameter.

_hex(values) → str

_row(*cells) → str

_rule() → str

decode_parameter_dump(message) → str

Table of the header and every parameter in a framed JD-Xi parameter dump.

Module Contents

jdxi_editor.ui.windows.midi.helpers.sysex_decode.SYSEX_START = 240[source]
jdxi_editor.ui.windows.midi.helpers.sysex_decode.SYSEX_END = 247[source]
jdxi_editor.ui.windows.midi.helpers.sysex_decode.ROLAND_ID = 65[source]
jdxi_editor.ui.windows.midi.helpers.sysex_decode.DATA_START[source]
jdxi_editor.ui.windows.midi.helpers.sysex_decode._HEX_BYTE[source]
jdxi_editor.ui.windows.midi.helpers.sysex_decode.parse_hex_line(line: str) → list[int][source]

Leading hex bytes of line, stopping at the first token that is not one.

Parameters:

line – str e.g. "F0 41 10 ..." or a log line "41 10 ... 04 {...}"

Returns:

list[int] byte values

Raises:

ValueError – if the line does not start with a hex byte

jdxi_editor.ui.windows.midi.helpers.sysex_decode.frame_sysex(message: list[int]) → list[int][source]

message with its F0 and F7, adding whichever is missing.

Parameters:

message – list[int] SysEx bytes, framed or not

Returns:

list[int] framed message

jdxi_editor.ui.windows.midi.helpers.sysex_decode.roland_checksum(address_and_data: Iterable[int]) → int[source]

Roland checksum: the value that makes address + data + checksum a multiple of 128.

Parameters:

address_and_data – Iterable[int] address and data bytes

Returns:

int checksum 0-127

jdxi_editor.ui.windows.midi.helpers.sysex_decode.is_roland_dump(message: list[int]) → bool[source]

Whether a framed message is a Roland address message longer than one parameter.

Parameters:

message – list[int] framed SysEx bytes

Returns:

bool

jdxi_editor.ui.windows.midi.helpers.sysex_decode._hex(values: Iterable[int]) → str[source]
jdxi_editor.ui.windows.midi.helpers.sysex_decode._row(*cells: object) → str[source]
jdxi_editor.ui.windows.midi.helpers.sysex_decode._rule() → str[source]
jdxi_editor.ui.windows.midi.helpers.sysex_decode.decode_parameter_dump(message: list[int]) → str[source]

Table of the header and every parameter in a framed JD-Xi parameter dump.

Data bytes no parameter covers are listed as reserved when they are not 0, and counted otherwise, so a mostly empty block stays readable.

Parameters:

message – list[int] framed SysEx bytes (F0 41 … checksum F7)

Returns:

str text table