This guide is still under-development.

Handling MIDI Inputs

Overview

Each time a MIDI message gets received by FL Studio from a MIDI device with a Python script assigned to it, several script events get called as a part of a filtering process with several levels that allows, among others, to process MIDI messages of the same kind the same way without having to repeat code for each specific message.

Level 0: Reception and OnMidiIn()

When your device sends a MIDI message to FL Studio, it creates an event object that will represent the message for your script to use it.

class event

Represents and holds the data of a MIDI message in order for a MIDI script to be able to react and use it.

handled: bool = False

Controls wether the message will make it into the next MIDI filtering stage or not. (read/write access)

Each time the execution of a OnMidi*() script event ends, FL Studio will check the value of handled to decide whether the event has to get promoted to the next filtering level or the script doesn’t need any further processing of the event.

timestamp: time

Timestamp of the event. (read access)

status: int

Value of the STATUS byte of the MIDI message. (read/write access)

data1: int

Value of the DATA1 byte of the MIDI message. (read/write access)

If the message is a SysEx message, it will be set to 0.

data2: int

Value of the DATA2 byte of the MIDI message. (read/write access)

If the message is a SysEx message, it will be set to 0.

port: int

Value of the MIDI port the MIDI device is assigned to. (read access)

note: int

MIDI note number. (read/write access)

velocity: int

MIDI velocity. (read/write access)

pressure: int

MIDI pressure. (read/write access)

progNum: int

MIDI program number. (read access)

controlNum: int

MIDI control number. (read access)

controlVal: int

MIDI control value. (read access)

pitchBend: int

MIDI pitch bend value. (read access)

sysex: bytes

If the message is a SysEx message, the full byte chain will be available here. (read/write access)

If the message is regular MIDI message, it will be set to None.

isIncrement: bool

MIDI is increment state. (read/write access)

res: double

Unknown. (read/write access)

inEv: int

Unknown. (read/write access)

outEv: int

Unknown. (read/write access)

midiId: int

Unknown. (read/write access)

midiChan: int

MIDI channel used to transmit the message (with index on 0). (read/write access)

midiChanEx: int

Unknown. (read/write access)

pmeflags: int

Tags the event with a number to add more information about it. (read access)

See table

The API Tutorials