midion

midion — Generates MIDI note messages at k-rate.

Description

Generates MIDI note messages at k-rate.

Syntax

midion kchn, knum, kvel

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.

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.

Example 550. Simple Example of the midion opcode.

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

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.

<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 ;Triggered by MIDI notes on channel 1



  ifund notnum

  ivel  veloc



  knote1 init ifund

  knote2 init ifund + 3

  knote3 init ifund + 5



  ;minor chord on MIDI out channel 1

  ;Needs something plugged to csound's MIDI output

  midion 1, knote1,ivel

  midion 1, knote2,ivel

  midion 1, knote3,ivel



endin





</CsInstruments>

<CsScore>

; Dummy ftable

f0 60

</CsScore>

</CsoundSynthesizer>


Here is another example of the midion opcode. It uses the file midion_scale.csd.

Example 551. Example of the midion opcode to generate random notes from a scale.

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

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.

<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 ; Triggered by MIDI notes on channel 1



  ivel 	veloc



  krate = 8

  iscale = 100 ;f



  ; Random sequence from table f100

  krnd  randh int(14),krate,-1

  knote table abs(krnd),iscale

  ; Generates random notes from the scale on ftable 100

  ; on channel 1 of csound's MIDI output

  midion 1,knote,ivel



endin



</CsInstruments>

<CsScore>

f100 0 32 -2  40 50 60 70 80 44 54 65 74 84 39 49 69 69



; Dummy ftable

f0 60

</CsScore>

</CsoundSynthesizer>


See Also

moscil, midion2, noteon, noteoff, noteondur, noteondur2

Credits

Author: Gabriel Maldonado
Italy
May 1997

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