REAL-TIME AUDIO OUTPUT HINTS FOR CSOUNDAV Art Hunkins - April 2005 1) The only flag you *need* for real-time audio is -+P. This specifies Portaudio, which includes all MME, DirectSound and ASIO drivers in your system. This flag is the equivalent of -odac or -odevaudio in canonical Csound. You can enter any flag either on the command line, or under CsOptions toward the beginning of a .csd file (use a text editor, such as Notepad). 2) If you want MIDI input, you also need the -+K flag. This corresponds to the -M flag in canonical Csound. 3) When you render files with these flags, a popup window will appear for each flag. It will list available output drivers for -+P and MIDI input devices for -+K. Once you have made your selections (and find they work), you can optionally add the appropriate number to the flag (again with a text editor) - e.g., -+P6 or -+M0. This will eliminate the popup windows. 4) With respect to latency (response lag to performance action, such as a MIDI keypress): ASIO and DirectSound drivers give more accurate timing than MME. However, these drivers are also more prone to pops and crackles; be sure to close other processes running on your computer, including those in the taskbar. The only processes that *must* remain open are Explorer and Systray. Other than change driver type, there is nothing in CsoundAV you can do to lower latency. 5) Also to minimize pops and crackles: it is recommended you eventually add the following combination of flags (they suppress messages): -+Om0. Or, add this longer combination (which also suppresses function table displays and minimizes the GUI run-time window): -+Om0d+M. 6) If you're getting "zipper noise" when using an MME driver, either switch to another driver type or do the following: in the AV's GUI window, click on "Set Environment Paths," then insert a value of 50 or so (adjust as needed) for "Portaudio output latency." This "zipper noise" is a new "feature" of v0.0432 (and affects MME drivers only). It did not exist in 0.0431, which is still available and near identical (http://sourceforge.net/projects/csoundav - then click on "View ALL Project Files"). For console (command-line) AV, the solution is a bit more complicated. If your OS is Win95/98/ME, edit your autoexec.bat file (in Notepad) by adding the line: set PA_MIN_LATENCY_MSEC=50 (This adds 50ms of latency to hopefully get rid of your "zipper.") Comparably, in WinNT/2000/XP, right-click on your desktop "My Computer" icon, and click on the "Advanced" tab of the "System Properties" dialog box. Then click on the "Environment Variables" button and add a PA_MIN_LATENCY_MSEC variable with the appropriate value (50 or so). 7) If you are *still* getting pops and crackles, you can try three additional remedies: a) perform a MIDI version of a work rather than one that uses a mouse clicking on-screen widgets (mouse motion is a major source of pops and crackles). b) Assuming a sample rate of 44100, reduce this number to 22050 and cut the value of ksmps in half (again toward the top of the .csd file). With this option, sr, kr and ksmps must remain integers, and kr * ksmps must continue to = sr. (Note that a lower sr will give satisfactory sound for some works but not for others.) c) If available, perform a "simple" version of the work that is less computationally intensive, or one that requires fewer voices. 8) Otherwise, you need a faster computer. Most of the above suggestions will "tweak" output, and get rid of the occasional pop or crackle (or consistent "zipper"). Only a more powerful system will remedy sound that is significantly choppy. Some of these suggestions are taken from an email reply by Gabriel Maldonado to the general Csound listserv on 3/27/05. I reproduce it below verbatim: Have you tried with Portaudio drivers (-+P flag) only???? You don't have to set any other flag (except -+K for midi). So you only have to set -+P -+K and nothing else (eventually -+Om0 to suppress messages to the console, but only when you are sure yor csd works ok. DON'T SET ANY OTHER FLAG!!!). SB Audigy should allow a very low latency (in the order 15-20 ms or even less) with the ASIO native host. You can tweak the latency by opening the "set environment dir paths" dialog-box and set the "Portaudio lantecy in millisecs" number boxes. If you get the message "PortAudio not initialized" try to change the sample rate (it seems to me that Audigy only allows 48 KHz, or 44.1 KHz under ASIO, but I don't remember). BtW Creative ASIO driver of SB Audigy are is stereo, no multichanneling (at least it is what I remember, maybe things have changed). If you want to do multi channeling with ASIO, you should install (at your own risk) the KX driver: http://kxproject.lugosoft.com If you want an even lower latency (in the order of 5 ms) and reliability I suggest a professional audio interface (I have a MOTU 828 firewire that works very well with my laptop, but I was told that the best, concerning latency, are the RME Hammerfall interfaces). Notice that Windows is one of the worst OSs for reliable realtime tasks. You should be sure that your audio interface doesn't share IRQ with other devices for the maximum of reliability. Unfortunately this is not always possible with Windows-based laptops. good luck! Gabriel Gabriel Maldonado http://csounds.com/maldonado