jvconnected.interfaces.midi.midi_io
- class jvconnected.interfaces.midi.midi_io.MidiIO(*args, **kwargs)[source]
Bases:
InterfaceMidi interface handler
- ListProperty inport_names: tp.List[str]
list of input port names to use (as
str)inport_namesis apydispatch.ListPropertyobject.
- ListProperty outport_names: tp.List[str]
list of output port names to use (as
str)outport_namesis apydispatch.ListPropertyobject.
- DictProperty inports: tp.Dict[str, InputPort]
Mapping of
InputPortinstances stored with theirnameas keysinportsis apydispatch.DictPropertyobject.
- DictProperty outports: tp.Dict[str, OutputPort]
Mapping of
OutputPortinstances stored with theirnameas keysoutportsis apydispatch.DictPropertyobject.
- DictProperty mapped_devices: tp.Dict[str, 'jvconnected.interfaces.midi.mapped_device.MappedDevice']
Mapping of
MappedDeviceinstances stored with the device id as keysmapped_devicesis apydispatch.DictPropertyobject.
- DictProperty device_channel_map: Dict[str, int]
Mapping of
MappedDeviceinstances stored with the device id as keysdevice_channel_mapis apydispatch.DictPropertyobject.
- DictProperty channel_device_map: Dict[int, str]
Mapping of Midi channel assignments using the Midi channel as keys and
device_idas valueschannel_device_mapis apydispatch.DictPropertyobject.
- Event port_state(io_type: IOType, name: str, state: bool)[source]
Fired when a port is added or removed using one of
add_input(),add_output(),remove_input(),remove_output().port_stateis apydispatch.Eventobject.
- interface_name: ClassVar[str] = 'midi'
Unique name for the interface. Must be defined by subclasses
- async set_engine(engine: jvconnected.engine.Engine)[source]
Attach the interface to a running instance of
jvconnected.engine.EngineThis will be called automatically by the engine if the class is in the
jvconnected.interfaces.registry.If the engine is running, the interface will start (using the
open()method). Otherwise it will automatically start when the engine does.
- async add_input(name: str)[source]
Add an input port
The port name will be added to
inport_namesand stored in theconfig.If MidiIO is
running, an instance ofInputPortwill be created and added toinports.- Parameters
name (str) – The port name (as it appears in
get_available_inputs())
- async add_output(name: str)[source]
Add an output port
The port name will be added to
outport_namesand stored in theconfig.If MidiIO is
running, an instance ofOutputPortwill be created and added tooutports.- Parameters
name (str) – The port name (as it appears in
get_available_outputs())
- async remove_input(name: str)[source]
Remove an input port from
inportsandinport_namesIf the port exists in
inports, it will be closed and removed.- Parameters
name (str) – The port name
- async remove_output(name: str)[source]
Remove an output port from
outportsandoutport_namesIf the port exists in
outports, it will be closed and removed.- Parameters
name (str) – The port name
- async send_message(msg: BaseMessage)[source]
Send a message to all output ports in
outports- Parameters
msg (BaseMessage) – The
Messageto send
- async send_messages(msgs: Sequence[Message])[source]
Send a message to all output ports in
outports
- async map_device(device: jvconnected.device.Device, send_all_parameters: bool = True, midi_channel: Optional[int] = None) MappedDevice[source]
Connect a
jvconnected.device.Deviceto amapped_device.MappedDeviceThe Midi channel used for the device is retreived from the
configif available. If no channel assignment was found, the next available channel is used and saved in theconfig.- Parameters
device (jvconnected.device.Device) – The
Deviceto mapsend_all_parameters (bool, optional) – If True, send all current parameter values once the device is mapped. Default is True
midi_channel (int, optional) – The Midi channel to use for the device (from 0 to 15). If not provided, the channel is assigned automatically using
get_midi_channel_for_device()
- Raises
ValidationError – If midi_channel was provided and already in use
ValueError – If there are no Midi channels available
- async unmap_device(device_id: str, unassign_channel: bool = False)[source]
Unmap a device
- Parameters
unassign_channel (bool, optional) – If True, removes the Midi channel assignment for the device and updates the saved config. If False (the default), only removes the
MappedDevicefrommapped_devices.
- async remap_device_channel(device_id: str, midi_channel: int)[source]
Reassign the Midi channel for a device
If the device is online, the existing
MappedDeviceattached to it is reassigned as well.- Parameters
- Raises
ValidationError – If the given midi_channel is already in use