Structured Data File Format
Prev | Unified File Format for Orchestras and Scores | Next

### 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 files may be included with the tag <CsFileB filename=filename>, where filename is the name of the file to be included. The Base64 encoded data should be terminated with a </CsFileB> tag. For encoding files, the csb64enc and makecsd utilities (included with Csound 5.00 and newer) can be used. The file will be extracted to the current directory, and deleted at end of performance. If there is an already existing file with the same name, it is not overwritten, but an error will occur instead.

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. Using this tag is not recommended; use <CsFileB> instead.

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. Using this tag is not recommended; use <CsFileB> instead.

##### 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>

Prev | Up | Next
Unified File Format for Orchestras and Scores | Home | Command Line Parameter File