jvconnected.interfaces.midi¶
jvconnected.interfaces.midi.midi_io¶
-
class
jvconnected.interfaces.midi.midi_io.MidiIO(*args, **kwargs)[source]¶ Bases:
jvconnected.interfaces.base.InterfaceMidi interface handler
- Properties
-
-
inports: Dict[str, InputPort] → Property(Dict[str, InputPort])¶ Mapping of
InputPortinstances stored with the names as keys
-
outports: Dict[str, OutputPort] → Property(Dict[str, OutputPort])¶ Mapping of
OutputPortinstances stored with the names as keys
-
mapped_devices: Dict[str, MappedDevice] → Property(Dict[str, MappedDevice])¶ Mapping of
MappedDeviceinstances stored with the device id as keys
-
config: None → Property(None)¶ Instance of
jvconnected.config.Config. This is gathered from theengineafterset_engine()has been called.
-
-
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: mido.messages.messages.BaseMessage)[source]¶ Send a message to all output ports in
outports- Parameters
msg – The
Messageto send
-
map_device(midi_channel: int, device: jvconnected.device.Device)[source]¶ Connect a
jvconnected.device.Deviceto amapped_device.MappedDevice
jvconnected.interfaces.midi.aioport¶
-
class
jvconnected.interfaces.midi.aioport.BasePort(*args, **kwargs)[source]¶ Bases:
pydispatch.dispatch.DispatcherAsync wrapper for
mido.ports- Parameters
name (str) – The port name
- Properties
- Attributes
stopped (asyncio.Event)
-
class
jvconnected.interfaces.midi.aioport.InputPort(*args, **kwargs)[source]¶ Bases:
jvconnected.interfaces.midi.aioport.BasePortAsync wrapper around
mido.ports.BaseInput- Attributes
queue (asyncio.Queue) – Message queue for the port
-
async
receive(timeout: Optional[numbers.Number] = None) → Optional[mido.messages.messages.Message][source]¶ Wait for an incoming message
- Parameters
timeout (float, optional) – Time to wait for a message. if
None, wait until an item is available- Returns
An instance of
mido.Message. If timeout was provided and no message was retrieved,Nonewill be returned.
-
async
queue_get(timeout: Optional[numbers.Number] = None) → Any[source]¶ Convenience method for
get()on thequeue- Parameters
timeout (float, optional) – Time to wait for an item on the queue. if
None, wait until an item is available
-
task_done()[source]¶ Convenience method for
queuetask_done()
-
class
jvconnected.interfaces.midi.aioport.OutputPort(*args, **kwargs)[source]¶ Bases:
jvconnected.interfaces.midi.aioport.BasePortAsync wrapper around
mido.ports.BaseOutput- Attributes
queue (queue.Queue) – Message queue for the port. Since the output port operates in a separate thread, this is a thread-based queue (not async)
-
async
open() → bool[source]¶ Open the midi port
- Returns
Trueif the port was successfully opened- Return type
-
async
send(msg: mido.messages.messages.Message)[source]¶ Send a message
The message will be placed on the
queueand sent from a separate thread- Parameters
msg – The
mido.Messageto send
jvconnected.interfaces.midi.mapper¶
-
class
jvconnected.interfaces.midi.mapper.Map(name: str = '', group_name: str = '', full_name: str = '', index: int = - 1)[source]¶ Bases:
object
-
class
jvconnected.interfaces.midi.mapper.ControllerMap(name: str = '', group_name: str = '', full_name: str = '', index: int = - 1, controller: int = 0)[source]¶
-
class
jvconnected.interfaces.midi.mapper.NoteMap(name: str = '', group_name: str = '', full_name: str = '', index: int = - 1, note: int = 0)[source]¶
-
class
jvconnected.interfaces.midi.mapper.AdjustControllerMap(name: str = '', group_name: str = '', full_name: str = '', index: int = - 1, controller: int = 0)[source]¶
-
class
jvconnected.interfaces.midi.mapper.MidiMapper(maps: Optional[Sequence[Union[jvconnected.interfaces.midi.mapper.Map, Dict]]] = None)[source]¶ Bases:
objectContainer for MIDI mapping definitions
jvconnected.interfaces.midi.mapped_device¶
-
class
jvconnected.interfaces.midi.mapped_device.MappedDevice(*args, **kwargs)[source]¶ Bases:
pydispatch.dispatch.DispatcherManages midi input and output for a single
Device- Parameters
- Attributes
param_specs (Dict[str, ParameterGroupSpec]) – A dict of
jvconnected.interfaces.paramspec.ParameterGroupSpecinstancesmapped_params (Dict[str, MappedParameter]) – A dict of
MappedParameterinstances stored with theMappedParameter.nameas keys
-
async
handle_incoming_message(msg: mido.messages.messages.BaseMessage)[source]¶ Dispatch an incoming message to all
MappedParameterinstancesThe
MappedParameter.handle_incoming_message()method is called for each parameter instance inmapped_params
-
class
jvconnected.interfaces.midi.mapped_device.MappedParameter(*args, **kwargs)[source]¶ Bases:
pydispatch.dispatch.DispatcherHandles midi input and output for a single parameter within a
jvconnected.device.ParameterGroup- Attributes
mapped_device (MappedDevice) – The parent
MappedDeviceinstanceparam_group (ParameterGroupSpec) – The
ParameterGroupSpecdefinition that describes the parameterparam_name (str) – The parameter name within the param_group
name (str) – Unique name of the parameter as defined by
jvconnected.interfaces.paramspec.ParameterSpec.full_nameparam_spec – The
ParameterSpecinstance within theparam_groupchannel (int) – The midi channel to use, typically gathered from
mapped_devicevalue_min (int) – Minimum value for the parameter as it exists in the
jvconnected.device.ParameterGroupvalue_max (int) – Maximum value for the parameter as it exists in the
jvconnected.device.ParameterGroup
-
property
value_range→ Number [read-only]¶ Total range of values calculated as
value_max - value_min
-
async
handle_incoming_message(msg: mido.messages.messages.BaseMessage)[source]¶ Process an incoming message
If the message is valid for this object, the appropriate setter methods will by called on the
param_spec
-
message_valid(msg: mido.messages.messages.BaseMessage) → bool[source]¶ Check the incoming message parameters to determine whether it should be handled by this object
-
scale_to_midi(value: Union[numbers.Number, bool]) → int[source]¶ Scale the given value to a range of 0 to 127
If the given value is
bool, this will return127forTrueand0forFalse.Otherwise the result will be \(((value - vmin) / vrange * 127\)
-
scale_from_midi(value: int) → int[source]¶ Scale a value from \([0,1,..,127]\) to the range expected by the parameter. This results in \((value / 127) * vrange + vmin\)
-
get_message_type(value: Union[numbers.Number, bool]) → str[source]¶ Get the
mido.Messagetype argument for an outgoingmido.Messagewith the given value.Typically one of
['control_change', 'note_on', 'note_off', 'pitchwheel']
-
get_message_kwargs(value: Union[numbers.Number, bool]) → Dict[source]¶ Get keyword arguments to build an outgoing
mido.Messagewith the given value
-
build_message(value: Union[numbers.Number, bool]) → mido.messages.messages.Message[source]¶ Create a
mido.Messageto send for the given parameter valueUses
get_message_type()andget_message_kwargs()for message arguments
-
class
jvconnected.interfaces.midi.mapped_device.MappedController(*args, **kwargs)[source]¶ Bases:
jvconnected.interfaces.midi.mapped_device.MappedParameterMappedParametersubclass that uses midi control-change messages- Attributes
controller (int) – The controller number
-
message_valid(msg: mido.messages.messages.BaseMessage) → bool[source]¶ Check the incoming message parameters to determine whether it should be handled by this object
-
get_message_type(value: Union[numbers.Number, bool]) → str[source]¶ Get the
mido.Messagetype argument for an outgoingmido.Messagewith the given value.Typically one of
['control_change', 'note_on', 'note_off', 'pitchwheel']
-
get_message_kwargs(value: Union[numbers.Number, bool]) → Dict[source]¶ Get keyword arguments to build an outgoing
mido.Messagewith the given value
-
class
jvconnected.interfaces.midi.mapped_device.MappedNoteParam(*args, **kwargs)[source]¶ Bases:
jvconnected.interfaces.midi.mapped_device.MappedParameterMappedParametersubclass that uses midi note messagesIntended for boolean values. Sends a
note_onmessage with velocity of127for True and0for False.Incoming
note_onmessages with velocity < 0 are treated asTrue, velocity == 0 andnote_offmessages are consideredFalse.- Attributes
note (int) – The midi note number
-
message_valid(msg: mido.messages.messages.BaseMessage) → bool[source]¶ Check the incoming message parameters to determine whether it should be handled by this object
-
get_message_type(value: Union[numbers.Number, bool]) → str[source]¶ Get the
mido.Messagetype argument for an outgoingmido.Messagewith the given value.Typically one of
['control_change', 'note_on', 'note_off', 'pitchwheel']
-
get_message_kwargs(value: Union[numbers.Number, bool]) → Dict[source]¶ Get keyword arguments to build an outgoing
mido.Messagewith the given value
-
class
jvconnected.interfaces.midi.mapped_device.AdjustController(*args, **kwargs)[source]¶ Bases:
jvconnected.interfaces.midi.mapped_device.MappedControllerA
MappedControllerthat sends outgoing messages likeMappedController, but incoming messages will either increment (>=64) or decrement (<64) the value.The use case for this would be for parameters that lack a direct setter method, but instead rely on adjustment methods.
An example would be the
gainattribute ofjvconnected.device.ExposureParamswhere the value can only be changed using theincrease_gain()anddecrease_gain()methods.-
message_valid(msg: mido.messages.messages.BaseMessage) → bool[source]¶ Check the incoming message parameters to determine whether it should be handled by this object
-
get_message_type(value: Union[numbers.Number, bool]) → str[source]¶ Get the
mido.Messagetype argument for an outgoingmido.Messagewith the given value.Typically one of
['control_change', 'note_on', 'note_off', 'pitchwheel']
-
get_message_kwargs(value: Union[numbers.Number, bool]) → Dict[source]¶ Get keyword arguments to build an outgoing
mido.Messagewith the given value
-
jvconnected.interfaces.midi.bcf¶
jvconnected.interfaces.midi.bcf_sysex¶
-
exception
jvconnected.interfaces.midi.bcf_sysex.ResponseError(error_code: int)[source]¶ Bases:
Exception
-
class
jvconnected.interfaces.midi.bcf_sysex.BCLSyxBase(manufacturer: Sequence[ByteString] = (0, 32, 50), device_id: Sequence[ByteString] = (127), model: Sequence[ByteString] = (20), command: Sequence[ByteString] = (32), message_index: int = 0)[source]¶ Bases:
object-
property
index_msb→ typing.Sequence[typing.ByteString] [read-only]¶ Bits 7-13 of
message_index
-
property
index_lsb→ typing.Sequence[typing.ByteString] [read-only]¶ Bits 0-6 of
message_index
-
property
-
class
jvconnected.interfaces.midi.bcf_sysex.BCLSysex(manufacturer: Sequence[ByteString] = (0, 32, 50), device_id: Sequence[ByteString] = (127), model: Sequence[ByteString] = (20), command: Sequence[ByteString] = (32), message_index: int = 0, bcl_text: str = '')[source]¶
-
class
jvconnected.interfaces.midi.bcf_sysex.BCLReply(manufacturer: Sequence[ByteString] = (0, 32, 50), device_id: Sequence[ByteString] = (127), model: Sequence[ByteString] = (20), command: Sequence[ByteString] = (32), message_index: int = 0, error_code: Sequence[ByteString] = (0))[source]¶
-
class
jvconnected.interfaces.midi.bcf_sysex.BCLBlock(revision: str = 'F1', text_lines: Sequence[str] = <factory>)[source]¶ Bases:
object
-
class
jvconnected.interfaces.midi.bcf_sysex.ControlBase(message_type: str = 'control_change', channel: int = 0, number: int = 0, mode: str = '', value_min: int = 0, value_max: int = 127, value_default: Union[int, NoneType] = None, show_value: bool = True)[source]¶ Bases:
object
-
class
jvconnected.interfaces.midi.bcf_sysex.EncoderConf(message_type: str = 'control_change', channel: int = 0, number: int = 0, mode: str = '1dot', value_min: int = 0, value_max: int = 127, value_default: Union[int, NoneType] = None, show_value: bool = True, index: int = 1, encoder_mode: str = 'absolute', resolution: Sequence[int] = (96, 96, 96, 96))[source]¶ Bases:
jvconnected.interfaces.midi.bcf_sysex.ControlBase-
mode: str = '1dot'¶ LED Display mode
Choices
[ 'off', '1dot', '1dot/off', '12dot', '12dot/off', 'bar', 'bar/off', 'spread', 'pan', 'qual', 'cut', 'damp', ]
-
-
class
jvconnected.interfaces.midi.bcf_sysex.FaderConf(message_type: str = 'control_change', channel: int = 0, number: int = 0, mode: str = 'absolute', value_min: int = 0, value_max: int = 127, value_default: Union[int, NoneType] = None, show_value: bool = True, index: int = 1, motor: bool = True, override: str = 'move', keyoverride: str = 'off')[source]¶
-
class
jvconnected.interfaces.midi.bcf_sysex.ButtonConf(message_type: str = 'control_change', channel: int = 0, number: int = 0, mode: str = '', value_min: int = 0, value_max: int = 127, value_default: Union[int, NoneType] = None, show_value: bool = True, index: int = 1, button_mode: str = 'toggleon', increment: int = 1)[source]¶ Bases:
jvconnected.interfaces.midi.bcf_sysex.ControlBaseChoices
['toggleoff', 'toggleon', 'increment']
-
increment: int = 1¶ Amount to increment/decrement if
button_modeis'increment'