midic21

midic21 — Allows a floating-point 21-bit MIDI signal scaled with a minimum and a maximum range.

Description

Allows a floating-point 21-bit MIDI signal scaled with a minimum and a maximum range.

Syntax

idest midic21 ictlno1, ictlno2, ictlno3, imin, imax [, ifn]
kdest midic21 ictlno1, ictlno2, ictlno3, kmin, kmax [, ifn]

Initialization

idest -- output signal

ictln1o -- most-significant byte controller number (0-127)

ictlno2 -- mid-significant byte controller number (0-127)

ictlno3 -- least-significant byte controller number (0-127)

imin -- user-defined minimum floating-point value of output

imax -- user-defined maximum floating-point value of output

ifn (optional) -- table to be read when indexing is required. Table must be normalized. Output is scaled according to the imin and imax values.

Performance

kdest -- output signal

kmin -- user-defined minimum floating-point value of output

kmax -- user-defined maximum floating-point value of output

midic21 (i- and k-rate 21 bit MIDI control) allows a floating-point 21-bit MIDI signal scaled with a minimum and a maximum range. Minimum and maximum values can be varied at k-rate. It can use optional interpolated table indexing. It requires three MIDI controllers as input.

[Note] Note

Please note that the midic family of opcodes are designed for MIDI triggered events, and do not require a channel number since they will respond to the same channel as the one that triggered the instrument (see massign). However they will crash if called from a score driven event.

Examples

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

Example 590. Example of the midic21 opcode.

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
-odac -M0 --midi-key-cps=4 --midi-velocity-amp=5   ;;;realtime audio out and realtime midi in, midi key cps is routed to p4 and velocity to p5
; For Non-realtime ouput leave only the line below:
; -o midic21.wav -W ;;; for file output any platform
</CsOptions>
<CsInstruments>

; by tgrey - 2020

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

instr 1
	; This example expects MIDI controller input on channel 1
	; run, play a note and move your midi controllers 1, 7, and 10 to see results
	ictlno1= 1 	; = cc #1 midi mod wheel (course tuning)
	ictlno2= 7 	; = cc #7 midi volume (fine tuning)
	ictlno3= 10 ; = cc #10 midi pan (extremely fine tuning)

	; max range is 4 octaves: (2^4) = 16
	imax  = 16

	; read all 3 controllers, scaling them between 1 and imax
	kTune midic21 ictlno1, ictlno2, ictlno3, 1, imax	
	printk2	kTune

	; generate tones
	asig oscili p5, p4*kTune
	aref oscili p5, p4

	; combine detuned tone and reference tone
	; creates a beat effect from the detune
	asig=(asig+aref)*.5

	outs asig, asig
endin
</CsInstruments>
<CsScore>
; run for 60 seconds
f0 60
e
</CsScore>
</CsoundSynthesizer>


See Also

ctrl7, ctrl14, ctrl21, initc7, initc14, initc21, midic7, midic14

Credits

Author: Gabriel Maldonado
Italy

New in Csound version 3.47

Thanks goes to Rasmus Ekman for pointing out the correct controller number range.