| 1 | <section id="RealTimeJack"> |
| 2 | <title>Realtime I/O with JACK Connection Kit</title> |
| 3 | |
| 4 | <para> |
| 5 | Under a number of systems the JACK connection kit can be used for both |
| 6 | audio and MIDI input/output. JACK is available for Linux, Mac and Windows. For more details on this, see |
| 7 | </para> |
| 8 | <para><ulink url="http://jackaudio.org/faq">http://jackaudio.org/faq</ulink> |
| 9 | </para> |
| 10 | |
| 11 | <bridgehead>Scheduling</bridgehead> |
| 12 | <para> DO NOT |
| 13 | use "--sched" if you are using JACK for audio output. JACK controls |
| 14 | scheduling for the audio applications connected to it, and also tries |
| 15 | to run at the highest possible priority. If the "--sched" flag is |
| 16 | used, Csound and JACK will be competing rather than cooperating, |
| 17 | resulting in extremely poor performance. </para> |
| 18 | |
| 19 | <bridgehead>JACK Audio</bridgehead> |
| 20 | <para>The simplest way to use the JACK plugin enabling input and output is as follows: |
| 21 | <screen> |
| 22 | -+rtaudio=jack -i adc -o dac</screen> |
| 23 | Additionally, there are some command line options specific to JACK: |
| 24 | <variablelist> |
| 25 | <title>JACK Command-line Flags</title> |
| 26 | <varlistentry> |
| 27 | <term>-+jack_client=[client_name]</term> |
| 28 | <listitem> |
| 29 | <para> |
| 30 | The client name used by Csound, defaults to 'csound6'. |
| 31 | If multiple instances of Csound connect to the JACK server, |
| 32 | different client names need to be used to avoid name |
| 33 | conflicts. |
| 34 | </para> |
| 35 | </listitem> |
| 36 | </varlistentry> |
| 37 | <varlistentry> |
| 38 | <term>-+jack_inportname=[input port name prefix], -+jack_outportname=[output port name prefix] |
| 39 | </term> |
| 40 | <listitem> |
| 41 | <para> |
| 42 | Name prefix of Csound JACK input/output ports; the default is |
| 43 | 'input' and 'output'. The actual port name is the channel number |
| 44 | appended to the name prefix. |
| 45 | Example: with the above default settings, a stereo orchestra will |
| 46 | create these ports in full duplex operation: |
| 47 | <screen> |
| 48 | csound6:input1 (record left) |
| 49 | csound6:input2 (record right) |
| 50 | csound6:output1 (playback left) |
| 51 | csound6:output2 (playback right)</screen> |
| 52 | </para> |
| 53 | </listitem> |
| 54 | </varlistentry> |
| 55 | </variablelist> |
| 56 | </para> |
| 57 | <bridgehead>Connecting Csound to other JACK clients</bridgehead> |
| 58 | <para> |
| 59 | By default, connections are made to the first ports on the jack port list |
| 60 | (generally these default to system physical ports).The plugin can connect to |
| 61 | ports specified as names or numbers. |
| 62 | </para> |
| 63 | |
| 64 | <para> |
| 65 | As names: the port name prefix is used, e.g. "system:playback_", |
| 66 | "system:capture_", "alsa_pcm:playback_" or "alsa_pcm:capture_". |
| 67 | For example: -odac:system:playback_ (for output), -iadc:system:capture_. |
| 68 | The port name prefix excludes channel names. |
| 69 | </para> |
| 70 | |
| 71 | <para> |
| 72 | As numbers: the base port number is given, where the connection |
| 73 | is made to this and subsequent ports up to the number of channels. |
| 74 | For a base port number N we will have the connections as N+0, N+1, |
| 75 | ..., N+nchnls-1. For instance -odac2 with nchnls=1 will connect |
| 76 | outputs to ports 2 and 3. Ports are listed as in other input/output |
| 77 | backends. |
| 78 | </para> |
| 79 | |
| 80 | <para> |
| 81 | Note that ports can be prevented from autoconnecting by passing |
| 82 | -odac:null and -iadc:null, for output and input, respectively. Connections |
| 83 | can also be made manually using jack connection tools. |
| 84 | </para> |
| 85 | |
| 86 | <bridgehead>Notes on buffer sizes</bridgehead> |
| 87 | <para> |
| 88 | Audio data is received from and sent to the JACK server by Csound |
| 89 | using a ring buffer that is controlled by the -b and -B flags. |
| 90 | -B is the total size of the buffer, while -b is the size of a |
| 91 | single period. These values are rounded so that the total size is |
| 92 | an integer multiple of, and greater than the period size. |
| 93 | The difference of the Csound buffer and period size must be greater |
| 94 | than or equal to the JACK period size. |
| 95 | </para> |
| 96 | <para> |
| 97 | If both -iadc and -odac are used at the same time, the -b option |
| 98 | should be set to an integer multiple of ksmps. |
| 99 | </para> |
| 100 | <para> |
| 101 | An example of buffer settings for low latency on a fast Linux system: |
| 102 | <screen> |
| 103 | jackd -d alsa -P -r 48000 -p 64 -n 4 -zt & |
| 104 | csound -+rtaudio=jack -b 64 -B 256 [...]</screen> |
| 105 | To improve performance, use ksmps values like 32 and 64. |
| 106 | </para> |
| 107 | <para> |
| 108 | The sample rate of the orchestra must be the same as that of the |
| 109 | JACK server. |
| 110 | </para> |
| 111 | |
| 112 | <bridgehead>JACK Midi</bridgehead> |
| 113 | <para> |
| 114 | Jack can also be used for MIDI IO. For this -+rtmidi=jack is |
| 115 | needed. For input -M followed by the requested jack MIDI port name is |
| 116 | used to connect directly to an input stream. For output -Q |
| 117 | followed by the jack port name is used. |
| 118 | </para> |
| 119 | <para> |
| 120 | For example |
| 121 | <screen> |
| 122 | -+rtmidi=jack -Q UM-3:midi/capture_2</screen> |
| 123 | makes a conection from the Csound Midi port to the second Midi port of a Midi interface. |
| 124 | </para> |
| 125 | <para> |
| 126 | The options |
| 127 | -+jack_midi_inportname= and -+jack_midi_outportname= can be |
| 128 | used to rename Csound's MIDI IO ports. |
| 129 | </para> |
| 130 | |
| 131 | </section> |