Getting Started with Csound
Prev | Preface | Next

## Getting Started with Csound

### Downloading

In case you don't already have Csound (or have an older version) download the appropriate Csound version for your platform from the Sourceforge Csound5 Download Page. Installers for Windows have '.exe' extension and for Mac '.dmg' or '.tar.gz'. If the installer's filename ends in '-d' it means the installer has been built with double precision (64-bit) which provides higher quality output than the ordinary float precision (32-bit), which provides quicker output. You can also download the sources and build them, but this requires more expertise (See the section Building Csound).

It's also useful to download the most recent version of this manual, which you will also find there.

### Running

Csound can be run in different ways. Since Csound is a command line program (DOS in Windows terms), just clicking on the csound executable will have no effect. Csound must be called either from a terminal (or DOS prompt), or from a front-end. To use Csound from the command line, you must open a Terminal (DOS prompt on Windows). Using Csound from the command line can be hard if you've never used the terminal, so you may want to try to use one of the front-ends included with your distribution. A front-end is a graphical program that assists running Csound and can usually help edit csound files.

Both in the case of front-ends as well as execution from the command line, Csound needs two things:

- A Csound file ('.csd' or possibly an '.orc' and a '.sco' file)
- A list of command line flags (or configuration options) that configure execution. They determine things like output filename and format, whether real-time audio and MIDI are enabled, which soundcard to use, the buffer size, the amount of messages printed, etc. These options can be included in the '.csd' file itself, so for the examples included in this manual you shouldn't need to worry about them. The complete and very long list of available command flags can be found here, but you might want to have a look there later...

See the section Configuring if Csound is giving you trouble.

This documentation includes many '.csd' files which you can try out, and which should work directly from the command line or from any frontend. A simple example is oscil.csd that can be found in the examples folder of this documentation. Your front-end should allow you to choose the file, and it should have a 'play' or 'render' button.

| Note for MacCsound users
You might need to remove all the lines from the command options slot in order for the manual examples to work.

You can also try the manual examples from the command line by navigating to the examples directory of the manual using something like this on Windows (assuming the manual is located at c:\Program Files\Csound\manual\):

    cd "c:\Program Files\Csound\manual\examples"

or something like:

    cd /manualdirectory/manual/examples

for the Mac or linux terminals and then typing:

    csound oscil.csd

The example files are configured to run in realtime by default, so you should have heard a 2 second sine wave.

### Writing your own csd files

A .csd file looks like this (this file is oscils.csd):

    <CsoundSynthesizer>
    <CsOptions>
    ; Select audio/midi flags here according to platform
    ; Audio out   Audio in    No messages
    -odac           -iadc     -d     ;;;RT audio I/O
    ; For Non-realtime ouput leave only the line below:
    ; -o oscils.wav -W ;;; for file output any platform
    </CsOptions>
    <CsInstruments>

    ; Initialize the global variables.
    sr = 44100
    kr = 4410
    ksmps = 10
    nchnls = 1

    ; Instrument #1 - a fast sine oscillator.
    instr 1
      iamp = 10000
      icps = 440
      iphs = 0

      a1 oscils iamp, icps, iphs
      out a1
    endin

    </CsInstruments>
    <CsScore>

    ; Play Instrument #1 for 2 seconds.
    i 1 0 2
    e

    </CsScore>
    </CsoundSynthesizer>

Csound's .csd files contain 3 main sections contained within <CsSynthesizer> and </CsSynthesizer> tags:

- CsOptions - Includes the Command Line flags specific to this particular file. These options can also be set using the .csoundrc file or directly in the command line. Some frontends also provide ways to specify global or local options.
- CsInstruments - Contains the instruments or processes available in the file. Instruments are defined using the instr and endin opcodes. The CsInstruments section also contains the Orchestra Header which defines things like sample rate, the number of samples in a control period and the number of output channels.
- CsScore - Contains the 'notes' to be played optionally the definition of f-tables. Notes are created using the i statement, and f-tables are created using the f statement. There are several other score statements available.

Note that anything after a semicolon (;) until the end of the line is a comment, and is ignored by csound.

You can write csd files in any plain text editor like notepad or textedit. Just be sure to save the file as plain text (not rich text). Many frontends include advanced editing capabilities with syntax highlighting and completion.

You can find an in depth tutorial on getting started with Csound written by Michael Gogins here.

Prev | Up | Next
Copyright Notice | Home | What's new in Csound 5.06