jdxi_editor.ui.editors.synth.specs

Attributes

DRUM_KIT_SPECS

INSTRUMENT_FAMILY_SPECS

ENGINE_KEYWORDS

ENGINE_IMAGE_SPECS

ENGINE_IMAGE_ALIASES

SHORT_KEYWORD_LENGTH

_CAMEL_SPLIT

_TRAILING_INDEX

_JOINERS

Classes

InstrumentDescriptor

Canonical description of a JD-Xi instrument preset.

InstrumentFamilySpec

DrumKitSpec

EngineKeywordSpec

EngineImageSpec

Icon filenames that may carry an engine's artwork.

Functions

preset_match_text(text) → str

Normalize preset labels for keyword matching.

engine_image_basenames(name) → tuple[str, ...]

Expand an engine or instrument name into the image basenames to try.

_short_keyword_pattern(keyword) → re.Pattern

preset_match_texts(text) → tuple[str, ...]

Normalized forms of a preset label to match keywords against.

keyword_in(texts, keyword) → bool

Test whether keyword occurs in any of the normalized texts.

any_keyword_in(texts, keywords) → bool

Test whether any of keywords occurs in texts.

preset_image_basenames(text) → tuple[str, ...]

Candidate image basenames named after the preset itself.

Module Contents

class jdxi_editor.ui.editors.synth.specs.InstrumentDescriptor[source]

Canonical description of a JD-Xi instrument preset.

category: str[source]
family: str | None[source]
engine: str | None[source]
raw_text: str[source]
class jdxi_editor.ui.editors.synth.specs.InstrumentFamilySpec[source]
family: str[source]
keywords: Iterable[str][source]
class jdxi_editor.ui.editors.synth.specs.DrumKitSpec[source]
engine: str[source]
keywords: tuple[str, ...][source]
family: str = 'kit'[source]
jdxi_editor.ui.editors.synth.specs.preset_match_text(text: str) → str[source]

Normalize preset labels for keyword matching.

Strips a leading program index (e.g. 001 - Power 3 → power 3, 101: MKS-50 Bass1 → mks-50 bass1). The index has to go, otherwise it is matched as a model number: 101 would detect an SH-101 and 202 an MC-202.

jdxi_editor.ui.editors.synth.specs.DRUM_KIT_SPECS[source]
jdxi_editor.ui.editors.synth.specs.INSTRUMENT_FAMILY_SPECS[source]
class jdxi_editor.ui.editors.synth.specs.EngineKeywordSpec[source]
name: str[source]
keywords: Iterable[str][source]
jdxi_editor.ui.editors.synth.specs.ENGINE_KEYWORDS: list[EngineKeywordSpec][source]
class jdxi_editor.ui.editors.synth.specs.EngineImageSpec[source]

Icon filenames that may carry an engine’s artwork.

Note that basenames holds filenames, not keywords: keywords decide which engine a preset belongs to (see EngineKeywordSpec), while these decide which file is drawn for it.

name: str[source]
basenames: tuple[str, ...][source]
jdxi_editor.ui.editors.synth.specs.ENGINE_IMAGE_SPECS: list[EngineImageSpec][source]
jdxi_editor.ui.editors.synth.specs.ENGINE_IMAGE_ALIASES: dict[str, tuple[str, ...]][source]
jdxi_editor.ui.editors.synth.specs.engine_image_basenames(name: str) → tuple[str, ...][source]

Expand an engine or instrument name into the image basenames to try.

Parameters:

name – Detected engine or instrument name (e.g. "tb").

Returns:

Candidate basenames without extension, most specific first.

jdxi_editor.ui.editors.synth.specs.SHORT_KEYWORD_LENGTH = 3[source]
jdxi_editor.ui.editors.synth.specs._short_keyword_pattern(keyword: str) → re.Pattern[source]
jdxi_editor.ui.editors.synth.specs._CAMEL_SPLIT[source]
jdxi_editor.ui.editors.synth.specs.preset_match_texts(text: str) → tuple[str, ...][source]

Normalized forms of a preset label to match keywords against.

The JD-Xi runs tone names together to fit its display, and the two forms pull in opposite directions: "S-SawStacLd1" needs the glued form for the keyword sawstac, while "ResoPulseBs1" needs the split form for the keyword bs. Both are returned, so a keyword matching either counts.

Parameters:

text – Preset label, with or without its index.

Returns:

The normalized label, plus its camel-case-split form when that differs.

jdxi_editor.ui.editors.synth.specs.keyword_in(texts, keyword: str) → bool[source]

Test whether keyword occurs in any of the normalized texts.

Keywords longer than SHORT_KEYWORD_LENGTH match as substrings; shorter ones have to sit on a letter boundary.

Parameters:
  • texts – Normalized preset text, or several forms of it (see preset_match_texts()).

  • keyword – Keyword to look for, lower case.

Returns:

True when the keyword matches.

jdxi_editor.ui.editors.synth.specs.any_keyword_in(texts, keywords: Iterable[str]) → bool[source]

Test whether any of keywords occurs in texts.

Parameters:
  • texts – Normalized preset text, or several forms of it.

  • keywords – Keywords to look for.

Returns:

True when at least one keyword matches.

jdxi_editor.ui.editors.synth.specs._TRAILING_INDEX[source]
jdxi_editor.ui.editors.synth.specs._JOINERS = (' ', '-', '_')[source]
jdxi_editor.ui.editors.synth.specs.preset_image_basenames(text: str) → tuple[str, ...][source]

Candidate image basenames named after the preset itself.

The preset label, minus its index and trailing variant number, is offered in the spellings artwork tends to use: "164: Trem EP 1" looks for trem ep, trem-ep, trem_ep (and the same without punctuation). Dropping a file named after a preset into the icon folder is therefore enough to give that preset its own image – no table to update here.

Only multi-word phrases are returned. A single word is far too broad to be preset-specific (“bass”, “lead”), and the name and family lookups already cover that case.

Parameters:

text – Preset label, with or without its index.

Returns:

Candidate basenames without extension, most specific first.