outkpc

outkpc — Sends MIDI program change messages at k-rate.

Description

Sends MIDI program change messages at k-rate.

Syntax

outkpc kchn, kprog, kmin, kmax

Performance

kchn -- MIDI channel number (1-16)

kprog -- program change number in floating point

kmin -- minimum floating point value (converted in MIDI integer value 0)

kmax -- maximum floating point value (converted in MIDI integer value 127 (7 bit))

outkpc (k-rate program change output) sends program change messages. It works only with MIDI instruments which recognize them. These opcodes can drive a different value of a parameter for each note currently active.

It can scale the k-value floating-point argument according to the kmin and kmax values. For example: set kmin = 1.0 and kmax = 2.0. When the kvalue argument receives a 2.0 value, the opcode will send a 127 value to the MIDI OUT device. When the kvalue argument receives a 1.0 value, it will send a 0 value. k-rate opcodes send a message each time the MIDI converted value of argument kvalue changes.

Examples

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

Example 713. Example of the outkpc opcode.

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

This example generates a program change and a note on Csound's MIDI output port whenever a note is received on channel 1. Be sure to have something connected to Csound's MIDI out port to hear the result.

<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

kprogram init 0

instr 1 ;Triggered by MIDI notes on channel 1

  ifund   notnum
  ivel 	veloc
  idur = 1

; Sends a MIDI program change message according to
; the triggering note's velocity
outkpc     1 ,ivel ,0 ,127

noteondur  1 ,ifund ,ivel ,idur

endin

</CsInstruments>
<CsScore>
; Dummy ftable
f 0 60
</CsScore>
</CsoundSynthesizer>


Here is another example of the outkpc opcode. It uses the file outkpc_flkt.csd.

Example 714. Example of the outkpc opcode using FLTK.

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

<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

FLpanel "outkpc",200,100,90,90;start of container
gkpg, gihandle FLcount "Midi-Program change",0,127,1,5,1,152,40,16,23,-1
FLpanelEnd

FLrun

instr 1

ktrig changed gkpg
outkpc     ktrig,gkpg,0,127

endin


</CsInstruments>
<CsScore>
; Run instrument 1 for 60 seconds
i 1 0  60
</CsScore>
</CsoundSynthesizer>


See also

MIDI Message Output

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.