jdxi_editor.midi.sysex.patch_bundle

jdxi_editor.midi.sysex.patch_bundle Write and read the JSON sections of a patch bundle (.jsz / .msz).

Saving takes each section from the synth’s memory (see SynthMemory) when it is complete there: the JSON is the parsed DT1, exactly as a reply from the JD-Xi, plus SYSEX (that DT1) and VALUE_FORMAT: "midi". Sections the memory does not hold are written from the editor controls and converted to raw MIDI values.

Loading sends a section’s SYSEX unchanged when it has one; older sections, saved in display units, are converted first.

Attributes

JDXI_HEADER_HEX

PATCH_AREAS

_PARSER_NOISE

BUNDLE_MIDI_NAME

BUNDLE_MIDI_MAX_BYTES

Functions

section_file_name(address_hex) → str

section_from_dt1(dt1) → dict

Bundle JSON for one DT1 section: parsed values, 4-byte ADDRESS, SYSEX.

write_memory_sections(memory, folder[, only]) → set[str]

Write every complete patch section in memory; returns their addresses.

convert_editor_sections(folder, skip) → int

Convert the editor-written sections in folder to raw MIDI values.

section_sysex(section) → Optional[bytes]

The section's DT1 message, if it carries one.

load_section(section) → dict

A loaded section in raw MIDI values (old sections are converted).

section_param_dt1s(section) → list[bytes]

One DT1 per parameter of a section in raw MIDI values.

extract_bundle_midi(zip_ref, folder) → Optional[pathlib.Path]

Copy the first MIDI file of a .msz bundle into folder, under a name of our own.

Module Contents

jdxi_editor.midi.sysex.patch_bundle.JDXI_HEADER_HEX = 'f041100000000e'[source]
jdxi_editor.midi.sysex.patch_bundle.PATCH_AREAS = (24, 25)[source]
jdxi_editor.midi.sysex.patch_bundle._PARSER_NOISE = ('parameter_block', 'block_name')[source]
jdxi_editor.midi.sysex.patch_bundle.section_file_name(address_hex: str) → str[source]
jdxi_editor.midi.sysex.patch_bundle.section_from_dt1(dt1: bytes) → dict[source]

Bundle JSON for one DT1 section: parsed values, 4-byte ADDRESS, SYSEX.

jdxi_editor.midi.sysex.patch_bundle.write_memory_sections(memory: jdxi_editor.midi.io.synth_memory.SynthMemory, folder: pathlib.Path, only: set[str] | None = None) → set[str][source]

Write every complete patch section in memory; returns their addresses.

Parameters:

only – when given, the 4-byte addresses (hex, e.g. "19420000") that a read of the JD-Xi has just confirmed: the other sections in memory may be from before (the editor controls are used for them, as the user was told)

jdxi_editor.midi.sysex.patch_bundle.convert_editor_sections(folder: pathlib.Path, skip: set[str]) → int[source]

Convert the editor-written sections in folder to raw MIDI values.

Parameters:

skip – addresses written from the synth’s memory (already raw)

Returns:

number of files converted

jdxi_editor.midi.sysex.patch_bundle.section_sysex(section: dict) → bytes | None[source]

The section’s DT1 message, if it carries one.

jdxi_editor.midi.sysex.patch_bundle.load_section(section: dict) → dict[source]

A loaded section in raw MIDI values (old sections are converted).

jdxi_editor.midi.sysex.patch_bundle.section_param_dt1s(section: dict) → list[bytes][source]

One DT1 per parameter of a section in raw MIDI values.

The values are written as they are (no display conversion), at the section address plus the parameter’s offset; 4-nibble parameters are split as the JD-Xi expects.

jdxi_editor.midi.sysex.patch_bundle.BUNDLE_MIDI_NAME = 'bundle.mid'[source]
jdxi_editor.midi.sysex.patch_bundle.BUNDLE_MIDI_MAX_BYTES = 33554432[source]
jdxi_editor.midi.sysex.patch_bundle.extract_bundle_midi(zip_ref, folder: pathlib.Path) → pathlib.Path | None[source]

Copy the first MIDI file of a .msz bundle into folder, under a name of our own.

The name inside the ZIP is never used as a path: «../../x.mid» or an absolute path would write outside folder (zip slip). Oversized entries are refused.

Parameters:

zip_ref – an open zipfile.ZipFile

Returns:

the file written, or None when the bundle has no usable MIDI file