Csound Environment Variables

The following environment variables can be used by Csound:

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:

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] 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.


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 .


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.


~$ 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"
<plist version="1.0">

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.