Topics   All   MacOS (Only)   Windows (Only)   Linux (Only, Not)   iOS (Only, Not)  
Components   Crossplatform Mac & Win   Server   Client   Old   Deprecated   Guides   Examples   Videos
New in version: 12.2   12.3   12.4   12.5   13.0   13.1   13.2   13.3   13.4   13.5    Statistic    FMM    Blog  

PortMidi.ReadMessage

Reads one Midi message from the buffers.

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

Parameters

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

Result

Returns message, empty or error.

Description

Reads one Midi message from the buffers.
Format of result is a list containing: Status, Data1, Data2, Timestamp and raw message first as decimal number and than also as hex number. Hex notation makes reading easier for debugging.

Examples

Split MIDI Timestamp:

# last five bits are frame counter
Set Variable [$Frame; MBS("Math.BitwiseAND"; TimeStamp; 31)]
# Seconds are in 2nd byte, so take 6 bits after shifting 8 to right
Set Variable [$Second; MBS( "Math.BitwiseAND"; MBS( "Math.BitwiseShiftRight"; TimeStamp; 8 ); 63)
# Minutes are in 3rd byte, so take 6 bits after shifting 16 to right
Set Variable [$Minute; MBS( "Math.BitwiseAND"; MBS( "Math.BitwiseShiftRight"; TimeStamp; 16 ); 63)
# Hours are in 4th byte: take 5 bits after shifting 24 to right
Set Variable [$Hour; MBS( "Math.BitwiseAND"; MBS( "Math.BitwiseShiftRight"; TimeStamp; 24 ); 31)

See also

Example Databases

This function checks for a license.

Created 18th August 2014, last changed 20th February 2023


PortMidi.Poll - PortMidi.Rescan

💬 Ask a question or report a problem