Features of this version of Csound
Here is a list of the features of DirectCsound, following the versions order.
|
|
release 1.0 |
|
Release 1.5 |
|
Release 1.71 |
|
Release 1.72 |
|
Release 1.731 |
|
Release 1.8 (sept. 97) |
|
RTsound 1.9 (jan. 98) |
|
RTsound 1.901 (feb.98) |
|
RTsound 1.902 (feb.98) |
|
RTsound 1.903 (mar.98) |
|
DirectCsound Version 2.0 (June 98) |
|
DirectCsound Version 2.1 (September 98) |
|
This version of csound does not have an IDE interface, so, to run it, you must type a command-line with several arguments from a DOS window (alternatively you can write a batch file or a shell program to run DirectCsound. A good shell program for this Csound version is WCshell by Riccardo Bianchini, written in Visual Basic. Another realtime oriented shell is my program VMCI, available at the url: ftp://musart.dist.unige.it/CSOUND/win95/).
Note that in this version of Csound command line arguments are not optional, if you don't type them correctly DirectCsound will show an error message! SEE below for some command line example.
If you already know standard Csound, let's read all the additional features of this version
If you don't know Csound you must study the main manual at first.
FLAG |
ARGUM |
DESCRIPTION |
-+K |
<num> | Enable MIDI IN. <num> = MIDI IN device id number. <num> is optional, if you omit it, a list of available MIDI IN devices will be displayed, then you can choose one of them by typing the corresponding number to the console. If this flag is used, don't use the standard flag -Msbmidi. |
-+q |
<num> | Enable MME WAVE OUT. <num> = WAVE OUT device id number. <num> optional, if you omit it, a list of available MME WAVE OUTdevices will be displayed, then you can choose one of them by typing the corresponding number to the console. This flag enables the old MME WAVE OUT. Don't use this flag together with -+X (DirectX audio). If this flag is used, don't use the standard flag -odevaudio. When using '-o<FILENAME>' together with '-+q' flag, both realtime audio and FILE output are enabled in parallel. |
-+p |
<num> | Set the buffer number in MME WAVE OUT. <num> is optional. default=4, maximum=40. The number of buffers, togheter with the buffer length (flag -b<num>), must be choosen accurately, considering that, when increasing the buffer, the latency delay increases too, whereas when decreasing the buffer, the risk of pop and click due to buffer underruns increases. |
-+j |
<num> | Console virtual text rows number. It is possible to define the number of rows of the console (max 2000) by using this flag. |
-+J |
<num> | Console virtual text columns number. |
-+O |
(uppercase letter) Suppress all printf for better realtime performance. Using this flag is better than using '-m0' because '-m0' still leaves some message output to the console. I suggest to use both -+O and -m0 at the same time for the best realtime performance. Warning! Use '-+O' only when your orc/sco files are fully tested, because the error messages are suppressed too. |
|
-+e |
Allow any output sample rate (for cards that support this feature). When you use a non-standard sr in realtime (for example 40000), a message will inform you that this sampling frequency is not allowed by the card. Some cards can handle all the sr frequency (for example the Sound Blaster cards) within a range continuously (for example from 8000 to 44100). So you can use these frequencies without any problem by setting this flag. |
|
-+y |
Don't wait for keypress on exit. Useful for batch processing. |
|
-+Q |
<num> | Enable MIDI OUT. <num> = MIDI OUT device id number. <num> is optional, if you omit it, a list of available MIDI OUT devices will be displayed, then you can choose one of them by typing the corresponding number to the console. |
-+Y |
Disable WAVE OUT (for better MIDI OUT timing performances). When using MIDI OUT oriented orc/sco pairs, disabling WAVE OUT will improve the timing of MIDI OUT flow. |
|
-+* |
Yields control to system until DAC buffer is half-empty, for better multitasking. In some cases this flag enhanches the realtime performance, and, above all, allow to use other graphic programs concurrently with Csound in realtime, without interruptions of the sound flow. This flag will slow all other application, because set Csound process to a higher priority. It can be used both with MME (-+q) and DirectX (-+X) drivers. |
|
-+/ |
<filename> | Csound command line is intended to be included in a text file. The command file must contain the flag as well as the other arguments in the same syntax of csound command line. Carriage returns inside the command file are ignored. |
-+X |
<num> | Enable DirectSound routines for low latency delay of audio output. <num> optional, if you omit it, a list of available DirectX audio devices will be displayed, then you can choose one of them by typing the corresponding number to the console. Don't use this flag together with -+p and -+q flags (which enable old MME WAVE OUT). Also, don't use the standard flag -odevaudio with this flag. When using '-o <FILENAME>' together with '-+X' flag, both realtime audio and FILE output are enabled in parallel. |
The following command-line invokes realtime MIDI performance of Csound with the DirectSound routines. The console messages are suppressed (-+O and -m0 flags), it is asked to the user the midi input port number to be used (-K flag) and the DirectSound device number (-X flags). The buffer length is set to 100 samples.
csound.exe -+O -m0 -+X -+K -b100 miditest.orc miditest.sco |
Same as the above, but with -+* flag to enhance realtime DirectX audio multitasking (in some cases this flag can make realtime performance worse. Experiment!).
csound.exe -+O -m0 -+X -+K -b100 -+* miditest.orc miditest.sco |
The following command-line invokes realtime midi performance of Csound with pedal treshold of 99, 12 wave out buffers of 882 bytes each, and prompts the user to input the MIDI IN and MME WAVE OUT device numbers. An audible delay is present, due to the latency of the MME driver:
csound.exe -P99 -+p12 -b882 -+K -+q miditest.orc miditest.sco |
same as above but with all displays suppressed ("-O" and "-m0" flags. Use this feature only when your orc and sco are fully tested!):
csound.exe -+O -m0 -P99 -+p12 -b882 -+K -+q miditest.orc miditest.sco |
same as above but with display enabled, a 1000 rows virtual console, midi device number 4 (flag '-+K') and wave out device number 0 (flag '-+q'):
csound.exe -+j1000 -+K4 -+q0 -P99 -p12 -b882 miditest.orc miditest.sco |
some as above but with '-+*' flag to enhance Windows multitasking:
csound.exe -+* -+j1000 -+K4 -+q0 -P99 -+p12 -b882 miditest.orc miditest.sco |
allows arbitrary sample rate (e.g.other than 1025/22050/44100) with '-e' flag and MME WAVE OUT (Note the reduced -+p and -b values when using "rounded" sr and kr values; these values are good with my Pentium133 with a sr=40000 and kr=400):
csound.exe -+e -+O -m0 -P99 -+p4 -b100 -q -K miditest.orc miditest.sco |
allows MIDI OUT operations with device num.5 (flag '-Q') in parallel with WAVE OUT:
csound.exe -+e -P99 -+j2000 -+Q5 -+q -+p4 -+K4 -b100 midiout.orc midiout.sco |
allows MIDI OUT operations with device num.5 (flag '-Q') and suppresses WAVE OUT for better MIDI OUT timing (flag '-Y'):
csound.exe -+e -+Y -P99 -+j2000 -+Q5 -+q -+K4 midiout.orc midiout.sco |
calls csound by command line contained in file 'cl.txt':
csound.exe -+/cl.txt |
enables realtime WAVE IN operation (flag '-i'without arguments) in parallel with WAVE OUT (flag '-+q') and asks to the user the number of Multimedia-Windows devices:
csound.exe -+p12 -b882 -+q -i |
There are two ways to start realtime audio output sessions: using DirectSound or old MME WAVE OUT. Don't use both the flags at the same time!
To use DirectSound you have to set the -+X flag together with -b flag. The buffer length determines how quick the response to your realtime actions is. With my Pentium 133 a value of -b100 is the minimum possible value: below that sample-flow interruptions will occurr (i.e. pop and clics will be heard). However, with other computers it should be possible to reduce this value to allow a faster note response (curiosly, sometimes faster computers need a bigger value as in the case of my new Pentium II 400 MHz, which needs at least a -b200 value). |
When DirectSound is not used, finding the optimum values for "-b" and "-+p" flags (which enable the old MME WAVE OUT driver) requires some experimentation: more buffer length means more latency delay but also more safety from dropouts and sound interruptions (flag "-B" is now obsolete, don't use it). Now it is possible to reduce buffer length and delay by using '-+e' flag and 'rounded' sr and kr. Notice that sometimes a smaller buffer length can handle sound flow better than a larger. Only experimentation can lead you toward optimal '-b' values. However the minimum latency delay can be allowed only when using DirectX (+X flag) instead of old MME driver. |
When DirectSound is not used (i.e. when using old MME drivers), optimum "-b" and "-+p" flag values need to be changed with different audio and k rates. These changes are not linear and not intuitive. So experiment! |
It is suggested to set "-b" value to integer multiples or sub-multiples of kr. This tip sometime can help to reduce latency, sometime not. Again, experiment to find optimum values. |
When old MME WAVE OUT driver is used, "-b" and "-+p" flag values can be reduced considerably by using "rounded" ar and kr values (for example ar=32000 and kr=320; ar=40000 and kr=400 and so on) together with "-e" flag (until now this feature is tested only with a SB16 ASP and with an AWE32 card. I don't know if other cards support it). Reducing "-b" and "-+p" flag values means reducing latency delay and so a more interactive realtime playing. |
"-+Q" flag allows parallel MIDI OUT and DAC performance. Unfortunately the realtime timing implemented in Csound is completely managed by DAC buffer sample flow. So MIDI OUT operations can present some time irregularities. These irregularities can be fully eliminated when suppressing DAC operations themselves ('-+Y' flag). |
"-+Y" flag suppresses DAC operations. This enhances timing of midi out operations when used in conjunction with "-+Q" flag. It is recommended to use "-+Y" with low krates (max. kr=1000). As in Win95 maximum timer resolution is 1/1000 of second, unpredictable results can occurr when using it at krates greater than 1000. Also it is very important to set only kr values in which the following division: 1000/kr produces integer results (some example: kr = 10; 20; 50; 100; 125; 200; 250 etc.) because Win95 timer only handles integer periods in milliseconds. If you use a kr value that produces a non integer result in the above formula Csound seems to run normally but times will be not reliable. With my computer I work very well with a value of kr=200. Maybe with slower computers a lower value works better. Experiment! I recommend to use kr=200 or less because with values greater than 200 increases the overhead affecting the entire system and do not give a notable precision improvement. A time resoultion of 1/200 of sec is enough precise for almost all MIDI application. You must respect sr/kr/ksmps ratio even if sr value is meaningless when using "-Y" flag, or an error message will stop the performance. |
'-+*' flag compells Csound to yield control to system until audio output buffer content passes a certain threshold. Below this threshold Csound continues processing, while over this threshold Csound yields control to Windows. This gives a big enhanchement in multitasking processes. Enabling this option reduces polyphony a bit when using short buffer space. So the user should increase the number ('-+p' flag) and the length ('-b' flag) of buffers when setting '-+*' flag. Experiment to find best values. |
For best realtime performance, it is (obviously) better:
|
'-+O' flag suppresses all text output during the performance time. Using only '-m0' flag, some text messages are still sent to the console. I suggest to use '-m0' and '-+O' flag together for maximum performance speed. |
'xtratim' and 'release' opcodes (as well as 'linenr') don't operate correctly when using -t flag. |
When using ctrlXX and midicXX opcodes you must be sure the MIDI IN flag (-K and/or -Msbmidi) is activated, or Csound will crash! |
When using realtime AUDIO input you must set the -i flag without argument, or followed by a number which represent the wave-in port number recognized by Win95. (ex. -i0). Notice that DirectX realtime input is not implemented yet, so you must use the old MME driver. |
When using parallel WAVE out and FILE out, you must set -o flag followed by the output file name (which must have a name different than "devaudio" or "dac" obviously), toghether with the -+q flag (when using MME) or -+X flag (when using DirectX). |