jvconnected.interfaces.midi.mapper

class jvconnected.interfaces.midi.mapper.Map(name: str = '', group_name: str = '', full_name: str = '', index: int = -1)[source]

Bases: object

Stores information for mapping MIDI messages to ParameterGroupSpec definitions

name: str = ''

The name of the parameter within its ParameterGroupSpec

group_name: str = ''

The name of the ParameterGroupSpec

full_name: str = ''

Combination of group_name and name, separated by a “.”

"{group_name}.{name}"

map_type: ClassVar[str] = ''

A unique name to identify subclasses

index: int = -1

The map index

If not set (or -1), this will be assigned by MidiMapper when the instance is added to it

is_14_bit: ClassVar[bool] = False

True if the map uses 14 bit values

class jvconnected.interfaces.midi.mapper.ControllerMap(name: str = '', group_name: str = '', full_name: str = '', index: int = -1, controller: int = 0)[source]

Bases: Map

controller: int = 0

The Midi controller number for the mapping

map_type: ClassVar[str] = 'controller'

A unique name to identify subclasses

class jvconnected.interfaces.midi.mapper.Controller14BitMap(name: str = '', group_name: str = '', full_name: str = '', index: int = -1, controller: int = 0)[source]

Bases: ControllerMap

map_type: ClassVar[str] = 'controller/14'

A unique name to identify subclasses

is_14_bit: ClassVar[bool] = True

True if the map uses 14 bit 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.mapper.NoteMap(name: str = '', group_name: str = '', full_name: str = '', index: int = -1, note: int = 0)[source]

Bases: Map

note: int = 0

The Midi note number for the mapping

map_type: ClassVar[str] = 'note'

A unique name to identify subclasses

class jvconnected.interfaces.midi.mapper.AdjustControllerMap(name: str = '', group_name: str = '', full_name: str = '', index: int = -1, controller: int = 0)[source]

Bases: Map

controller: int = 0

The Midi controller number for the mapping

map_type: ClassVar[str] = 'adjust_controller'

A unique name to identify subclasses

jvconnected.interfaces.midi.mapper.DEFAULT_MAPPING: Sequence[Map] = (Controller14BitMap(name='iris_pos', group_name='exposure', full_name='exposure.iris_pos', index=-1, controller=0), AdjustControllerMap(name='master_black_pos', group_name='exposure', full_name='exposure.master_black_pos', index=-1, controller=1), AdjustControllerMap(name='gain_pos', group_name='exposure', full_name='exposure.gain_pos', index=-1, controller=2), ControllerMap(name='red_normalized', group_name='paint', full_name='paint.red_normalized', index=-1, controller=3), ControllerMap(name='blue_normalized', group_name='paint', full_name='paint.blue_normalized', index=-1, controller=4), AdjustControllerMap(name='detail_pos', group_name='paint', full_name='paint.detail_pos', index=-1, controller=5), NoteMap(name='preview', group_name='tally', full_name='tally.preview', index=-1, note=126), NoteMap(name='program', group_name='tally', full_name='tally.program', index=-1, note=127))

Default Midi mapping

The mapping uses the following layout for each camera index (where the channels will become the camera index)

Index

Parameter

Type

Controller/Note

0

Iris

Controller14BitMap

0 (MSB), 32 (LSB)

1

Master Black

AdjustControllerMap

1

2

Gain

AdjustControllerMap

2

3

Red Paint

ControllerMap

3

4

Blue Paint

ControllerMap

4

5

Detail

AdjustControllerMap

5

6

PGM Tally

NoteMap

126

7

PVW Tally

NoteMap

127

class jvconnected.interfaces.midi.mapper.MidiMapper(maps: Optional[Sequence[Union[Map, Dict]]] = None)[source]

Bases: object

Container for MIDI mapping definitions

Parameters

maps (Optional[Sequence[Union[Map, Dict]]]) – If given, a sequence of either Map instances or dicts to pass to the add_map() method. If not provided, the DEFAULT_MAPPING will be used.

The maps can be accessed by their full_name using dict methods.

