PortMidi  2.2.x
Events and Filters Handling

Data Structures

struct  PmEvent
 All midi data comes in the form of PmEvent structures. More...
 

Macros

#define PM_FILT_ACTIVE   (1 << 0x0E)
 filter active sensing messages (0xFE):
 
#define PM_FILT_SYSEX   (1 << 0x00)
 filter system exclusive messages (0xF0):
 
#define PM_FILT_CLOCK   (1 << 0x08)
 filter MIDI clock message (0xF8)
 
#define PM_FILT_PLAY   ((1 << 0x0A) | (1 << 0x0C) | (1 << 0x0B))
 filter play messages (start 0xFA, stop 0xFC, continue 0xFB)
 
#define PM_FILT_TICK   (1 << 0x09)
 filter tick messages (0xF9)
 
#define PM_FILT_FD   (1 << 0x0D)
 filter undefined FD messages
 
#define PM_FILT_UNDEFINED   PM_FILT_FD
 filter undefined real-time messages
 
#define PM_FILT_RESET   (1 << 0x0F)
 filter reset messages (0xFF)
 
#define PM_FILT_REALTIME
 filter all real-time messages More...
 
#define PM_FILT_NOTE   ((1 << 0x19) | (1 << 0x18))
 filter note-on and note-off (0x90-0x9F and 0x80-0x8F
 
#define PM_FILT_CHANNEL_AFTERTOUCH   (1 << 0x1D)
 filter channel aftertouch (most midi controllers use this) (0xD0-0xDF)
 
#define PM_FILT_POLY_AFTERTOUCH   (1 << 0x1A)
 per-note aftertouch (0xA0-0xAF)
 
#define PM_FILT_AFTERTOUCH   (PM_FILT_CHANNEL_AFTERTOUCH | PM_FILT_POLY_AFTERTOUCH)
 filter both channel and poly aftertouch
 
#define PM_FILT_PROGRAM   (1 << 0x1C)
 Program changes (0xC0-0xCF)
 
#define PM_FILT_CONTROL   (1 << 0x1B)
 Control Changes (CC's) (0xB0-0xBF)
 
#define PM_FILT_PITCHBEND   (1 << 0x1E)
 Pitch Bender (0xE0-0xEF.
 
#define PM_FILT_MTC   (1 << 0x01)
 MIDI Time Code (0xF1)
 
#define PM_FILT_SONG_POSITION   (1 << 0x02)
 Song Position (0xF2)
 
#define PM_FILT_SONG_SELECT   (1 << 0x03)
 Song Select (0xF3)
 
#define PM_FILT_TUNE   (1 << 0x06)
 Tuning request (0xF6)
 
#define PM_FILT_SYSTEMCOMMON   (PM_FILT_MTC | PM_FILT_SONG_POSITION | PM_FILT_SONG_SELECT | PM_FILT_TUNE)
 All System Common messages (mtc, song position, song select, tune request)
 
#define Pm_Channel(channel)   (1<<(channel))
 
#define Pm_Message(status, data1, data2)
 Pm_Message() encodes a short Midi message into a 32-bit word. More...
 
#define Pm_MessageStatus(msg)   ((msg) & 0xFF)
 
#define Pm_MessageData1(msg)   (((msg) >> 8) & 0xFF)
 
#define Pm_MessageData2(msg)   (((msg) >> 16) & 0xFF)
 

Typedefs

typedef int32_t PmMessage
 see PmEvent
 

Functions

PMEXPORT PmError Pm_SetFilter (PortMidiStream *stream, int32_t filters)
 
PMEXPORT PmError Pm_SetChannelMask (PortMidiStream *stream, int mask)
 Pm_SetChannelMask() filters incoming messages based on channel. More...
 
PMEXPORT PmError Pm_Abort (PortMidiStream *stream)
 Pm_Abort() terminates outgoing messages immediately The caller should immediately close the output port; this call may result in transmission of a partial midi message. More...
 
PMEXPORT PmError Pm_Close (PortMidiStream *stream)
 Pm_Close() closes a midi stream, flushing any pending buffers. More...
 
PmError Pm_Synchronize (PortMidiStream *stream)
 Pm_Synchronize() instructs PortMidi to (re)synchronize to the time_proc passed when the stream was opened. More...
 

Detailed Description

Macro Definition Documentation

◆ PM_FILT_REALTIME

#define PM_FILT_REALTIME
Value:
#define PM_FILT_ACTIVE
filter active sensing messages (0xFE):
Definition: portmidi.h:389
#define PM_FILT_SYSEX
filter system exclusive messages (0xF0):
Definition: portmidi.h:391
#define PM_FILT_UNDEFINED
filter undefined real-time messages
Definition: portmidi.h:401
#define PM_FILT_TICK
filter tick messages (0xF9)
Definition: portmidi.h:397
#define PM_FILT_RESET
filter reset messages (0xFF)
Definition: portmidi.h:403
#define PM_FILT_CLOCK
filter MIDI clock message (0xF8)
Definition: portmidi.h:393

filter all real-time messages

Definition at line 405 of file portmidi.h.

◆ Pm_Message

#define Pm_Message (   status,
  data1,
  data2 
)
Value:
((((data2) << 16) & 0xFF0000) | \
(((data1) << 8) & 0xFF00) | \
((status) & 0xFF))

Pm_Message() encodes a short Midi message into a 32-bit word.

If data1 and/or data2 are not present, use zero.

Pm_MessageStatus(), Pm_MessageData1(), and Pm_MessageData2() extract fields from a 32-bit midi message.

Definition at line 503 of file portmidi.h.

Function Documentation

◆ Pm_Abort()

PMEXPORT PmError Pm_Abort ( PortMidiStream *  stream)

Pm_Abort() terminates outgoing messages immediately The caller should immediately close the output port; this call may result in transmission of a partial midi message.

There is no abort for Midi input because the user can simply ignore messages in the buffer and close an input device at any time.

Definition at line 906 of file portmidi.c.

◆ Pm_Close()

PMEXPORT PmError Pm_Close ( PortMidiStream *  stream)

Pm_Close() closes a midi stream, flushing any pending buffers.

(PortMidi attempts to close open streams when the application exits – this is particularly difficult under Windows.)

Definition at line 860 of file portmidi.c.

◆ Pm_SetChannelMask()

PMEXPORT PmError Pm_SetChannelMask ( PortMidiStream *  stream,
int  mask 
)

Pm_SetChannelMask() filters incoming messages based on channel.

The mask is a 16-bit bitfield corresponding to appropriate channels. The Pm_Channel macro can assist in calling this function. i.e. to set receive only input on channel 1, call with Pm_SetChannelMask(Pm_Channel(1)); Multiple channels should be OR'd together, like Pm_SetChannelMask(Pm_Channel(10) | Pm_Channel(11))

Note that channels are numbered 0 to 15 (not 1 to 16). Most synthesizer and interfaces number channels starting at 1, but PortMidi numbers channels starting at 0.

All channels are allowed by default

Definition at line 831 of file portmidi.c.

◆ Pm_Synchronize()

PmError Pm_Synchronize ( PortMidiStream *  stream)

Pm_Synchronize() instructs PortMidi to (re)synchronize to the time_proc passed when the stream was opened.

Typically, this is used when the stream must be opened before the time_proc reference is actually advancing. In this case, message timing may be erratic, but since timestamps of zero mean "send immediately," initialization messages with zero timestamps can be written without a functioning time reference and without problems. Before the first MIDI message with a non-zero timestamp is written to the stream, the time reference must begin to advance (for example, if the time_proc computes time based on audio samples, time might begin to advance when an audio stream becomes active). After time_proc return values become valid, and BEFORE writing the first non-zero timestamped MIDI message, call Pm_Synchronize() so that PortMidi can observe the difference between the current time_proc value and its MIDI stream time.

In the more normal case where time_proc values advance continuously, there is no need to call Pm_Synchronize. PortMidi will always synchronize at the first output message and periodically thereafter.

Definition at line 892 of file portmidi.c.


Generated for PortMidi by doxygen 1.9.1