Advertisement

How-To Control Csound with a Custom Midi Controller: Introduction (1 of 2)

Csound is a free language for sound synthesis and processing. It has a rich history and is still used today by musicians, composers and sound designers including Brian Eno, Richard James (aka Aphex Twin), NIN, DJ Spooky, and many more. Why is Csound still in existence today? It is a simple language which veers quickly to complex auditory experiences. This coupled with a quick learning curve has kept Csound a popular audio synthesis language since its creation in 1985 by Barry Vercoe.

This How-To is one of a two part installment. Part One is an introductory leap into Csound. Part Two next week will have you building a physical interface to control a Csound environment via Midi. Please note that this intro is a small daub of paint in the universe that is Csound creation. Many books, entire webpages, and courses have been taught on Csound. This introduction is meant to offer a glimpse into the rich world of audio creation and to hopefully inspire the reader to invest more time in Csound.



You will need for this How-To: a computer with an audio card, and a Mac (OS X or OS 9), Windows, or Linux operating system. This How-To will focus on the lastest Mac OS X version of Csound, but should allow extrapolation to your OS.

Find and install Csound for your OS of choice:
Mac OS X
Mac OS 9
Windows
Linux (also here)

If you are in doubt about which version to grab go to the Csound front page and choose "Execs" and navigate to the download for your operating system or alternatively see the sourceforge page for Csound.

Launch the Csound application. Notice you have "orc" and "sco" tabs at the top of the main window. Orc stands for orchestra which is the area where you will define what your instruments will sound like. Sco stands for Score, the section in which you will define the notes and durations and parameters for each instrument.

csound4



Delete the text in the "orc" window and cut and paste this text to replace it (or download both orc and score files from here):

COPY AND PASTE THE TEXT BELOW THIS LINE
=======================================
;Fabienne Serriere
;engadget.com
;23rd August 2005
;feel free to redistribute! please use me and re-use me.

sr = 44100
kr = 44100
ksmps = 1
nchnls = 1

instr 10
idur = p3
iamp = ampdb(p4)
ifrq = cpspch(p5)
ifun = p6
iatk = p7
irel = p8
iatkfun = p9
index1 = p10
index2 = p11
kenv envlpx iamp, iatk, idur, irel, iatkfun, .7, .01
kmodswp expon index1, idur, index2
kbuzswp expon 20, idur, 1
afab grain 10000, ifrq*.04, 55, 10000, 10, .05, 1, 1, 1
asig3 foscil kenv, ifrq, 1, 1, kmodswp, ifun
asig2 buzz kenv, ifrq*.99, kbuzswp+1, ifun
asig1 pluck iamp, ifrq*.5, ifrq, 0, 1
amix = asig1+asig2+asig3+afab
out amix*.5
endin

instr 20
idur = p3
iamp = ampdb(p4)
ifrq = cpspch(p5)
iatk = p6
irel = p7
ivibdel = p8
imoddpt = p9
imodfrq = p10
iharm = p11
kenv linen iamp, iatk, idur, irel
kvibenv linseg 0, ivibdel, 1, idur-ivibdel, .3
klfo oscil kvibenv*imoddpt, imodfrq, 2
asig buzz kenv, ifrq+klfo, iharm, 2
out asig
endin


instr 30 ; 3D Sample Wave Terrain