>>> from jvconnected.interfaces.midi.mapper import MidiMapper, ControllerMap, NoteMap
>>> mapper = MidiMapper()
>>> gain = mapper['exposure.gain_pos']
>>> print(gain)
AdjustControllerMap(name='gain_pos', group_name='exposure', full_name='exposure.gain_pos', index=2, controller=2)
>>> mapper.get('exposure.gain_pos')
AdjustControllerMap(name='gain_pos', group_name='exposure', full_name='exposure.gain_pos', index=2, controller=2)
>>> 'exposure.gain_pos' in mapper
True

When iterating over the mapper, either directly or through the keys(), values() or items() methods, the results will be sorted by their group_name then their name attributes

>>> [key for key in mapper] 
['exposure.gain_pos',
 'exposure.iris_pos',
 'exposure.master_black_pos',
 'paint.blue_normalized',
 'paint.detail_pos',
 'paint.red_normalized',
 'tally.preview',
 'tally.program']
>>> [map_obj.full_name for map_obj in mapper.values()] 
['exposure.gain_pos',
 'exposure.iris_pos',
 'exposure.master_black_pos',
 'paint.blue_normalized',
 'paint.detail_pos',
 'paint.red_normalized',
 'tally.preview',
 'tally.program']

Maps can also be sorted by their indices using the iter_indexed() method

>>> [map_obj.full_name for map_obj in mapper.iter_indexed()] 
['exposure.iris_pos',
 'exposure.master_black_pos',
 'exposure.gain_pos',
 'paint.red_normalized',
 'paint.blue_normalized',
 'paint.detail_pos',
 'tally.preview',
 'tally.program']
>>> [map_obj.index for map_obj in mapper.values()]
[2, 0, 1, 4, 5, 3, 6, 7]

By default, MidiMapper will use a set of predefined maps when initialized. This can be overridden by passing a sequence of map definitions (or an empty one) when creating it

>>> mapper = MidiMapper([])
>>> len(mapper)
0

Then use add_map() to create maps using a dict

>>> pgm_tally = mapper.add_map(dict(map_type='note', full_name='tally.program', note=127))
>>> mapper['tally.program']
NoteMap(name='program', group_name='tally', full_name='tally.program', index=0, note=127)

Or existing Map instances

>>> pvw_tally = NoteMap(group_name='tally', name='preview', note=126)
>>> pvw_tally
NoteMap(name='preview', group_name='tally', full_name='tally.preview', index=-1, note=126)
>>> mapper.add_map(pvw_tally) 
>>> mapper['tally.preview']
NoteMap(name='preview', group_name='tally', full_name='tally.preview', index=1, note=126)
>>> mapper['tally.preview'] is pvw_tally
True
map: Dict[str, Map]

The Map definitions stored using their full_name as keys

map_grouped: Dict[str, Dict[str, Map]]

The Map definitions stored as nested dicts by group_name and name

map_by_index: Dict[int, Map]

The Map definitions stored using their index as keys

add_map(map_obj: Union[Map, Dict]) Map[source]

Add or create a Map definition

  • If the given argument is a dict, it must contain a value for “map_type” as described in the create_map() method, with the remaining items passed as keyword arguments.

  • If the given argument is a Map instance, it is added using add_map_obj().

create_map(map_type: str, **kwargs) Map[source]

Create a Map with the given arguments and add it

Parameters
  • map_type (str) – The map_type of the Map subclass to create

  • **kwargs – Keyword arguments used to create the instance

add_map_obj(map_obj: Map)[source]

Add an existing Map instance

get(full_name: str) Optional[Map][source]

Get the Map instance matching the given full_name

If not found, None is returned

keys() Iterator[str][source]

Iterate over all the full_name of all stored instances

This will be sorted first by group_name, then by name

values() Iterator[Map][source]

Iterate over all stored instances, sorted as described in keys()

items() Iterator[Tuple[str, Map]][source]

Iterate over pairs of keys() and values()

iter_indexed() Iterator[Map][source]

Iterate over all stored instances, sorted by their index