Module mididings.event

This module defines classes and functions for dealing with MIDI events in Python code, e.g. when using Process() or Call().

class MidiEvent(type, port=0, channel=0, data1=0, data2=0, sysex=None)

A MIDI event, as seen by Python code.

Each event has these attributes:

type

The event type, one of the Event Types constants.

port

The port number.

channel

The channel number.

data1

The first data byte, meaning depends on event type.

data2

The second data byte, meaning depends on event type.

The following attributes are only valid for certain event types, and accessing them will raise an error otherwise:

note

The note number, stored in data1.

velocity

The velocity value, stored in data2.

ctrl

The controller number, stored in data1.

value

The controller value, stored in data2.

program

The program number, stored in data2. Unlike data2, this attribute observes the data_offset setting.

sysex

SysEx data.

Several utility functions are defined to simplify the creation of event objects. Each of these functions returns a newly created object of type MidiEvent:

NoteOnEvent(port, channel, note, velocity)

Create a new note-on event object.

NoteOffEvent(port, channel, note, velocity=0)

Create a new note-off event object.

CtrlEvent(port, channel, ctrl, value)

Create a new control change event object.

PitchbendEvent(port, channel, value)

Create a new pitch bend event object.

AftertouchEvent(port, channel, value)

Create a new aftertouch event object.

PolyAftertouchEvent(port, channel, note, value)

Create a new polyphonic aftertouch event object.

ProgramEvent(port, channel, program)

Create a new program change event object.

SysExEvent(port, sysex)

Create a new sysex event object.