ilevl = p4*32767 ; Output level
ipitch = (p5 iposx1 = p6 ; X position start
iposx2 = p7 ; X position finish
iposy1 = p8 ; Y position start
iposy2 = p9 ; Y position finish
iradi1 = p10/1000 ; Radius start (scaled)
iradi2 = p11/1000 ; Radius end (scaled)
iratex = p12 ; X random rate
iratey = p13 ; Y random rate
idpth = p14/1000 ; Random depth (scaled)

kx line iposx1, p3, iposx2 ; X position
ky line iposy1, p3, iposy2 ; Y position
krad line iradi1, p3, iradi2 ; Radius
krndx randi idpth, iratex ; X random position modulation
krndy randi idpth, iratey ; Y random position modulation
ksin oscili krad, ipitch, 40 ; X indexing osc (sine)
kcos oscili krad, ipitch, 40, .25 ; Y indexing osc (cosine)
kindx = kx + ksin + krndx ; Add X indexes together
kindy = ky + kcos + krndy ; Add Y indexes together
ax tablei kindx, 20, 1, 0, 1 ; X indexing
ay tablei kindy, 30, 1, 0, 1 ; Y indexing
out ax*ay*ilevl ; Output

endin


instr 40
idur = p3
iamp = ampdb(p4)
ifrq = cpspch(p5)
ifun = p6
iatk = p7
irel = p8
iatkfun = p9
index1 = p10
index2 = p11
kenv envlpx iamp, iatk, idur, irel, iatkfun, .7, .01
kmodswp expon index1, idur, index2
kbuzswp expon 20, idur, 1
afab grain 10000, ifrq*.5, 55, 10000, 10, .05, 1, 1, 1
asig3 foscil kenv, ifrq, 1, 1, kmodswp, ifun
asig2 buzz kenv, ifrq*.99, kbuzswp+1, ifun
asig1 pluck iamp, ifrq*.5, ifrq, 0, 1
amix = asig1+asig2+asig3+afab
out amix*.5
endin

==========================
COPY AND PASTE THE TEXT ABOVE THIS LINE

Next do the same for the "sco" section. Delete the existing text and cut and paste this in its place (or download both orc and score files from here):


COPY AND PASTE THE TEXT BELOW THIS LINE
==========================

;Fabienne Serriere
;engadget.com
;23rd August 2005
;feel free to redistribute! please use me and re-use me.

;Function 1 uses the GEN15 subroutine to compute a sine wave
;Function 2 uses the GEN10 subroutine to compute a sine wave
;Function 9 uses the GEN05 subroutine to compute an exponential Attack for use with envlpx
;Function 10 uses the GEN05 subroutine to compute an exponential Attack for use with envlpx
;Function 20 terrain table
;Function 30 terrain table
;Function 40 index table

f 1 0 4096 15 1
f 2 0 4096 10 1
f 9 0 513 5 .001 128 .8 128 .6 256 1
f 10 0 513 5 .01 64 1 64 .5 64 .99 64 .6 64 .98 64 .7 64 .97 32 .8 32 1
f 20 0 32768 1 "sample.wav" 0 4 0 ; X Sample1
f 30 0 65536 1 "sample.wav" 0 4 0 ; Y Sample1
f 40 0 8193 10 1 ; Sine

;ins st dur amp frq fun atk rel atkfun indx1 indx2
;===========================================

i 10 0 .4 58 4.00 1 .5 1 9 3 100
i 10 + .4 59 4.00 1 .5 1 9 3 100
i 10 . .4 60 4.00 1 .5 1 9 3 100
i 10 . .4 62 4.00 1 .5 1 9 3 100
i 10 . .4 66 4.00 1 .5 1 9 3 100

i 10 . .4 75 4.00 1 .5 1 9 3 100
i 10 . .4 66 4.00 1 .5 1 9 3 100
i 10 . .4 66 4.00 1 .5 1 9 3 100
i 10 . .4 66 4.00 1 .5 1 9 3 100
i 10 . .4 66 4.00 1 .5 1 9 3 100

i 10 . .4 75 4.00 1 .5 1 9 3 100
i 10 . .4 66 4.00 1 .5 1 9 3 100
i 10 . .4 66 4.00 1 .5 1 9 3 100
i 10 . .4 66 4.00 1 .5 1 9 3 100
i 10 . .4 66 4.00 1 .5 1 9 3 100

i 10 . .2 75 4.00 1 .5 1 9 3 100
i 10 . .2 66 4.00 1 .5 1 9 3 100
i 10 . .4 66 4.00 1 .5 1 9 3 100
i 10 . .4 66 4.00 1 .5 1 9 3 100
i 10 . .4 66 4.00 1 .5 1 9 3 100

i 10 . .4 75 4.00 1 .5 1 9 3 100
i 10 . .4 66 4.00 1 .5 1 9 3 100
i 10 . .4 66 4.00 1 .5 1 9 3 100
i 10 . .4 66 4.00 1 .5 1 9 3 100
i 10 . .4 66 4.00 1 .5 1 9 3 100

i 10 . .133 75 4.00 1 .5 1 9 3 100
i 10 . .133 75 4.00 1 .5 1 9 3 100
i 10 . .133 75 4.00 1 .5 1 9 3 100
i 10 . .4 66 4.00 1 .5 1 9 3 100
i 10 . .4 66 4.00 1 .5 1 9 3 100
i 10 . .4 66 4.00 1 .5 1 9 3 100
i 10 . .4 66 4.00 1 .5 1 9 3 100

i 10 . .4 75 4.00 1 .5 1 9 3 100
i 10 . .4 66 4.00 1 .5 1 9 3 100
i 10 . .4 66 4.00 1 .5 1 9 3 100
i 10 . .4 66 4.00 1 .5 1 9 3 100
i 10 . .4 66 4.00 1 .5 1 9 3 100

i 10 . .4 75 4.00 1 .5 1 9 3 100
i 10 . .4 66 4.00 1 .5 1 9 3 100
i 10 . .4 66 4.00 1 .5 1 9 3 100
i 10 . .4 66 4.00 1 .5 1 9 3 100
i 10 . .4 66 4.00 1 .5 1 9 3 100

i 10 . .4 75 4.00 1 .5 1 9 3 100
i 10 . .4 66 4.00 1 .5 1 9 3 100
i 10 . .4 66 4.00 1 .5 1 9 3 100
i 10 . .4 66 4.00 1 .5 1 9 3 100
i 10 . .4 66 4.00 1 .5 1 9 3 100

i 10 . .4 75 4.00 1 .5 1 9 3 100
i 10 . .4 66 4.00 1 .5 1 9 3 100
i 10 . .4 66 4.00 1 .5 1 9 3 100
i 10 . .4 66 4.00 1 .5 1 9 3 100
i 10 . .4 66 4.00 1 .5 1 9 3 100

i 10 . 4 75 4.00 1 .5 5 9 3 100


;ins st dur amp frq atk rel lfodel lfodpth lfofrq harm1
;=================================================


i 20 4 2 74 6.02 .2 .4 .5 5 6 9
i 20 + 1 74 6.02 .1 .5 .8 4 5 12
i 20 . .1 76 6.04 .2 .4 .5 5 6 9
i 20 . .1 74 6.03 .1 .5 .8 4 5 12

i 20 . 2 75 6.02 .3 .3 1.6 7 7 6
i 20 . 1 75 6.04 .5 .3 1 6 4.7 8

i 20 . 1 80 6.02 .9 .4 1.5 5 6 11
i 20 . .1 82 5.11 .2 .4 .5 5 6 9
i 20 . .1 82 6.0 .1 .5 .8 4 5 12
i 20 . 3 80 6.02 .1 .3 1 4 5 5

==========


; Strt Leng Levl Pitch Xpos1 Xpos2 Ypos1 Ypos2 Radi1 Radi2 Xrate Yrate Depth
i 30 16 20.0 1.00 300.0 0.25 0.35 0.10 0.75 0.00 0.35 2.35 1.11 0.10
i 30 . . 0.05 220.5 0.10 0.33 1.00 0.33 0.00 0.25 1.25 0.77 0.10
i 30 . . 1.00 480.3 0.50 0.77 0.80 0.74 0.01 0.08 2.23 3.14 0.10

; Strt Leng Levl Pitch Xpos1 Xpos2 Ypos1 Ypos2 Radi1 Radi2 Xrate Yrate Depth
i 30 30 25.0 1.00 330.0 0.25 0.35 0.10 0.75 0.00 0.05 2.35 1.11 0.10
i 30 . . 0.05 80.5 0.10 0.93 1.00 0.33 0.00 0.25 1.25 0.77 0.10
i 30 . . 1.00 480.3 0.50 0.77 0.80 0.74 0.01 0.98 2.23 3.14 0.10


; Strt Leng Levl Pitch Xpos1 Xpos2 Ypos1 Ypos2 Radi1 Radi2 Xrate Yrate Depth
i 30 50 32.0 1.00 300.0 0.01 0.03 0.80 0.75 0.09 0.35 2.35 1.11 0.10
i 30 . . 0.05 220.5 0.10 0.33 1.00 0.33 0.00 0.25 1.25 0.77 0.10
i 30 . . 1.00 480.3 0.50 0.98 0.80 0.04 0.01 0.08 2.23 3.14 0.10


=========



;=============================================

i 40 72.4 .4 75 6.00 1 .5 1 9 3 100
i 40 + .6 66 6 1 .5 1 9 3 100
i 40 . .2 66 5.09 1 .5 1 9 3 100
i 40 . .4 66 5.09 1 .5 1 9 3 100

i 40 . .4 75 6 1 .5 1 9 3 100
i 40 . .6 66 6 1 .5 1 9 3 100
i 40 . .2 66 5.07 1 .5 1 9 3 100
i 40 . .4 66 5.07 1 .5 1 9 3 100

i 40 . .4 75 5.09 1 .5 1 9 3 100
i 40 . .4 66 5.10 1 .5 1 9 3 100
i 40 . .4 66 6.0 1 .5 1 9 3 100
i 40 . .4 66 6.02 1 .5 1 9 3 100

i 40 . .4 75 5.09 1 .5 1 9 3 100
i 40 . .4 66 5.10 1 .5 1 9 3 100
i 40 . .4 66 6.0 1 .5 1 9 3 100
i 40 . .4 66 6.02 1 .5 1 9 3 100

i 40 . .4 62 5.04 1 .5 1 9 3 100
i 40 . .4 62 5.05 1 .5 1 9 3 100
i 40 . .4 62 5.06 1 .5 1 9 3 100
i 40 . .4 62 5.07 1 .5 1 9 3 100

i 40 . .4 62 5.04 1 .5 1 9 3 100
i 40 . .4 62 5.05 1 .5 1 9 3 100
i 40 . .4 62 5.06 1 .5 1 9 3 100
i 40 . .4 62 5.07 1 .5 1 9 3 100

i 40 . .4 i 40 . .4 . 5.021 1 .5 1 9 3 100
i 40 . .4 . 5.022 1 .5 1 9 3 100
i 40 . .4 . 5.023 1 .5 1 9 3 100



i 40 . .1 50 5.06 1 .5 1 9 3 100
i 40 . .1 50 5.07 1 .5 1 9 3 100
i 40 . .1 50 5.06 1 .5 1 9 3 100

i 40 . .1 50 5.06 1 .5 1 9 3 100
i 40 . .1 50 5.07 1 .5 1 9 3 100
i 40 . .1 50 5.05 1 .5 1 9 3 100

i 40 . .1 50 5.07 1 .5 1 9 3 100
i 40 . .1 50 5.06 1 .5 1 9 3 100
i 40 . .1 50 5.06 1 .5 1 9 3 100

i 40 . .1 50 5.08 1 .5 1 9 3 100
i 40 . .1 50 5.07 1 .5 1 9 3 100
i 40 . .1 50 5.05 1 .5 1 9 3 100

i 40 . .1 i 40 . .1 . 5.07 1 .5 1 9 3 100
i 40 . .1 . 5.06 1 .5 1 9 3 100

i 40 . .1 . 5.06 1 .5 1 9 3 100
i 40 . .1 . 5.07 1 .5 1 9 3 100
i 40 . .1 . 5.05 1 .5 1 9 3 100

i 40 . .1 . 5.07 1 .5 1 9 3 100
i 40 . .1 . 5.06 1 .5 1 9 3 100
i 40 . .1 . 5.06 1 .5 1 9 3 100

i 40 . .1 . 5.08 1 .5 1 9 3 100
i 40 . .1 . 5.07 1 .5 1 9 3 100
i 40 . .1 . 5.05 1 .5 1 9 3 100

i 40 . .1 . 5.06 1 .5 1 9 3 100
i 40 . .1 . 5.07 1 .5 1 9 3 100
i 40 . .1 40 5.06 1 .5 1 9 3 100

i 40 . .1 . 5.06 1 .5 1 9 3 100
i 40?