jvconnected.interfaces.midi.mapped_device
- class jvconnected.interfaces.midi.mapped_device.MappedDevice(*args, **kwargs)[source]
Bases:
DispatcherManages midi input and output for a single
Device- Parameters
- param_specs
A dict of
jvconnected.interfaces.paramspec.ParameterGroupSpecinstances- Type
Dict[str, ParameterGroupSpec]
- mapped_params
A dict of
MappedParameterinstances stored with theMappedParameter.nameas keys- Type
Dict[str, MappedParameter]
- async handle_incoming_messages(msgs: Iterable[Message])[source]
Dispatch incoming messages to all
MappedParameterinstancesThe
MappedParameter.handle_incoming_messages()method is called for each parameter instance inmapped_params
- class jvconnected.interfaces.midi.mapped_device.MappedParameter(*args, **kwargs)[source]
Bases:
DispatcherHandles midi input and output for a single parameter within a
jvconnected.device.ParameterGroup- mapped_device
The parent
MappedDeviceinstance- Type
- param_group
The
ParameterGroupSpecdefinition that describes the parameter- Type
- map_obj
The midi mapping definition
- Type
- param_spec
The
ParameterSpecinstance within theparam_group
- channel
The midi channel to use, typically gathered from
mapped_device- Type
- value_min: int = 0
Minimum value for the parameter as it exists in the
jvconnected.device.ParameterGroup
- value_max: int = 1
Maximum value for the parameter as it exists in the
jvconnected.device.ParameterGroup
- property midi_max: int
Maximum value for MIDI data
Will be 127 (
0x7f) in most cases. Ifis_14_bit, the value will be 16383 (0x3fff).
- property value_range: Number
Total range of values calculated as
\[\begin{split}V_{offset} &= \begin{cases} 1, & \quad \text{if }V_{min} = 0\\ 0, & \quad \text{if }V_{min}\ne 0 \end{cases}\\ V_{range} &= V_{max} - V_{min} + V_{offset}\end{split}\]
- message_valid(msg: BaseMessage) bool[source]
Check the incoming message parameters to determine whether it should be handled by this object
- scale_to_midi(value: Union[Number, bool]) int[source]
Scale the given value to the range allowed in midi messages
For boolean input, the result will be
\[\begin{split}result = \begin{cases} M_{max}, & \quad \text{if value is true}\\ 0, & \quad \text{otherwise} \end{cases}\end{split}\]For numeric input
\[result = \frac{value - V_{min}}{V_{range}} \cdot M_{max}\]where \(M_{max}\) =
midi_max, \(M_{range}\) =midi_range, \(V_{min}\) =value_minand \(V_{range}\) =value_range
- scale_from_midi(value: int) int[source]
Scale a value from the midi range to the
param_specrange\[result = \frac{value}{M_{range}} \cdot V_{range} + V_{min}\]where \(M_{range}\) =
midi_range, \(V_{min}\) =value_minand \(V_{range}\) =value_range
- get_message_type(value: Union[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[Number, bool]) Dict[source]
Get keyword arguments to build an outgoing
mido.Messagewith the given value
- build_message(value: Union[Number, bool]) 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:
MappedParameterMappedParametersubclass that uses midi control-change messages- value_min: int = 0
Minimum value for the parameter as it exists in the
jvconnected.device.ParameterGroup
- value_max: int = 1
Maximum value for the parameter as it exists in the
jvconnected.device.ParameterGroup
- message_valid(msg: BaseMessage) bool[source]
Check the incoming message parameters to determine whether it should be handled by this object
- get_message_type(value: Union[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']
- class jvconnected.interfaces.midi.mapped_device.MappedController14Bit(*args, **kwargs)[source]
Bases:
MappedControllerA
MappedControllerusing 14-bit Midi values- property controller_msb: int
The controller index containing the most-significant 7 bits
This will always be equal to the
controllervalue
- property controller_lsb: int
The controller index containing the least-significant 7 bits
Per the MIDI 1.0 specification, this will be
controller_msb+ 32
- class jvconnected.interfaces.midi.mapped_device.MappedNoteParam(*args, **kwargs)[source]
Bases:
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.- message_valid(msg: BaseMessage) bool[source]
Check the incoming message parameters to determine whether it should be handled by this object
- get_message_type(value: Union[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']
- class jvconnected.interfaces.midi.mapped_device.AdjustController(*args, **kwargs)[source]
Bases:
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
gain_posattribute ofjvconnected.device.ExposureParamswhere the value can only be changed using theincrease_gain()anddecrease_gain()methods.- message_valid(msg: BaseMessage) bool[source]
Check the incoming message parameters to determine whether it should be handled by this object
- get_message_type(value: Union[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']