noteondur2

noteondur2 — Sends a noteon and a noteoff MIDI message both with the same channel, number and velocity.

Description

Sends a noteon and a noteoff MIDI message both with the same channel, number and velocity.

Syntax

noteondur2 ichn, inum, ivel, idur

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.

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.

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.

Example 601. Example of the noteondur2 opcode.

See the sections Real-time Audio and Command Line Flags for more information on using command line flags.

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.

<CsoundSynthesizer> 

<CsOptions> 

; Select audio/midi flags here according to platform

; Audio out   Audio in    No messages

-odac           -iadc     -d         -M0  -Q1;;;RT audio I/O with MIDI in

</CsOptions>

<CsInstruments>



sr = 44100

kr = 4410

ksmps = 10

nchnls = 2



; Example by Giorgio Zucco 2007



instr 1



  ifund   notnum 

  ivel 	veloc

  idur = 1



  ;chord with single key

  noteondur2 	1, ifund,   ivel, idur

  noteondur2 	1, ifund+3, ivel, idur

  noteondur2 	1, ifund+7, ivel, idur

  noteondur2 	1, ifund+9, ivel, idur



endin







</CsInstruments>

<CsScore>

; Dummy ftable

f 0 60

</CsScore>

</CsoundSynthesizer>


See Also

noteoff, noteon, noteondur, midion, midion2

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.