Skip to content

midion2

Sends noteon and noteoff messages to the MIDI OUT port when triggered by a value different than zero.

Syntax

midion2(kchn, knum, kvel, ktrig[, iport])
midion2 kchn, knum, kvel, ktrig[, iport]

Initialisation

iport -- MIDI output port, optional set to 0.

Performance

kchn -- MIDI channel (1-16)

knum -- MIDI note number (0-127)

kvel -- note velocity (0-127)

ktrig -- trigger input signal (normally 0)

Similar to midion, this opcode sends noteon and noteoff messages to the MIDI out port, but only when ktrig is non-zero. This opcode is can work together with the output of the trigger opcode.

midion2 turns off only notes it sent. Each trigger turns off the last note before sending the new one, and the release turns it off, on the port the note went to. A note still sounding at a tie or a reinit pass is turned off by the next trigger or the release, and when the instrument ends without a release, for instance through turnoff2 with krelease 0, or the performance stops, it is turned off then. A channel above 16 is sent on channel 16.

Csound 7.0.0 and earlier sent a noteoff for channel 1, note 0 before the first note, sent a channel above 16 on channel 1, and left a note sounding when its instrument ended without a release.

Examples

Here is an example of the midion2 opcode. It uses the file midion2.csd.

Example of the midion2 opcode.
<CsoundSynthesizer>
<CsOptions>
; Select audio/midi flags here according to platform
 -M0 -Q1 ;;;midi in and midi out
</CsOptions>
<CsInstruments>

sr = 44100
ksmps = 32
nchnls = 2
0dbfs  = 1

instr 1

kcps line 3, p3, .1     
klf  lfo 1, kcps, 3     ;use a unipolar square to trigger
ktr  trigger klf, 1, 1  ;from 3 times to .1 time per sec.
     midion2 1, 60, 100, ktr

endin
</CsInstruments>
<CsScore>

i 1 0 20
e
</CsScore>
</CsoundSynthesizer>

See also

Note-on/Note-off Output

Credits

Author: Gabriel Maldonado
Italy
1998

New in Csound version 3.492

Thanks goes to Rasmus Ekman for pointing out the correct MIDI channel and controller number ranges.