Use Non-Frames Version Previous Page Next Page
MIDI Support: Note-on/Note-off

noteon, noteoff, noteondur, noteondur2

          noteon     ichn, inum, ivel

          noteoff    ichn, inum, ivel

          noteondur   ichn, inum, ivel, idur

          noteondur2 ichn, inum, ivel, idur


Send noteon and noteoff messages to the MIDI OUT port.


ichn – MIDI channel number (0-15)

inum – note number (0-127)

ivel – velocity (0-127)


noteon (i-rate note on) and noteoff (i-rate note off) are the simplest MIDI OUT opcodes. noteon sends a MIDI noteon message to MIDI OUT port, and noteoff sends a noteoff message. A noteon opcode must always be followed by an noteoff with the same channel and number inside the same instrument, otherwise the note will play endlessly. These noteon and noteoff are useful only when introducing a timout statement to play a non-zero duration MIDI note. For most purposes it is better to use noteondur and noteondur2.

noteondur and noteondur2 (i-rate note on with duration) send a noteon and a noteoff MIDI message both with the same channel, number and velocity. Noteoff message is sent after idur seconds are elapsed by the time noteondur was active.

noteondur differs from noteondur2 in that noteondur truncates note duration when current instrument is deactivated by score or by real-time playing, while noteondur2 will extend performance time of current instrument until idur seconds have elapsed. In real-time playing, it is suggested to use noteondur also for undefined durations, giving a large idur value.

Any number of noteondur or noteondur2 opcodes can appear in the same Csound instrument, allowing chords to be played by a single instrument.

Name Changes

Prior to Csound version 3.52 (February, 1999), these opcodes were called ion, ioff, iondur, and iodur2. ondur and ondur2 changed to noteondur and noteondur2 in Csound version 3.53.


Gabriel Maldonado
New in Csound version 3.47

Use Non-Frames Version Previous Page Next Page
MIDI Support: Note-on/Note-off