Using
Prev | Part I. Csound 5 User's Guide | Next

## Using

Assuming that you have installed and configured the software, Csound and CsoundVST can be operated in a variety of modes and configurations. The `.csd` and `.py` files in the `examples` directory demonstrate a few of these modes of operation. Some of these scores are simple, others are moderately complex.

You may need to edit the SoundFont file paths in instrument definitions that use the fluid SoundFont 2 player opcode to match your environment.

## Real-Time Audio

For real-time audio output, with or without MIDI control, you will probably want to tune the `kr` and `ksmps` orchestra statements, and the `-b` and `-B` command-line options, to give you the shortest possible latency that does not cause clicks or stutters in Csound's audio output.

In general, `-b` (Csound's audio buffer) should be set to a small power of 2 (such as 64 or 128), and `-B` (the audio driver's buffer) should be set to 2 or 4 times that.

Currently, with `-B` set to 512, audio output latency is about 12 milliseconds, fast enough for reasonably responsive keyboad playing.

Even shorter latencies, as low as 3 milliseconds on some systems, are feasible.

### Windows with ASIO

If your sound card does not have an ASIO driver, you can still use Csound with ASIO by downloading and installing the asio4all adapter from http://www.asio4all.com.

### Using Csound5 with JACK

#### Command line options

To enable the JACK plugin, use this command line option:

    	      -+rtaudio=jack

Additionally, there are some command line options specific to JACK:

JACK Command-line Flags

-+jack_client=[client_name]

  The client name used by Csound, defaults to 'csound5'. If multiple instances of Csound connect to the JACK server, different client names need to be used to avoid name conflicts.

-+jack_inportname=[input port name prefix], -+jack_outportname=[output port name prefix]

  Name prefix of Csound JACK input/output ports; the default is 'input' and 'output'. The actual port name is the channel number appended to the name prefix. Example: with the above default settings, a stereo orchestra will create these ports in full duplex operation:

      		      csound5:input1              (record left)
      		      csound5:input2              (record right)
      		      csound5:output1             (playback left)
      		      csound5:output2             (playback right)

-+jack_sleep_time=[sleep time in microseconds]

  As of Csound version 5.01, this option is deprecated and ignored.

#### Connecting Csound to other JACK clients

By default, no connections are made (you need to use jack_connect, qjackctl, or a similar utility); however, the plugin can connect to ports specified as '-iadc:portname_prefix' or '-odac:portname_prefix', where portname_prefix is the full name of a port without a channel number, such as 'alsa_pcm:capture_' (for -i adc), or 'alsa_pcm:playback_' (for -o dac).

#### Notes on buffer sizes

Audio data is received from and sent to the JACK server by Csound using a ring buffer that is controlled by the -b and -B flags. -B is the total size of the buffer, while -b is the size of a single period. These values are rounded so that the total size is an integer multiple of, and greater than the period size. The difference of the Csound buffer and period size must be greater than or equal to the JACK period size.

If both -iadc and -odac are used at the same time, the -b option should be set to an integer multiple of ksmps.

An example of buffer settings for low latency on a fast system:

    	      jackd -d alsa -P -r 48000 -p 64 -n 4 -zt &
    	      csound -+rtaudio=jack -b 64 -B 256 [...]

with real time scheduling (as root):

    	      jackd -R -P 90 -d alsa -P -r 48000 -p 64 -n 2 -zt &
    	      csound --sched=80,90,10 -d -+rtaudio=jack -b 64 -B 192 [...]

To improve performance, use ksmps values like 32 and 64.

The sample rate of the orchestra must be the same as that of the JACK server.

Prev | Up | Next
CsoundVST | Home | Csound