Csound can be operated in a variety of modes and configurations. The original method for running Csound was as a console program (DOS prompt for Windows, Terminal for Mac OS X). This, of course, still works. Running csound without any arguments prints out a list of command-line options, which are more fully explained in the Command Line Flags (by Category) section. Normally, the user executes something like:
csound -W -omysoundfile myorchestra.orc myscore.sco
or, to use the single-file Csound structured data (.csd) format:
csound myscore.csd
You can find many .csd files in the examples folder.
There are also many Front-Ends which can be used to run csound. A Front-End is a graphical program that eases the process of running csound, and sometimes provides editing and composing functions.
Csound also has several ways of producing output. It can:
CsoundVST is a multi-function front end for Csound, based on the Csound API. CsoundVST runs as a stand-alone graphical user interface to Csound, or as a VST plugin in hosts such as the Cubase audio sequencer. CsoundVST provides both a C++ and a Python API to Csound, and to a set of classes for algorithmic composition.
CsoundVST contains a built-in Python interpreter. With Python, the user can generate a score, import a MIDI file, process notes, load and run a Csound orchestra, and in general do anything that can be done either with Csound or in Python.
To run CsoundVST as a stand-alone front end to Csound, execute CsoundVST. When the program has loaded, you will see a graphical user interface with a row of buttons along the top. Click on the Open... button to load a .csd file. You can also click on the Open... button and load a .orc file, then click on the Import... button to add a .sco file. You can edit the Csound command, the orchestra file, or the score file in the respective tabs of the user interface. When all is satisfactory, click on the Perform button to run Csound. You can stop a performance at any time by clicking on the Stop button.
You can use CsoundVST as a Python extension module. In fact, you can do this either in a standard Python interpreter, such as Python command line or the Idle Python GUI, or in CsoundVST itself in Python mode.
To use CsoundVST in a standard Python interpreter, import CsoundVST.
import CsoundVST
The CsoundVST module automatically creates an instance of CppSound named csound, which provides an object-oriented interface to the Csound API. In a standard Python interpreter, you can load a Csound .csd file and perform it like this:
C:\Documents and Settings\mkg>python Python 2.3.3 (#51, Dec 18 2003, 20:22:39) [MSC v.1200 32 bit (Intel)] on win32 Type "help", "copyright", "credits" or "license" for more information. >>> import CsoundVST >>> csound.load("c:/projects/csound5/examples/trapped.csd") 1 >>> csound.exportForPerformance() 1 >>> csound.perform() BEGAN CppSound::perform(5, 988ee0)... BEGAN CppSound::compile(5, 988ee0)... Using default language 0dBFS level = 32767.0 Csound version 5.00 beta (float samples) Jun 7 2004 libsndfile-1.0.10pre6 orchname: temp.orc scorename: temp.sco orch compiler: 398 lines read instr 1 instr 2 instr 3 instr 4 instr 5 instr 6 instr 7 instr 8 instr 9 instr 10 instr 11 instr 12 instr 13 instr 98 instr 99 sorting score ... ... done Csound version 5.00 beta (float samples) Jun 6 2004 displays suppressed 0dBFS level = 32767.0 orch now loaded audio buffered in 16384 sample-frame blocks SFDIR undefined. using current directory writing 131072-byte blks of shorts to test.wav WAV SECTION 1: ENDED CppSound::compile. ftable 1: ftable 2: ftable 3: ftable 4: ftable 5: ftable 6: ftable 7: ftable 8: ftable 9: ftable 10: ftable 11: ftable 12: ftable 13: ftable 14: ftable 15: ftable 16: ftable 17: ftable 18: ftable 19: ftable 20: ftable 21: ftable 22: new alloc for instr 1: B 0.000 .. 1.000 T 1.000 TT 1.000 M: 32.7 0.0 new alloc for instr 1: B 1.000 .. 3.600 T 3.600 TT 3.600 M: 207.6 0.1 ... B 93.940 .. 94.418 T 98.799 TT281.799 M: 477.6 85.0 B 94.418 ..100.000 T107.172 TT290.172 M: 118.9 11.5 end of section 4 sect peak amps: 25950.8 26877.4 inactive allocs returned to freespace end of score. overall amps: 32204.8 31469.6 overall samples out of range: 0 0 0 errors in performance 782 131072-byte soundblks of shorts written to test.wav WAV Elapsed time = 13.469000 seconds. ENDED CppSound::perform. 1 >>>
To use CsoundVST itself as your Python interpreter, click on the CsoundVST Settings tab, and select the Python check box in the Csound performance mode box. Do not create a new CppSound object; you must use the builtin csound object in the CsoundVST module.
The koch.py script shows how to use Python to do algorithmic composition for Csound. You can use Python triple-quoted string literals to hold your Csound files right in your script, and assign them to Csound:
csound.setOrchestra('''sr = 44100 kr = 441 ksmps = 100 nchnls = 2 0dbfs = .1 instr 1,2,3,4,5 ; FluidSynth General MID I; INITIALIZATION ; Channel, bank, and program determine the preset, that is, the actual sound. ichannel = p1 iprogram = p6 ikey = p4 ivelocity = p5 + 12 ijunk6 = p6 ijunk7 = p7 ; AUDIO istatus = 144; print iprogram, istatus, ichannel, ikey, ivelocityaleft, aright fluid "c:/projects/csound5/samples/VintageDreamsWaves-v2.sf2", \\ iprogram, istatus, ichannel, ikey, ivelocity, 1 outs aleft, arightendin''') csound.setCommand("csound --opcode-lib=c:/projects/csound5/fluid.dll \\ -RWdfo ./koch.wav ./temp.orc ./temp.sco") csound.exportForPerformance() csound.perform()
To run your script in Csound VST, click on the Perform button.
The following instructions are for Cubase SX. You would follow roughly similar procedures in other hosts.
Use the Devices menu, Plug-In Information dialog, VST Plug-Ins tab, Shared VST Plug-ins Folder text field to add your csound5 directory to Cubase's plugin path. You can have multiple directories separated by semicolons.
Quit Cubase, and start it again.
Use the File menu, New Project dialog to create a new song.
Use the Project menu, Add Track submenu, to add a new MIDI track.
Use the pencil tool to draw a Part on the track a few measures long. Write some music in the Part using the Event editor or the Score editor.
Use the Devices menu (or the F11 key) to open the VST Instruments dialog.
Click on one of the No VST Instrument labels, and select \_CsoundVST from the list that pops up.
Click on the e (for edit) button to open the \_CsoundVST dialog.
On the Settings page, check the Instrument box in the VST Plugin group, and the Classic box in the Csound performance mode group. Then click on the Apply button.
Click on the Open button to bring up the file selector dialog. Navigate to a directory containing a Csound csd file suitable for MIDI performance, such as csound/CsoundVST/examples/CsoundVST.csd. Click on the OK button to load the file. You can also open and import a suitable .orc and .sco file as described above.
In any event, the command line in the Classic Csound command line text box must specify -+rtmidi=null -M0, and should read something like this:
csound -f -h -+rtmidi=null -M0 -d -n -m7 temp.orc temp.sco
Click on the VST Instruments dialog's on/off button to turn it on. This should compile the Csound orchestra. Note: If you don't compile the orchestra, you won't be able to assign the plugin to a track.
In the Cubase Track Inspector, click on the out: Not Assigned label and select _CsoundVST from the list that pops up.
On the ruler at the top of the Arrangement window, select the loop end point and drag it to the end of your part, then click on the loop button to enable looping.
Click on the play button on the Transport bar. You should hear your music played by CsoundVST.
Try assigning your track to different channels; a different Csound instrument will perform each channel.
When you save your song, your Csound orchestra will be saved as part of the song and re-loaded when you re-load the song.
You can click on the Orchestra tab and edit your Csound instruments while CsoundVST is playing. To hear your changes, just click on the CsoundVST Perform button to recompile the orchestra.
You can assign up to 16 channels to a single CsoundVST plugin. However, you can't have more than one CsoundVST plugin in the same song!