mididings - Documentation

Table of Contents

Basics

mididings configuration files are just Python scripts, although mididings uses some of Python's features in ways for which they weren't intended ;)
Basically, the MIDI processing setup is defined in Python, while the actual event processing is done entirely in C++. It is however possible to explicitly call back into Python, if necessary.

Functions

config(**kwargs)

Changes global mididings settings. This should be called only once, before constructing any processing units.
Possible keyword arguments are:

run(patch)

Starts the actual MIDI processing. This is usually the last function called by a mididings script.

run_patches(patches, control=None, pre=None, post=None)

Starts the actual MIDI processing, using multiple patches.

switch_patch(number)

Switches to another patch. This function is similar to the PatchSwitch() object, but can be called from Python.

Data Types

MidiEvent

Used in conjunction with the Call(), CallAsync() and CallThread() units.

A MidiEvent object has the following attributes:

There are also aliases for these attributes, some of which are only defined for certain types of events:

Constants

Event Types

Every event has one of these types: NOTEON, NOTEOFF, CTRL, PITCHBEND, PROGRAM.
When building filters, event types can be combined using the bitwise or operator.
Also defined are NOTE (= NOTEON | NOTEOFF), NONE, ANY.

Event Attributes

These constants are used to refer to an event's data attributes: EVENT_PORT, EVENT_CHANNEL, EVENT_DATA1, EVENT_DATA2, EVENT_NOTE, EVENT_VELOCITY, EVENT_PARAM, EVENT_VALUE, EVENT_PROGRAM.

Making Connections

A >> B

Connects two units in series. Incoming MIDI events will be processed by unit A first, then by unit B. If the event is filtered out by unit A, it is not processed any further, and unit B will not be called.

[ A, B, ... ]

Connects two or more units in parallel. All units will be called with identical copies of incoming MIDI events. The output will be the sum of all the units' outputs.

{ T1: A, T2: B, ... }

Splits by event type. Equivalent to [ Filter(T1) >> A, Filter(T2) >> B, ... ].

Units

These are the basic building blocks from which you can build your patches.

Filters

Filter(type, ...)

Filters by one or more event types.

PortFilter(port, ...)
ChannelFilter(channel, ...)

Filters by event port or channel.

KeyFilter(key)
KeyFilter(lower, upper)
KeyFilter(range)

Filters by key or key-range. Keys can be MIDI note numbers or note names (e.g. 'g#3'). Ranges can be 2-tuples of note numbers, or note names (e.g. 'g#3:c6').

VelocityFilter(min, max)

Filters by note velocity.

CtrlFilter(ctrl, ...)

Filters by CC number.

CtrlValueFilter(value)
CtrlValueFilter(min, max)

Filters by CC value.

ProgFilter(program, ...)

Filters by PC number.

Splits

PortSplit({port: units, ...})
ChannelSplit({channel: units, ...})

Splits by port or channel.

KeySplit(key, units_lower, units_upper)
KeySplit({(lower, upper): units, ...})
KeySplit({range: units, ...})

Splits by key. Non-note events are sent to all units.

VelocitySplit(threshold, units_lower, units_upper)
VelocitySplit({(min, max): units, ...})

Splits by velocity. Non-note events are sent to all units.

Modifiers

Port(port)
Channel(channel)

Changes port or channel.

Transpose(offset)

Transposes all note events.

Velocity(offset)
VelocityFixed(value)

Changes velocity, either by adding an offset, or by setting it to a fixed value.

VelocityCurve(gamma)

Applies a "gamma"-curve to all velocity values.

VelocityGradient(note_lower, note_upper, value_lower, value_upper)
VelocityGradientFixed(note_lower, note_upper, value_lower, value_upper)

Changes velocity, using a gradient from lower to upper.

CtrlMap(ctrl_in, ctrl_out)

Maps one controller to another.

CtrlRange(ctrl, out_min, out_max, in_min=0, in_max=127)

Maps controller range in to out.

Generators

CtrlChange(ctrl, value)
CtrlChange(port, channel, ctrl, value)
ProgChange(program)
ProgChange(port, channel, program)

Changes the type of the event. If port and channel are omitted, the values of the input event are used.
To "reuse" values from the incoming event, one of the EVENT_* constants can be used in place of any parameter.

Function Calls

Call(function)

Calls a Python function. This will stall any other MIDI processing until the function returns.

CallAsync(function)

Schedules a Python function for execution, and continues MIDI processing immediately.

CallThread(function)

Like CallAsync(), but runs the function in its own thread.

Miscellaneous

Pass()

Does nothing.

Discard()

Discards the current event.

PatchSwitch()
PatchSwitch(number)

Switches to another patch. number should be a patch number, or one of the EVENT_* constants. Without parameters, the program number of the incoming event (should be a program change) will be used.

Print(name=None, types=ANY, portnames=Print.PORTNAMES_NONE)

Prints event data.

PrintString(string)

Prints a fixed string.

Sanitize()

Makes sure the event is a valid MIDI message. Events with invalid port, channel, controller, program or note number are discarded, note velocity and controller values are confined to the range 0-127.

Examples