jdxi_editor.midi.io.controller_map
Routes control-change messages from a hardware controller (not the JD-Xi) to filter controls of the synth editor that is open, and to the effect levels that the JD-Xi’s own right-hand knobs set.
Each supported controller is a ControllerProfile, read from JSON
rather than written here:
midi_controllers.jsonnext to this module holds the built-in controllers (the Arturia MiniLab 3 and the SINCO VMX8);~/.jdxi_editor/midi_controllers.json(user_config_path()) is the user’s copy, written on first start byinstall_user_config(). A controller in it overrides the keys it gives of the built-in one with the sameid; a newidadds a controller.
Set the environment variable JDXI_EDITOR_MIDI_CONTROLLERS to read another
user file, or to an empty string to use the built-in controllers only.
Changes to the file take effect when the editor is restarted. Mappings learnt
in the MIDI Controller dialog are stored separately and take precedence
(jdxi_editor.midi.io.controller_settings).
A controller entry looks like:
{
"id": "minilab3",
"label": "Arturia MiniLab 3",
"port_names": ["minilab"],
"secondary_port_names": ["din thru", "mcu", "hui", "alv"],
"single_port": false,
"mappings": [{"cc": 74, "control": "CUTOFF", "source": "Knob 1"}, ...],
"transport": [{"action": "PLAY", "cc": 107}, {"action": "PAUSE", "note": 93}]
}
control is a FilterControl name and source the physical knob
or fader, shown in the MIDI Controller dialog. transport lists the
controller’s transport buttons (TransportAction names), each sending a
cc or a note, with an optional channel (0 = MIDI channel 1).
Example
>>> MINILAB3_FILTER_MAP[74]
<FilterControl.CUTOFF: 'FILTER_CUTOFF'>
>>> MINILAB3.sources[FilterControl.CUTOFF]
'Knob 1'
>>> find_controller_port(["JD-Xi", "Minilab3 DIN THRU", "Minilab3 MIDI"])
'Minilab3 MIDI'
>>> find_controller_ports(["JD-Xi", "SINCO VMX8-Private", "SINCO VMX8-Master"])
['SINCO VMX8-Private']
>>> VMX8_FILTER_MAP[32]
<FilterControl.CUTOFF: 'FILTER_CUTOFF'>
Attributes
Classes
Controls a hardware controller can drive; values are parameter names. |
|
Transport commands a hardware controller's buttons can request. |
|
One transport button of a controller, as |
|
A supported hardware controller: how to find its ports, and its default map. |
Functions
|
Where the user's controller config is read from. |
|
The raw |
|
Profiles from raw entries; an entry that cannot be read is logged and skipped. |
|
The controllers in one JSON config file. |
|
The built-in controllers, overridden or extended by the user's config. |
|
Copy the built-in controller config to the user's, if there is none yet. |
|
|
|
The profile with |
|
The first supported controller that has a port among |
|
The input ports to open for the connected hardware controller. |
|
Pick the main input port of a supported hardware controller. |
Module Contents
- class jdxi_editor.midi.io.controller_map.FilterControl[source]
Bases:
enum.EnumControls a hardware controller can drive; values are parameter names.
Despite the name, this also covers the program effect levels (
EFFECT_CONTROLS), which the Effects editor holds.
- class jdxi_editor.midi.io.controller_map.TransportAction[source]
Bases:
enum.EnumTransport commands a hardware controller’s buttons can request.
- class jdxi_editor.midi.io.controller_map.TransportSpec[source]
One transport button of a controller, as
midi_controllers.jsonlists it.- Parameters:
action – TransportAction what the button does
kind – str
"cc"(press 127 / release 0) or"note"(note on / off)channel – int MIDI channel as mido numbers it (0 = MIDI channel 1)
number – int CC or note number 0-127
- action: TransportAction[source]
- classmethod from_dict(entry: dict) TransportSpec[source]
Build a button from one
transportentry, e.g.{"action": "PLAY", "cc": 52}.- Parameters:
entry – dict with
action, one ofcc/note, and optionallychannel(default 0)- Returns:
TransportSpec
- Raises:
KeyError – if the action is unknown or neither
ccnornoteis givenValueError – if a number is outside its MIDI range
- to_dict() dict[source]
This button as a
transportentry, the inverse offrom_dict().- Returns:
dict e.g.
{"action": "PLAY", "cc": 52, "channel": 0}
- class jdxi_editor.midi.io.controller_map.ControllerProfile[source]
A supported hardware controller: how to find its ports, and its default map.
- Parameters:
profile_id – str stable id, used as the settings key
label – str name shown in the MIDI Controller dialog
port_names – tuple[str, …] lower-case substrings of its port names
secondary_port_names – tuple[str, …] substrings of ports ranked after the main one
single_port – bool listen to the main port only; for devices that send every message on each of their ports
cc_map – dict CC number -> FilterControl defaults
sources – dict FilterControl -> physical control that sends it, e.g. “Knob 1”; controls whose source is unknown are left out
transport – tuple[TransportSpec, …] its transport buttons
- cc_map: dict[int, FilterControl][source]
- sources: dict[FilterControl, str][source]
- transport: tuple[TransportSpec, ...] = ()[source]
- classmethod from_dict(entry: dict) ControllerProfile[source]
Build a profile from one
controllersentry of the JSON config.- Parameters:
entry – dict with
id,label,port_namesandmappings, and optionallysecondary_port_names,single_portandtransport- Returns:
ControllerProfile
- Raises:
KeyError – if a required key or a control name is unknown
ValueError – if a CC number is not 0-127
TypeError – if a value has the wrong type
- jdxi_editor.midi.io.controller_map.user_config_path() pathlib.Path | None[source]
Where the user’s controller config is read from.
- Returns:
Optional[Path]
~/.jdxi_editor/midi_controllers.json, the path inJDXI_EDITOR_MIDI_CONTROLLERS, or None if that variable is empty
- jdxi_editor.midi.io.controller_map.read_entries(path: pathlib.Path) list[dict][source]
The raw
controllersentries of one JSON config file.- Parameters:
path – Path JSON file with a
controllerslist- Returns:
list[dict] in file order
- Raises:
OSError – if the file cannot be read
ValueError – if it is not valid JSON
- jdxi_editor.midi.io.controller_map._parse(entries: Iterable[dict], origin: object) list[ControllerProfile][source]
Profiles from raw entries; an entry that cannot be read is logged and skipped.
- Parameters:
entries – Iterable[dict] raw controller entries
origin – object where they came from, for the log
- Returns:
list[ControllerProfile]
- jdxi_editor.midi.io.controller_map.read_profiles(path: pathlib.Path) list[ControllerProfile][source]
The controllers in one JSON config file.
An entry that cannot be read is logged and skipped, so one typo does not lose the other controllers.
- Parameters:
path – Path JSON file with a
controllerslist- Returns:
list[ControllerProfile] in file order
- Raises:
OSError – if the file cannot be read
ValueError – if it is not valid JSON
- jdxi_editor.midi.io.controller_map.load_controller_profiles(user_path: pathlib.Path | None = None) tuple[ControllerProfile, ...][source]
The built-in controllers, overridden or extended by the user’s config.
A user entry with a built-in
idoverrides only the keys it has: an older copy withouttransportstill gets the built-in transport buttons.- Parameters:
user_path – Optional[Path] user config; defaults to
user_config_path()- Returns:
tuple[ControllerProfile, …] built-in order first, then new user ones
- jdxi_editor.midi.io.controller_map.install_user_config(path: pathlib.Path | None = None) pathlib.Path | None[source]
Copy the built-in controller config to the user’s, if there is none yet.
An existing file is never overwritten.
- Parameters:
path – Optional[Path] destination; defaults to
user_config_path()- Returns:
Optional[Path] the user config, or None if it is disabled or could not be written
- jdxi_editor.midi.io.controller_map.CONTROLLER_PROFILES: tuple[ControllerProfile, ...] = ()[source]
- jdxi_editor.midi.io.controller_map._profile(profile_id: str) ControllerProfile[source]
- jdxi_editor.midi.io.controller_map.MINILAB3_FILTER_MAP: dict[int, FilterControl][source]
- jdxi_editor.midi.io.controller_map.VMX8_FILTER_MAP: dict[int, FilterControl][source]
- jdxi_editor.midi.io.controller_map.profile_by_id(profile_id: str | None) ControllerProfile[source]
The profile with
profile_id, or the MiniLab 3 one if there is none.- Parameters:
profile_id – Optional[str]
- Returns:
ControllerProfile
- jdxi_editor.midi.io.controller_map.detect_profile(port_names: Iterable[str]) ControllerProfile | None[source]
The first supported controller that has a port among
port_names.- Parameters:
port_names – Iterable[str] MIDI port names
- Returns:
Optional[ControllerProfile] None if no supported controller is connected
- jdxi_editor.midi.io.controller_map.find_controller_ports(port_names: Iterable[str]) list[str][source]
The input ports to open for the connected hardware controller.
For a MiniLab 3 that is every port, since it sends its knobs on the port matching its current mode; for a VMX8, which repeats each message on both its ports, it is the main port alone (see
ControllerProfile).- Parameters:
port_names – Iterable[str] available MIDI input port names
- Returns:
list[str] the controller’s ports, main port first
- jdxi_editor.midi.io.controller_map.find_controller_port(port_names: Iterable[str]) str | None[source]
Pick the main input port of a supported hardware controller.
- Parameters:
port_names – Iterable[str] available MIDI input port names
- Returns:
Optional[str] the controller’s main port, or None if none is connected