midiin
Returns a generic MIDI message received by the MIDI IN port.
Syntax
Performance
kstatus -- the type of MIDI message. Can be:
- 128 (note off)
- 144 (note on)
- 160 (polyphonic aftertouch)
- 176 (control change)
- 192 (program change)
- 208 (channel aftertouch)
- 224 (pitch bend)
- 0 if no MIDI message are pending in the MIDI IN buffer
kchan -- MIDI channel (1-16 if only one input port is used, higher if channel is port mapped.)
kdata1, kdata2 -- message-dependent data values
For a Note Off message with kstatus equal to 128, kdata1 is the key number and kdata2 is the Note Off velocity. Match kchan and kdata1 to the note you want to handle. Check each message rather than waiting for kstatus to change, since consecutive messages can have the same status.
midiin has no input arguments, because it reads at the MIDI in port implicitly. It works at k-rate. Normally (i.e., when no messages are pending) kstatus is zero, only when MIDI data are present in the MIDI IN buffer, is kstatus set to the type of the relevant messages.
Note
Be careful when using midiin in low numbered instruments, since a MIDI note will launch additional instances of the instrument, resulting in duplicate events and weird behaviour. Use massign to direct MIDI note on messages to a different instrument or to disable triggering of instruments from MIDI.
Examples
Here is an example of the midiin opcode. It uses the file midiin.csd.
See also
ctlchn reads controller messages with optional channel and controller filters.
Credits
Author: Gabriel Maldonado
Italy
1998
New in Csound version 3.492