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 < 10 ? cpspch(p5) : p5) ; Pitch in cpspch or Hz
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      

14 thoughts on “How-To Control Csound With A Custom Midi Controller: Introduction (1 Of 2)

  1. is it just me, or does this article seem to not be posted right? i know one of my buddies that would probably get into csound, he is already into both programming and music.

  2. awesome tutorial.. always wanted to know what richard james was using… although i’m sure it’s just a small piece of the puzzle, i’m glad to see this stuff. keep it coming. and as for the question, “why is the whole article up on the homepage?” i’m sure you can scroll down. people need to stop complaining about the content they’re not interested in. you have the option to either visit the site or not. i know the effort involved is painful and excrutiating. put the bacon-butter-mayo sandwich down, and move the damn mouse.

  3. I did a whole semester of Csound in college. It was a blast. I still have a few of my orc’s and sco’s around somewhere. Will have to drag em out and try them with the new real-time renderer and see how it goes. I used to have to wait for a LONG time to get some of the granular synthesis stuff to render on those old G3’s.

  4. Okay, I was skeptical of the choice of Csound here, but later in the day talked to electronica master BT. He takes weekly courses on Csound and swears by it:

    http://createdigitalmusic.com/index.php?option=com_content&task=view&id=824&Itemid=44

    Max/MSP and Reaktor may remain my tools of choice (or Pd for a free alternative), but I’m increasingly respecting Csound in the modern age. Maybe I should play with that tool for bring Pd into Max.

    wow . . . my caps are gone! This site is like a copy editor’s worse nightmare. ;-)

  5. peter: I use both Pd and Csound and I swear by csound. I wanted to build a simple FM Synth in Pd and what I got was a cluttered mess of boxes and lines. The same synth in csound is a mere 3 lines:

    kmod oscili p6, p7, 1
    aout oscili p4, p5 + kmod, 1
    outs aout, aout

  6. It may be a little arcane, but stick with it. If you’re reading hackaday you’re the kind of person who Csound should appeal to!
    I’m throwing a few beginner notes in my blog, which you might want to check out to see if it’s on any help to you.
    csound.wordpress.com

Leave a Reply to carpespasmCancel reply

Please be kind and respectful to help make the comments section excellent. (Comment Policy)

This site uses Akismet to reduce spam. Learn how your comment data is processed.