noteondur2
Sends a noteon and a noteoff MIDI message both with the same channel, number and velocity.
Syntax
Initialization
ichn -- MIDI channel number (1-16)
inum -- note number (0-127)
ivel -- velocity (0-127)
idur -- how long, in seconds, this note should last.
iport -- MIDI output port, optional set to 0.
Performance
noteondur2 (i-rate note on with duration) sends 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 noteondur2 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.
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 at once. The noteoff goes to the port of the noteon.
When a note is tied onto a held note, a note with the same channel, number, velocity and port goes on sounding, and its duration starts again from the tie; a different one is turned off first. A reinit pass turns the note off and sends it again.
Csound 7.0.0 and earlier 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 noteondur2 opcodes can appear in the same Csound instrument, allowing chords to be played by a single instrument.
Examples
Here is an example of the noteondur2 opcode. It uses the file noteondur2.csd.
This example generates notes 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
New in Csound version 3.47
Thanks goes to Rasmus Ekman for pointing out the correct MIDI channel and controller number ranges.