Csound Environment Variables
Prev | The Csound Command | Next

## Csound Environment Variables

The following environment variables can be used by Csound:

- SFDIR: Default directory for sound files. Used if no full path is given for sound files.
- SSDIR: Default directory for input (source) audio and MIDI files. Used if no full path is given for sound files. May be used in conjunction with SFDIR to set separate input and output directories. Please note that MIDI files as well as audio files are also sought inside SSDIR.
- SADIR: Default directory for analysis files. Used if no full path is given for analysis files.
- SFOUTYP: Sets the default output file type. Currently only 'WAV', 'AIFF' and 'IRCAM' are valid. This flag is checked by the csound executable and the utilities and is used if no file output type is specified.
- INCDIR: Include directory. Specifies the location of files used by #include statements.
- OPCODE6DIR: Defines the location of csound opcode plugins for the single precision float (32-bit) version.
- OPCODE6DIR64: Defines the location of csound opcode plugins for the double precision float (64-bit) version.
- SNAPDIR: Is used by the FLTK widget opcodes when loading and saving snapshots.
- CSOUNDRC: Defines the csound resource (or configuration) file. A full path and filename containing csound flags must be specified. This variable defaults to .csoundrc if not present.
- CSSTRNGS: In Csound 5.00 and later versions, the localisation of messages is controlled by two environment variables CSSTRNGS and CS_LANG, both of which are optional. CSSTRNGS points to a directory containing .xmg files.
- CS_LANG: Selects a language for csound messages.
- RAWWAVE_PATH: Is used by the STK opcodes to find the raw wave files. Only relevant if you are using STK wrapper opcodes like STKBowed or STKBrass.
- CSNOSTOP: If this environment variable is set to "yes", then any graph displays are closed automatically at the end of performance (meaning that you possibly will not see much of them in the case of a short non-realtime render). Otherwise, you need to click "Quit" in the FLTK display window to exit, allowing for viewing the graphs even after the end of score is reached.
- MFDIR: Default directory for MIDI files. Used if no full path is given for MIDI files. Please note that MIDI files are sought in SSDIR and SFDIR as well.
- CS_OMIT_LIBS: Allows defining a list of plugin libraries that should be skipped. Libraries can be separated with commas, and don't require the "lib" prefix.

For more information about SFDIR, SSDIR, SADIR, MFDIR and INCDIR see Directories and files.

The only mandatory environment variables are OPCODE6DIR and OPCODE6DIR64. It is very important to set them correctly, otherwise most of the opcodes will not be available. Make sure you set the path correctly depending on the precision of your binary. if you run csound on a command line without any arguments you should see some text like : Csound version 6.03.1 (double samples) May 10 2014. This text refers to the double precision version.

CSSTRNGS and CS_LANG currently have very limited use since Csound has not yet been completely translated into other languages.

Other environment variables which are not exclusive to Csound but which might be of importance are:

- PATH: The directory containing csound executables should be listed in this variable.
- PYTHONPATH: If you intend to use CsoundVST and python, the directory containing the _CsoundVST shared library and the CsoundVST.py file must be in your PYTHONPATH environment variable (or the default path python searches in), so that the Python runtime knows how to load these files.
- LADSPA_PATH and DSSI_PATH: These environment variables are required if you are using the dssi4cs (LADSPA and DSSI host) plug-in opcodes.
- CSDOCDIR: Specifies the directory where the html help files are located. Though not used by Csound directly, this environment variable can help front-ends and editors (which implement it) to find the csound manual.

### Setting environment variables

#### On the command line

You can set environment variables on the command line or the configuration file .csoundrc by using the command line flag --env:NAME=VALUE or --env:NAME+=VALUE, where NAME is the environment variable name, and VALUE is its value. See Command-line Flags

| Note
Please note that this method of setting environment variables will not work for variables which are parsed before the command line arguments. SADIR, SSDIR, SFDIR, INCDIR, SNAPDIR, RAWWAVE_PATH, CSNOSTOP, SFOUTYP should work, but the following environment variables must be set on the system prior to running csound: OPCODE6DIR, OPCODE6DIR64, CSSTRINGS, and CS_LANG. CSOUNDRC can currently (v. 5.02) be set using --env, but this behavior is not guaranteed for future versions.

#### Windows

To set a csound environment on Windows XP and 2000 go to Control Panel->System->Advanced and click on the button 'Environment Variables'. On other versions of Windows earlier than Windows XP and Windows 2000 you set environment variables in the autoexec.bat file. Go to 'My Computer', select C: drive, right click on autoexec.bat, and select 'Edit'. The statement format is: SET NAME=VALUE .

#### Linux

You can set environment variables on Linux in many ways. You can set them using the export shell command, by setting them on .bashrc or similar files or by adding them to the /etc/profile file.

#### Mac

    ~$ export OPCODE6DIR64=/Users/you/your/Csound6/build

in addition if the bash shell is the default, then it is usually easier to edit your .bashrc or /etc/profile.

Note that if users choose one of the above methods, ie editing the .bashrc file then the environment variables are executed when a new shell is created. This can be problematic if your application implements a Quartz or Aqua interface and does not use the commandline.

If this is the case, then the standard solution (up to OS 10.3.9 and unless the application uses the csoundAPI and sets the environ variables directly) is to create an XML property list file (called a .plist file by the OS). This file should nominally be located at ~/.MacOSX/Environment.plist. This has been a solution specifically for the [csoundapi~] object for Pd on OS X. Since Pd uses an OS X native .app style packaging, and runs off of the Aqua interface, the standard means of supplying environment variables to Csound do not work. The solution is to set Csound's environment variables for the Aqua environment.

Likely, most users will not have the hidden folder .MacOSX located in their $HOME directory (aka ~/) This folder must first be created and the Environment.plist added to this folder. The contents of the Environment.plist file should be something like:

    <?xml version="1.0" encoding='UTF-8"?>
    <!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN"
        "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
    <plist version="1.0">
    <dict>
    <key>OPCODEDIR</key>
    <string>/Library/Frameworks/CsoundLib.framework/Versions/5.1/Resources/Opcodes</string>
    <key>OPCODEDIR64</key>
    <string>/Volumes/ExternalHD/devel/csound5/lib64</string>
    <key>INCDIR</key>
    <string>/Volumes/ExternalHD/CSOUND/include</string>
    <key>SFDIR</key>
    <string>/Volumes/ExternalHD/iTunes/csoundaudio</string>
    </dict>
    </plist>

and so on, using the XML <key> tag for each environment variable required by the API and the <string> tag for it's corresponding path on the system.

Please note that you must login out and login in for these changes to take effect.

Prev | Up | Next
Command-line Flags (by Category) | Home | Unified File Format for Orchestras and Scores