Components | All | New | MacOS | Windows | Linux | iOS | ||||
Examples | Mac & Win | Server | Client | Guides | Statistic | FMM | Blog | Deprecated | Old |
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 |
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 then also as hex number. Hex notation makes reading easier for debugging.
e.g. 144 is the status number for channel 1 note on followed by the Data1 as the note number and Data2 with the velocity. Status 128 is to turn the channel 1 note off.
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
- Math.BitwiseAND
- Math.BitwiseShiftRight
- PortMidi.Close
- PortMidi.OpenInput
- PortMidi.OpenOutput
- PortMidi.SendMessage
- PortMidi.SendMessageRaw
- PortMidi.SetDataAvailableEvaluate
- PortMidi.SetDataAvailableHandler
Example Databases
This function checks for a license.
Created 18th August 2014, last changed 19th March 2024
