midion
Generates MIDI note messages at k-rate.
Syntax
Initialization
iport -- MIDI output port, optional set to 0.
Performance
kchn -- MIDI channel number (1-16)
knum -- note number (0-127)
kvel -- velocity (0-127)
midion (k-rate note on) plays MIDI notes with current kchn, knum and kvel. These arguments can be varied at k-rate. Each time the MIDI converted value of any of these arguments changes, last MIDI note played by current instance of midion is immediately turned off and a new note with the new argument values is activated. This opcode, as well as moscil, can generate very complex melodic textures if controlled by complex k-rate signals.
A change of port, when iport is a global variable another instrument sets, moves the note the same way: it is turned off on the old port and sent on the new one. A noteoff always goes to the port of its noteon.
When a note is tied onto a held note, midion keeps sounding a note whose channel, number, velocity and port stay the same, and turns it off before sending a different one. A reinit pass turns the note off and sends it again. When the instrument ends without a release, for instance through turnoff2 with krelease 0, or the performance stops, the note still sounding is turned off.
In Csound 7.0.0, midion crashed at its first control cycle. Earlier versions sent the new note at a tie or a reinit without turning off the one still sounding, and left a note sounding when its instrument ended without a release.
Any number of midion opcodes can appear in the same Csound instrument, allowing a counterpoint-style polyphony within a single instrument.
Examples
Here is a simple example of the midion opcode. It uses the file midion_simple.csd.
This example generates a minor chord over every note received on the MIDI input. It generates MIDI notes on csound's MIDI output, so be sure to connect something.
Here is another example of the midion opcode. It uses the file midion_scale.csd.
This example generates random notes from a given scale for every note received on the MIDI input. It generates MIDI notes on csound's MIDI output, so be sure to connect something.
See also
Credits
Author: Gabriel Maldonado
Italy
May 1997
Thanks goes to Rasmus Ekman for pointing out the correct MIDI channel and controller number ranges.