jdxi_editor.midi.sysex.patch_bundle =================================== .. py:module:: jdxi_editor.midi.sysex.patch_bundle .. autoapi-nested-parse:: 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 ---------- .. autoapisummary:: jdxi_editor.midi.sysex.patch_bundle.JDXI_HEADER_HEX jdxi_editor.midi.sysex.patch_bundle.PATCH_AREAS jdxi_editor.midi.sysex.patch_bundle._PARSER_NOISE jdxi_editor.midi.sysex.patch_bundle.BUNDLE_MIDI_NAME jdxi_editor.midi.sysex.patch_bundle.BUNDLE_MIDI_MAX_BYTES Functions --------- .. autoapisummary:: jdxi_editor.midi.sysex.patch_bundle.section_file_name jdxi_editor.midi.sysex.patch_bundle.section_from_dt1 jdxi_editor.midi.sysex.patch_bundle.write_memory_sections jdxi_editor.midi.sysex.patch_bundle.convert_editor_sections jdxi_editor.midi.sysex.patch_bundle.section_sysex jdxi_editor.midi.sysex.patch_bundle.load_section jdxi_editor.midi.sysex.patch_bundle.section_param_dt1s jdxi_editor.midi.sysex.patch_bundle.extract_bundle_midi Module Contents --------------- .. py:data:: JDXI_HEADER_HEX :value: 'f041100000000e' .. py:data:: PATCH_AREAS :value: (24, 25) .. py:data:: _PARSER_NOISE :value: ('parameter_block', 'block_name') .. py:function:: section_file_name(address_hex: str) -> str .. py:function:: section_from_dt1(dt1: bytes) -> dict Bundle JSON for one DT1 section: parsed values, 4-byte ADDRESS, SYSEX. .. py:function:: write_memory_sections(memory: jdxi_editor.midi.io.synth_memory.SynthMemory, folder: pathlib.Path, only: Optional[set[str]] = None) -> set[str] Write every complete patch section in *memory*; returns their addresses. :param 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) .. py:function:: convert_editor_sections(folder: pathlib.Path, skip: set[str]) -> int Convert the editor-written sections in *folder* to raw MIDI values. :param skip: addresses written from the synth's memory (already raw) :return: number of files converted .. py:function:: section_sysex(section: dict) -> Optional[bytes] The section's DT1 message, if it carries one. .. py:function:: load_section(section: dict) -> dict A loaded section in raw MIDI values (old sections are converted). .. py:function:: section_param_dt1s(section: dict) -> list[bytes] 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. .. py:data:: BUNDLE_MIDI_NAME :value: 'bundle.mid' .. py:data:: BUNDLE_MIDI_MAX_BYTES :value: 33554432 .. py:function:: extract_bundle_midi(zip_ref, folder: pathlib.Path) -> Optional[pathlib.Path] 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. :param zip_ref: an open zipfile.ZipFile :return: the file written, or None when the bundle has no usable MIDI file