Components All New MacOS Windows Linux iOS
Examples Mac & Win Server Client Guides Statistic FMM Blog Deprecated Old


Sets filters on an open input stream to drop selected input types.

Component Version macOS Windows Linux Server iOS SDK
PortMidi 4.2 ✅ Yes ✅ Yes ❌ No ❌ No ❌ No
MBS( "PortMidi.SetFilter"; StreamRef; Filter )   More


Parameter Description Example
StreamRef The reference to the midi stream. You create those with PortMidi.OpenInput or PortMidi.OpenOutput and finally close them with PortMidi.Close. $stream
Filter The new filter value. 0


Returns OK or error.


Sets filters on an open input stream to drop selected input types.
By default, only active sensing messages are filtered.

Filtering is useful when midi routing or midi thru functionality is being provided by the user application.
For example, you may want to exclude timing messages (clock, MTC, start/stop/continue), while allowing note-related messages to pass. Or you may be using a sequencer or drum-machine for MIDI clock information but want to exclude any notes it may play.

Filter values (can be ORed):
Filter active sensing messages (0xFE)PM_FILT_ACTIVE16384
Filter system exclusive messages (0xF0)PM_FILT_SYSEX1
Filter clock messages (CLOCK 0xF8, START 0xFA, STOP 0xFC, and CONTINUE 0xFB)PM_FILT_CLOCK7424
Filter play messages (start 0xFA, stop 0xFC, continue 0xFB)PM_FILT_PLAY1024
Filter tick messages (0xF9)PM_FILT_TICK512
Filter undefined FD messagesPM_FILT_FD8192
Filter undefined real-time messagesPM_FILT_UNDEFINED8192
Filter reset messages (0xFF)PM_FILT_RESET32768
Filter all real-time messagesPM_FILT_REALTIME65281
Filter note-on and note-off (0x90-0x9F and 0x80-0x8FPM_FILT_NOTE50331648
Filter channel aftertouch (most midi controllers use this) (0xD0-0xDF)PM_FILT_CHANNEL_AFTERTOUCH536870912
Per-note aftertouch (0xA0-0xAF)PM_FILT_POLY_AFTERTOUCH67108864
Filter both channel and poly aftertouchPM_FILT_AFTERTOUCH603979776
Program changes (0xC0-0xCF)PM_FILT_PROGRAM268435456
Control Changes (CC's) (0xB0-0xBF)PM_FILT_CONTROL134217728
Pitch Bender (0xE0-0xEFPM_FILT_PITCHBEND1073741824
MIDI Time Code (0xF1)PM_FILT_MTC2
Song Position (0xF2)PM_FILT_SONG_POSITION4
Song Select (0xF3)PM_FILT_SONG_SELECT8
Tuning request (0xF6)PM_FILT_TUNE64
All System Common messages (mtc, song position, song select, tune request)PM_FILT_SYSTEMCOMMON78


To prohibit, say, active sensing and sysex messages, call:

MBS( "PortMidi.SetFilter"; $StreamRef; 16384 + 1 )

See also

This function checks for a license.

Created 18th August 2014, last changed 18th August 2014

PortMidi.SetDataAvailableHandler - PortMidi.TimeStamp