Extra

Units

These units offer some more advanced/specific functionality than what's provided in the core mididings module. Unless otherwise noted, they are defined in the mididings.extra module.

Note that some of these units are implemented in Python using Process(), and are thus not safe to use with the jack-rt backend.

Harmonize(tonic, scale, interval, non_harmonic='below')

A diatonic harmonizer.

Example: add a third above each note, based on the C# harmonic minor scale.
Harmonize('c#', 'minor_harmonic', ['unison', 'third'])

LimitPolyphony(max_polyphony, remove_oldest=True)

Limits the "MIDI polyphony" to max_polyphony. If remove_oldest is true, the oldest notes will be stopped when the maximum polyphony is exceeded. If remove_oldest is false, no new notes are accepted while max_polyphony notes are held.
Note that the actual polyphony of a connected synthesizer can still be higher than the limit set here, e.g. due to a long release phase.

MakeMonophonic()

Makes the MIDI signal "monophonic", i.e. only one note can be played at any given time. When one note is released while another is still held (but silent), the previous one will be retriggered.

SuppressPC()

Filters out program changes if the same program had previously been selected on the same port/channel.

PedalToNoteoff(ctrl=64, sostenuto=False)

Converts sustain pedal CCs to note-off events (delaying note-offs until the pedal is released). Acts either like a regular sustain pedal (the default) or like a sostenuto pedal.

LatchNotes(polyphonic=False, reset=None)

Makes notes latching, so they will keep playing when the key is released. If polyphonic is False, pressing a key will automatically turn off any previous notes. If polyphonic is True, each note can be stopped individually by pressing the corresponding key again. reset can be a note name/number that when pressed stops all currently playing notes.

BlackKeys()
WhiteKeys()

Filters notes by key color.

SendOSC(target, path, ...)

Defined in mididings.extra.osc. Requires pyliblo.
Sends an OSC message. Parameters are the same as for liblo.send(). Additionally, rather than a concrete value, each data argument can be a Python function instead. The function should then take a single MidiEvent parameter, and return the value to be sent.

SendDBUS(service, path, interface, method, ...)

Defined in mididings.extra.dbus. Requires dbus-python.
Sends a DBUS message. Rather than a concrete value, each data argument can be a Python function instead. The function should then take a single MidiEvent parameter, and return the value to be sent.

Example: change FFADO output volume using a MIDI controller.
CtrlFilter(42) >> SendDBUS(
    'org.ffado.Control',
    '/org/ffado/Control/DeviceManager/%s/Mixer/OUT0Gain' % DEVICEID,
    'org.ffado.Control.Element.Continuous',
    'setValue',
    lambda ev: ev.value * (2**17)
)

Hooks

MemorizeScene(memo_file)

Saves the currently selected scene number to a file when terminating mididings, and restores it at the next startup. memo_file is the path of the file to be used to store the scene number.

OSCInterface(port)

Defined in mididings.extra.osc. Requires pyliblo.
Allows controlling mididings via OSC. These messages are currently understood:

AutoRestart(modules=True, filenames=[])

Defined in mididings.extra.inotify. Requires pyinotify ≥ 0.8.
Automatically restarts mididings when the script changes. If modules is True, all imported local Python modules are monitored for changes as well. The filenames parameter allows specifying additional files to be monitored.
This restarts the entire mididings script, so MIDI processing is interrupted, and mididings does not take care of reestablishing any ALSA/JACK connections. If the new script contains errors that prevent it from running, mididings exits and needs to be restarted manually once the errors are fixed.