jvconnected.interfaces.midi.mapped_device
- class jvconnected.interfaces.midi.mapped_device.MappedDevice(*args, **kwargs)[source]
Bases:
Dispatcher
Manages midi input and output for a single
Device
- Parameters
- param_specs
A dict of
jvconnected.interfaces.paramspec.ParameterGroupSpec
instances- Type
Dict[str, ParameterGroupSpec]
- mapped_params
A dict of
MappedParameter
instances stored with theMappedParameter.name
as keys- Type
Dict[str, MappedParameter]
- async handle_incoming_messages(msgs: Iterable[Message])[source]
Dispatch incoming messages to all
MappedParameter
instancesThe
MappedParameter.handle_incoming_messages()
method is called for each parameter instance inmapped_params
- class jvconnected.interfaces.midi.mapped_device.MappedParameter(*args, **kwargs)[source]
Bases:
Dispatcher
Handles midi input and output for a single parameter within a
jvconnected.device.ParameterGroup
- mapped_device
The parent
MappedDevice
instance- Type
- param_group
The
ParameterGroupSpec
definition that describes the parameter- Type
- map_obj
The midi mapping definition
- Type
- param_spec
The
ParameterSpec
instance 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_min
and \(V_{range}\) =value_range
- scale_from_midi(value: int) int [source]
Scale a value from the midi range to the
param_spec
range\[result = \frac{value}{M_{range}} \cdot V_{range} + V_{min}\]where \(M_{range}\) =
midi_range
, \(V_{min}\) =value_min
and \(V_{range}\) =value_range
- get_message_type(value: Union[Number, bool]) str [source]
Get the
mido.Message
type argument for an outgoingmido.Message
with 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.Message
with the given value
- build_message(value: Union[Number, bool]) Message [source]
Create a
mido.Message
to 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:
MappedParameter
MappedParameter
subclass 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.Message
type argument for an outgoingmido.Message
with the given value.Typically one of
['control_change', 'note_on', 'note_off', 'pitchwheel']
- class jvconnected.interfaces.midi.mapped_device.MappedController14Bit(*args, **kwargs)[source]
Bases:
MappedController
A
MappedController
using 14-bit Midi values- property controller_msb: int
The controller index containing the most-significant 7 bits
This will always be equal to the
controller
value
- 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:
MappedParameter
MappedParameter
subclass that uses midi note messagesIntended for boolean values. Sends a
note_on
message with velocity of127
for True and0
for False.Incoming
note_on
messages with velocity < 0 are treated asTrue
, velocity == 0 andnote_off
messages 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.Message
type argument for an outgoingmido.Message
with the given value.Typically one of
['control_change', 'note_on', 'note_off', 'pitchwheel']
- class jvconnected.interfaces.midi.mapped_device.AdjustController(*args, **kwargs)[source]
Bases:
MappedController
A
MappedController
that 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_pos
attribute ofjvconnected.device.ExposureParams
where 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.Message
type argument for an outgoingmido.Message
with the given value.Typically one of
['control_change', 'note_on', 'note_off', 'pitchwheel']