#include

#include — Includes an external file for processing.

Description

Includes an external file for processing.

Syntax

#includefilename

Performance

It is sometimes convenient to have the orchestra arranged in a number of files, for example with each instrument in a separate file. This style is supported by the #include facility which is part of the macro system. A line containing the text

#include “filename

where the character " can be replaced by any suitable character. For most uses the double quote symbol will probably be the most convenient. The file name can include a full path.

This takes input from the named file until it ends, when input reverts to the previous input. Note: Csound versions prior to 4.19 had a limit of 20 on the depth of included files and macros.

Another suggested use of #include would be to define a set of macros which are part of the composer's style.

An extreme form would be to have each instrument defines as a macro, with the instrument number as a parameter. Then an entire orchestra could be constructed from a number of #include statements followed by macro calls.

  #includeclarinet#includeflute#includebassoon”
  $CLARINET(1)
  $FLUTE(2)
  $BASSOON(3)
        

It must be stressed that these changes are at the textual level and so take no cognizance of any meaning.

Examples

Here is an example of the include opcode. It uses the files include.orc, include.sco, and table1.inc.

Example 4. Example of the include opcode.

/* include.orc */
sr = 44100
kr = 4410
ksmps = 10
nchnls = 1

; Instrument #1 - a basic oscillator.
instr 1
  kamp = 10000
  kcps = 440
  ifn = 1

  a1 oscil kamp, kcps, ifn
  out a1
endin
/* include.orc */

        
/* table1.inc */
; Table #1, a sine wave.
f 1 0 16384 10 1
/* table1.inc */

        
/* include.sco */
; Include the file for Table #1.
#include "table1.inc"

; Play Instrument #1 for 2 seconds.
i 1 0 2
e
/* include.sco */

        

Credits

Author: John ffitch
University of Bath/Codemist Ltd.
Bath, UK
April 1998

Example written by Kevin Conder.

New in Csound version 3.48