The Alternative Csound Reference Manual
Previous | The Csound Command | Next

# Unified File Format for Orchestras and Scores

## Description

The Unified File Format , introduced in Csound version 3.50, enables the orchestra and score files, as well as command line flags, to be combined in one file. The file has the extension .csd. This format was originally introduced by Michael Gogins in AXCsound.

The file is a structured data file which uses markup language, similar to any SGML such as HTML. Start tags (<tag>) and end tags (</tag>) are used to delimit the various elements. The file is saved as a text file.

## Structured Data File Format

### Mandatory Elements

The Csound Element is used to alert the csound compiler to the .csd format. The file must begin with the start tag <CsoundSynthesizer>. The last line of the file must be the end tag </CsoundSynthesizer>. The remaining elements are defined below.

#### Options

Csound command line flags are put in the Options Element. This section is delimited by the start tag <CsOptions> and the end tag </CsOptions> Lines beginning with # or ; are treated as comments.

#### Instruments (Orchestra)

The instrument definitions (orchestra) are put into the Instruments Element. The statements and syntax in this section are identical to the Csound orchestra file, and have the same requirements, including the header statements (sr, kr, etc.) This Instruments Element is delimited with the start tag <CsInstruments> and the end tag </CsInstruments>.

#### Score

Csound score statements are put in the Score Element. The statements and syntax in this section are identical to the Csound score file, and have the same requirements. The Score Element is delimited by the start tag <CsScore> and the end tag </CsScore>.

### Optional Elements

#### Included Base64 Files

Base64 encoded MIDI files may be included with the tag <CsMidifileB filename=filename>, where filename is the name of the file containing the MIDI information. There is no matching end tag. New in Csound version 4.07.

Base64 encoded sample files may be included with the tag <CsSampleB filename=filename>, where filename is the name of the file containing the sample. There is no matching end tag. New in Csound version 4.07.

#### Version Blocking

Versions of Csound may blocked by placing one of the following statements between the start tag <CsVersion> and the end tag </CsVersion>:

    Before #.#

or

    After #.#

where #.# is the requested Csound version number. The second statement may be written simply as:

    #.#

See example below. New in Csound version 4.09.

#### Example

Below is a sample file, test.csd, which renders a .wav file at 44.1 kHz sample rate containing one second of a 1 kHz sine wave. Displays are suppressed. test.csd was created from two files, tone.orc and tone.sco, with the addition of command line flags.

    <CsoundSynthesizer>;
      ; test.csd - a Csound structured data file

    <CsOptions>
      -W -d -o tone.wav
    </CsOptions>

    <CsVersion>    ;optional section
      Before 4.10  ;these two statements check for
      After 4.08   ;   Csound version 4.09
    </CsVersion>

    <CsInstruments>
      ; originally tone.orc
      sr = 44100
      kr = 4410
      ksmps = 10
      nchnls = 1
      instr   1
          a1 oscil p4, p5, 1 ; simple oscillator
             out a1
        endin
    </CsInstruments>

    <CsScore>
      ; originally tone.sco
      f1 0 8192 10 1
      i1 0 1 20000 1000 ;play one second of one kHz tone
      e
    </CsScore>

    </CsoundSynthesizer>

## Command Line Parameter File

If the file .csoundrc exists, it will be used to set the command line parameters. These can be overridden. It uses the same form as a .csd file. Lines beginning with # or ; are treated as comments.

Previous | Home | Next
Command-line Flags | Up | Score File Preprocessing