https://wiki.archlinux.org/api.php?action=feedcontributions&user=Mrshpot&feedformat=atomArchWiki - User contributions [en]2024-03-28T11:52:29ZUser contributionsMediaWiki 1.41.0https://wiki.archlinux.org/index.php?title=JACK_Audio_Connection_Kit&diff=536792JACK Audio Connection Kit2018-08-22T15:57:07Z<p>Mrshpot: Fix filename of /etc/security/limits.d/99-realtime-privileges.conf</p>
<hr />
<div>[[Category:Sound]]<br />
[[fr:Jack]]<br />
[[ja:JACK Audio Connection Kit]]<br />
{{Related articles start}}<br />
{{Related|Professional audio}}<br />
{{Related articles end}}<br />
From [[Wikipedia:JACK Audio Connection Kit]]:<br />
:JACK Audio Connection Kit (or JACK; a recursive acronym) is a professional sound server daemon that provides real-time, low-latency connections for both audio and MIDI data between applications that implement its API. <br />
<br />
==Installation==<br />
In order for JACK to work properly, your user needs to be [[Users and groups#Group management|added]] to the {{ic|realtime}} group for access to higher ulimits defined in {{ic|/etc/security/limits.d/99-realtime-privileges.conf}} (provided by the {{Pkg|realtime-privileges}} package), which is needed for realtime audio processing.<br />
{{Note|You need to manually add your user to the {{ic|realtime}} group even if you're using logind, since logind just handles access to direct hardware.}}<br />
<br />
There are two JACK implementations, see [https://github.com/jackaudio/jackaudio.github.com/wiki/Q_difference_jack1_jack2 this comparison] for the difference between the two. In short, Jack 1 and Jack 2 are equivalent implementations of the same protocol. Programs compiled against Jack 1 will work with Jack 2 without recompile (and vice versa). <br />
<br />
===JACK2===<br />
'''JACK2''' is a C++ implementation with SMP support. [[Install]] it with the {{Pkg|jack2}} package. If you are on a 64-bit installation and need to run 32-bit applications that require JACK, also install the {{Pkg|lib32-jack2}} package from the [[multilib]] repository.<br />
<br />
====JACK2 D-Bus====<br />
JACK2 with [[D-Bus]] can be installed via {{Pkg|jack2-dbus}}. It is the same as the {{Pkg|jack2}} package but does not provide the legacy "jackd" server.<br />
<br />
It is controlled by the {{ic|jack_control}} utility. The jack_control utility requires you to also install the {{pkg|python2-dbus}} package as well.<br />
<br />
The important commands are listed below:<br />
jack_control start - starts the jack server<br />
jack_control stop - stops the jack server<br />
jack_control ds alsa - selects alsa as the driver (backend)<br />
jack_control eps realtime True - set engine parameters, such as realtime<br />
jack_control dps period 256 - set the driver parameter period to 256<br />
<br />
===JACK===<br />
'''JACK''' uses a C API and supports more than one soundcard on Linux (plus MIDI). [[Install]] it with the {{pkg|jack}} package. If you are on a 64-bit installation and need to run 32-bit applications that require JACK, also install the {{Pkg|lib32-jack}} package from the [[multilib]] repository.<br />
<br />
===GUI===<br />
<br />
* {{App|Cadence|Set of tools useful for audio production. It performs system checks, manages JACK, calls other tools and make system tweaks.|https://kxstudio.linuxaudio.org/Applications:Cadence|{{Pkg|cadence}}}}<br />
* {{App|Patchage|Modular patch bay for audio and MIDI systems based on JACK and ALSA.|https://drobilla.net/software/patchage|{{Pkg|patchage}}}}<br />
* {{App|PatchMatrix|JACK patch bay in flow matrix style.|https://git.open-music-kontrollers.ch/lad/patchmatrix/about/|{{Pkg|patchmatrix}}}}<br />
* {{App|[[Wikipedia:Qjackctl|QjackCtl]]|Simple Qt application to control the JACK sound server daemon.|https://qjackctl.sourceforge.io/|{{Pkg|qjackctl}}}}<br />
<br />
==Basic Configuration==<br />
<br />
===Overview===<br />
The right configuration for your hardware and application needs depends on several factors. Your sound card and CPU will heavily affect how low of latency you can achieve when using JACK.<br />
<br />
The mainline Linux kernel now supports realtime scheduling, so using a patched kernel is no longer necessary. However, {{AUR|linux-rt}} in the AUR is a patched kernel that has some extra patches that can help to get lower latencies.<br />
<br />
===A shell-based example setup===<br />
The D-Bus edition of JACK2 can make startup much easier. Formerly, QjackCtl was used to start it, or a daemonizer was used, or some other method. But using {{Pkg|jack2-dbus}}, JACK2 can be easily started and configured via a shell script.<br />
<br />
Create a shell script that can be executed at X login:<br />
<br />
{{hc|start_jack.sh|<br />
#!/bin/bash<br />
<br />
jack_control start<br />
jack_control ds alsa<br />
jack_control dps device hw:HD2<br />
jack_control dps rate 48000<br />
jack_control dps nperiods 2<br />
jack_control dps period 64<br />
sleep 10<br />
a2jmidid -e &<br />
sleep 10<br />
qjackctl &<br />
}}<br />
<br />
The above will start a working JACK instance which other programs can then utilize. Details of each line follow. When discovering your own best configuration, it is helpful to do trial and error using QjackCtl's GUI with a non-D-Bus JACK2 version.<br />
<br />
====Details of the shell-based example setup====<br />
<br />
jack_control start<br />
Starts JACK if it is not already started.<br />
jack_control ds alsa<br />
Sets JACK to use the ALSA driver set.<br />
jack_control dps device hw:HD2<br />
Sets JACK to use ALSA-compatible sound card named HD2. One can find the names with {{ic|cat /proc/asound/cards}}. Most ALSA tutorials and default configurations use card numbers, but this can get confusing when external MIDI devices are in use; names make it easier.<br />
jack_control dps rate 48000<br />
Sets JACK to use 48000 khz sampling. Happens to work very well with this card. Some cards only do 44100, many will go much higher. The higher you go, the lower your latency, but the better your card and your CPU have to be, and software has to support this as well.<br />
jack_control dps nperiods 2<br />
Sets JACK to use 2 periods. 2 is right for motherboard, PCI, PCI-X, etc.; 3 for USB.<br />
jack_control dps period 64<br />
Sets JACK to use 64 periods per frame. Lower is less latency, but the setting in this script gives 2.67 ms latency, which is nicely low without putting too much stress on the particular hardware this example was built for. If a USB sound system were in use it might be good to try 32. Anything less than 3-4 ms should be fine for realtime synthesis and/or FX, 5 ms is the smallest a human being can detect. QjackCtl will tell you how you are doing; at no-load, which means no clients attached, you will want a max of 3-5% CPU usage, and if you cannot get that without xruns (the red numbers which mean the system cannot keep up with the demands), you will have to improve your hardware.<br />
sleep 10<br />
Wait for the above to settle.<br />
a2jmidid -e &<br />
Start the ALSA-to-JACK MIDI bridge. Good for mixing in applications which take MIDI input through ALSA but not JACK.<br />
sleep 10<br />
Wait for the above to settle.<br />
qjackctl &<br />
Load QjackCtl. GUI configuration tells it to run in the system tray. It will pick up the JACK session started by D-Bus just fine, and very smoothly too. It maintains the patchbay, the connections between these applications and any other JACK-enabled apps to be started manually. The patchbay is set up using manual GUI, but connections pre-configured in the patchbay are automatically created by QjackCtl itself when apps are started.<br />
<br />
===A GUI-based example setup===<br />
This example setup utilizes a more GUI focused configuration and management of JACK<br />
<br />
* Install {{Pkg|jack2-dbus}}.<br />
* Install {{Pkg|qjackctl}}, and tell your GUI window/desktop system to run it at startup.<br />
* Make sure QjackCtl is told to:<br />
** use the D-Bus interface,<br />
** run at startup,<br />
** save its configuration to the default location,<br />
** start the JACK audio server on application startup,<br />
** enable the system tray icon, and<br />
** start minimized to system tray.<br />
* Reboot.<br />
* After logging in, you will see QjackCtl in your system tray. Left-click on it.<br />
* Tweak settings in the QjackCtl GUI to lower latency. The Frame Size, Frame Buffer, and Bitrate settings all affect latency. Larger frame sizes lower latency, lower frame buffers lower latency, and higher bitrate settings lower latency, but all increase load on the sound card and your CPU. A Latency of about ~5ms is desirable for direct monitoring of instruments or microphones, as the latency begins to become perceptible at higher latencies.<br />
<br />
===Playing nice with ALSA===<br />
To allow Alsa programs to play while jack is running you must install the jack plugin for alsa with {{Pkg|alsa-plugins}}.<br />
<br />
And enable it by editing (or creating) /etc/asound.conf (system wide settings) to have these lines:<br />
{{bc|<nowiki><br />
# convert alsa API over jack API<br />
# use it with<br />
# % aplay foo.wav<br />
<br />
# use this as default<br />
pcm.!default {<br />
type plug<br />
slave { pcm "jack" }<br />
}<br />
<br />
ctl.mixer0 {<br />
type hw<br />
card 1<br />
}<br />
<br />
# pcm type jack<br />
pcm.jack {<br />
type jack<br />
playback_ports {<br />
0 system:playback_1<br />
1 system:playback_2<br />
}<br />
capture_ports {<br />
0 system:capture_1<br />
1 system:capture_2<br />
}<br />
}</nowiki>}}<br />
<br />
You need not restart your computer or anything. Just edit the alsa config files, start up jack, and there you go...<br />
<br />
Remember to start it as a '''user'''. If you start it with {{ic|jackd}} -d alsa" as user X, it will not work for user Y.<br />
<br />
Another approach, using ALSA loopback device (more complex but probably more robust), is described in [http://alsa.opensrc.org/Jack_and_Loopback_device_as_Alsa-to-Jack_bridge this article].<br />
<br />
=== GStreamer ===<br />
<br />
GStreamer requires the {{pkg|gst-plugins-good}} package to work with JACK, which contains the jackaudiosink plugin that adds JACK playback support.<br />
<br />
Further information (outdated): http://jackaudio.org/faq/gstreamer_via_jack.html<br />
<br />
=== PulseAudio ===<br />
If you need to keep {{Pkg|pulseaudio}} installed (in the event it is required by other packages, like {{Pkg|gnome-settings-daemon}}), you may want to prevent it from spawning automatically with X and taking over from JACK.<br />
<br />
Edit {{ic|/etc/pulse/client.conf}}, uncomment "autospawn" and set it to "no":<br />
;autospawn = yes<br />
autospawn = no<br />
<br />
''If you want both to play along, see: [[PulseAudio/Examples#PulseAudio through JACK]]''<br />
<br />
=== Firewire ===<br />
In order to prevent ALSA from messing around with your firewire devices you have to blacklist all firewire related kernel modules. This also prevents PulseAudio from using firewire. Create the following file:<br />
<br />
{{hc|/etc/modprobe.d/alsa-no-jack.conf|<br />
blacklist snd-fireworks<br />
blacklist snd-bebob<br />
blacklist snd-oxfw<br />
blacklist snd-dice<br />
blacklist snd-firewire-digi00x<br />
blacklist snd-firewire-tascam<br />
blacklist snd-firewire-lib<br />
blacklist snd-firewire-transceiver<br />
blacklist snd-fireface<br />
blacklist snd-firewire-motu<br />
}}<br />
<br />
''The list of modules is the most recent available at the time of writing at [https://github.com/takaswie/snd-firewire-improve Alsa Firewire Improve Repository].''<br />
<br />
Now you can unload your loaded firewire modules or reboot.<br />
<br />
==MIDI==<br />
<br />
JACK can handle one soundcard very well, and an arbitrary number of MIDI devices (connected e.g. via USB).<br />
If you start JACK and want to use a MIDI keyboard or a synthesizer or some other pure MIDI device, you have to start JACK with a proper soundcard (one that actually outputs or inputs PCM sound).<br />
As soon you have done that, you can connect the MIDI device. E.g. with QjackCtl ({{pkg|qjackctl}}), you click on the connect button and you will find your device listed under JACK-MIDI or ALSA-MIDI, depending on the driver.<br />
<br />
For JACK-MIDI, you may want to set the '''MIDI Driver''' to '''seq''' or '''raw''' in QjackCtl ''Setup > Settings''. This should make your MIDI device appear under the ''MIDI'' tab. You can also change the name of the client (from a generic "midi_capture_1" to something more descriptive), if you enable ''Setup > Display > Enable client/port aliases'' and then ''Enable client/port aliases editing (rename)''.<br />
<br />
For ALSA-MIDI, make sure to turn on '''Enable ALSA Sequencer support''' in QjackCtl ''Setup > Misc''. This will add the ''ALSA'' tab in QjackCtl ''Connect'' window where your MIDI controller will show up.<br />
<br />
For bridging ALSA-MIDI to JACK-MIDI, you may consider using a2jmidid ({{Pkg|a2jmidid}}). The following command will export all available ALSA MIDI ports to JACK MIDI ports:<br />
$ a2jmidid -e<br />
They will be visible in QjackCtl under the ''MIDI'' tab labelled "a2j" client.<br />
You can automate starting of a2jmidid by adding to QjackCtl ''Setup > Options > Execute script after Startup'': {{ic|/usr/bin/a2jmidid -e &}}<br />
{{note|When connecting MIDI keyboard controllers in QjackCtl, make sure to ''Expand All'' first and connect the desired ''Output Ports'' (below the ''Readable Clients'') to the ''Input Ports'' (below the ''Writable Clients''). As a shortcut, if you select a writable client instead of individual ports as your destination, it should connect all its currently displayed output ports underneath.}}<br />
<br />
*'''Q:''' What is the difference between JACK-MIDI and ALSA-MIDI?<br />
*'''A:''' The former has improved timing and sample accurate MIDI event alignment. It extends or may even replace the latter but at this point they both co-exist.<br />
<br />
To install some M-Audio MIDI keyboards, you will need the firmware package {{AUR|midisport-firmware}} in the [[AUR]]. Also, the snd_usb_audio module has to be available.<br />
For more information about specific USB MIDI devices, see http://alsa.opensrc.org/USBMidiDevices.<br />
<br />
==Troubleshooting==<br />
==="Cannot lock down memory area (Cannot allocate memory)" message on startup===<br />
<br />
See [[Realtime process management#Configuring PAM]] and ensure that the user is in the {{ic|realtime}} [[group]].<br />
<br />
===jack2-dbus and qjackctl errors===<br />
Still having the "Cannot allocate memory" and/or "Cannot connect to server socket err = No such file or directory" error(s) when pressing qjackctl's start button (assuming that you have package jack2-dbus installed) ?<br />
<br />
Please delete {{ic|~/.jackdrc}}, {{ic|~/.config/jack/conf.xml}}, {{ic|~/.config/rncbc.org/QjackCtl.conf}}. Kill ''jackdbus'' and restart from scratch :)<br />
(Thanks to nedko)<br />
<br />
Also try running <br />
$ fuser /dev/snd/*<br />
and check the resulting PID's with<br />
$ ps ax | grep [PID here]<br />
This will hopefully show the conflicting programs.<br />
<br />
==="ALSA: cannot set channel count to 1 for capture" error in logs===<br />
Change ALSA input and output channels from 1 to 2<br />
<br />
===Crackling or pops in audio===<br />
Your CPU or sound card is too weak to handle your settings for JACK. Lower the bitrate, lower the frame size, and raise the frame period in small increments until crackling stops.<br />
<br />
===Problems with specific applications===<br />
====VLC - no audio after starting JACK====<br />
Run VLC and change the following menu options:<br />
* Tools > Preferences<br />
* Show settings: All<br />
* Audio > Output modules > Audio output module: JACK audio output<br />
* Audio > Output modules > JACK: Automatically connect to writable clients (enable)<br />
<br />
==See also==<br />
<br />
* [https://github.com/jackaudio/jackaudio.github.com/wiki/Q_difference_jack1_jack2 Differences between JACK 1 and JACK2]<br />
* [http://jackaudio.org/faq/ JACK FAQ]</div>Mrshpothttps://wiki.archlinux.org/index.php?title=Professional_audio&diff=536791Professional audio2018-08-22T15:56:26Z<p>Mrshpot: Updated info about the realtime (was 'audio') group, according to recent changes in Arch repos</p>
<hr />
<div>[[Category:Sound]]<br />
[[ja:プロオーディオ]]<br />
[[ru:Professional audio]]<br />
{{Related articles start}}<br />
{{Related|Sound system}}<br />
{{Related|envy24control}}<br />
{{Related articles end}}<br />
Modern Linux systems are more than capable of supporting your (semi-)professional audio needs. Latencies of 5ms down to even as low as 1ms can be achieved with good hardware and proper configuration.<br />
<br />
== Getting started ==<br />
<br />
Some of the major pro audio applications are already available from the official Arch Linux repositories. For anything which is not, you can either add a binary repository (see further down below) or if you prefer to compile, search the AUR. Nothing stops you from building directly off of upstream releases, but then you might as well run LFS.<br />
<br />
Start by installing [[JACK]]. See [[List of applications#Audio]] and [https://github.com/nodiscc/awesome-linuxaudio awesome-linuxaudio] for the available applications.<br />
<br />
=== System configuration ===<br />
You may want to consider the following often seen system optimizations:<br />
* Add yourself to the ''realtime'' [[group]].<br />
* Add the {{ic|threadirqs}} [[kernel parameter]].<br />
* Install {{AUR|linux-rt}} kernel.<br />
* Set the [[cpufreq]] governor to ''performance''.<br />
* Add ''noatime'' to [[fstab]] (see [[Improving performance#Mount options]]).<br />
<br />
Realtime configuration has mostly been automated. There is no longer any need to edit files like {{ic|/etc/security/limits.conf}} for realtime access. However, if you must change the settings, see {{ic|/etc/security/limits.d/99-realtime-privileges.conf}} and {{ic|/usr/lib/udev/rules.d/40-realtime-privileges.rules}} (these files are provided by {{pkg|realtime-privileges}}). Additionaly, you may want to increase the highest requested RTC interrupt frequency (default is 64 Hz) by [[systemd FAQ#How can I make a script start during the boot process?|running the following at boot]]:<br />
echo 2048 > /sys/class/rtc/rtc0/max_user_freq<br />
echo 2048 > /proc/sys/dev/hpet/max-user-freq<br />
<br />
By default, swap frequency defined by "swappiness" is set to 60. By reducing this number to 10, the system will wait much longer before trying to write to disk.<br />
Then, there is ''inotify'' which watches for changes to files and reports them to applications requesting this information. When working with lots of audio data, a lot of watches will need to be kept track of, so they will need to be increased.<br />
These two settings can be adjusted in {{ic|/etc/sysctl.d/99-sysctl.conf}}.<br />
vm.swappiness &#61; 10<br />
fs.inotify.max_user_watches &#61; 524288<br />
<br />
You may also want to maximize the PCI latency timer of the PCI sound card and raise the latency timer of all other PCI peripherals (default is 64).<br />
$ setpci -v -d *:* latency_timer&#61;'''b0'''<br />
$ setpci -v -s ''$SOUND_CARD_PCI_ID'' latency_timer&#61;'''ff''' # eg. SOUND_CARD_PCI_ID&#61;03:00.0 (see below)<br />
The SOUND_CARD_PCI_ID can be obtained like so:<br />
{{hc|$ lspci &#166; grep -i audio|<br />
'''03:00.0''' Multimedia audio controller: Creative Labs SB Audigy (rev 03)<br />
'''03:01.0''' Multimedia audio controller: VIA Technologies Inc. VT1720/24 [Envy24PT/HT] PCI Multi-Channel Audio Controller (rev 01)}}<br />
<br />
==== Checklist ====<br />
The steps below are mostly to double-check that you have a working multimedia system:<br />
* Have I set up sound properly? See [[ALSA]] or [[OSS]].<br />
<br />
$ speaker-test<br />
<br />
* Am I in the realtime group? See [[ALSA]] or [[OSS]].<br />
<br />
$ groups | grep realtime<br />
<br />
* Is PulseAudio, OSS or something else grabbing my device?<br />
<br />
$ lsof +c 0 /dev/snd/pcm* /dev/dsp*<br />
<br />
-OR-<br />
<br />
$ fuser -fv /dev/snd/pcm* /dev/dsp* <br />
<br />
* Is PAM-security and realtime working OK?<br />
<br />
See: [[Realtime for Users#PAM-enabled login]] (Pay special attention especially if you do not run KDM, GDM or Slim.)<br />
<br />
* Have I rebooted after having done all that?<br />
<br />
=== JACK ===<br />
<br />
The aim here is to find the best possible combination of buffer size and periods, given the hardware you have. '''Frames/Period = 256''' is a sane starter. For onboard and USB devices, try '''Periods/Buffer = 3'''. Commonly used values are: 256/3, 256/2, 128/3.<br />
<br />
Also, the sample rate must match the hardware sample rate. To check what sample and bit rates your device supports:<br />
$ cat /proc/asound/card0/codec#0<br />
Replace ''card0'' and ''codec#0'' depending on what you have. You will be looking for '''rates''' or ''VRA'' in '''Extended ID'''. A common sample rate across many of today's devices is '''48000 Hz'''. Others common rates include 44100 Hz and 96000 Hz.<br />
<br />
Almost always, when recording or sequencing with external gear is concerned, '''realtime''' is a must. Also, you may like to set maximum priority (at least 10 lower than system limits defined in {{ic|/etc/security/limits.d/99-realtime-privileges.conf}}); the highest is for the device itself).<br />
<br />
Start jack with the options you just found out:<br />
$ /usr/bin/jackd -R -P89 -dalsa -dhw:0 -r48000 -p256 -n3<br />
<br />
{{pkg|qjackctl}}, {{Pkg|cadence}} and {{pkg|patchage}} can all be used to as GUIs to monitor JACK's status and simplify its configuration . <br />
<br />
{{Note|Once you set up JACK, try different audio applications to test your configuration results. I spent days trying to troubleshoot JACK xrun issues with LMMS which in the end turned out to be the problem with the latter.}}<br />
<br />
''Further reading: [http://www.linux-magazine.com/content/download/63041/486886/version/1/file/JACK_Audio_Server.pdf Linux Magazine article]''<br />
<br />
==== FireWire ====<br />
<br />
{{Note|Nothing much is needed to be done as most things have been automated, especially with the introduction of the [https://ieee1394.wiki.kernel.org/articles/j/u/j/Juju_Migration_e8a6.html new FireWire stack], deprecation of HAL and more focus on [[udev]]. You should not need to edit device permissions, but if you suspect that your device may not be working due to such issues, see {{ic|/lib/udev/rules.d/60-ffado.rules}} and if needed, create and put your changes into {{ic|/etc/udev/rules.d/60-ffado.rules}}.}}<br />
<br />
JACK(2) is built against FFADO, you only need to install it with the {{Pkg|libffado}} package.<br />
<br />
To test whether you have any chances of getting FireWire devices to work:<br />
<br />
* Ensure the proper kernel modules are loaded:<br />
<br />
# modprobe firewire-core firewire-ohci<br />
<br />
* Is my chipset sane enough to initiate a device?<br />
<br />
http://www.ffado.org/?q=node/622<br />
<br />
* Is my chipset sane enough to make a device work to its capacity?<br />
<br />
We cannot say for sure, particularly for those based on Ricoh (cross-platform issue). Most of the time, your device will run fine, but on occasion you will be faced with funny quirks. For unlucky ones, you will be facing hell.<br />
<br />
{{Note|As stated by Takashi Sakamoto [http://mailman.alsa-project.org/pipermail/alsa-devel/2014-September/081731.html on the alsa-devel mailing list], if you use the FireWire backend with jackd, the DICE module is incompatible. If you see a line like this :<br />
Warning (dice_eap.cpp)[1811] read: No routes found. Base 0x7, offset 0x4000<br />
you need to disable the "snd_dice" module.}}<br />
<br />
==== Jack Flash ====<br />
<br />
If after getting jack setup you will find that Flash has no audio.<br />
<br />
In order to get flash to work with jack you will need to [[install]] the {{AUR|libflashsupport-jack}} package.<br />
<br />
You can also use more flexible method to allow Alsa programs (including Flash) play sound while jack is running:<br />
<br />
First you must install the jack plugin for Alsa by [[installing]] the {{Pkg|alsa-plugins}} package. Enable it by editing (or creating) {{Ic|/etc/asound.conf}} (system wide settings) to have these lines:<br />
<br />
{{Bc|<br />
# convert alsa API over jack API<br />
# use it with<br />
# % aplay foo.wav<br />
<br />
# use this as default<br />
pcm.!default {<br />
type plug<br />
slave { pcm "jack" }<br />
}<br />
<br />
ctl.mixer0 {<br />
type hw<br />
card 1<br />
}<br />
<br />
# pcm type jack<br />
pcm.jack {<br />
type jack<br />
playback_ports {<br />
0 system:playback_1<br />
1 system:playback_2<br />
}<br />
capture_ports {<br />
0 system:capture_1<br />
1 system:capture_2<br />
}<br />
}<br />
}}<br />
<br />
You do not need to restart your computer or anything. Just edit the alsa config files, start up jack.<br />
<br />
==== Quickscan JACK script ====<br />
<br />
Most people will probably want to run JACK in realtime mode, there are however a lot of knobs and buttons to press in order for that to happen.<br />
<br />
A great way to quickly diagnose your system and find out what it is missing in order to have JACK work properly in real time mode is to run the Quickscan script. <br />
<br />
https://github.com/raboof/realtimeconfigquickscan/blob/master/realTimeConfigQuickScan.pl<br />
<br />
The output should tell you where your system is lacking and will point you to places to find more information.<br />
<br />
==== Desktop Effects vs JACK ====<br />
<br />
In addition to the factors listed under the System Configuration section above as well as the settings checked by realTimeConfigQuickScan.pl, it is also worth noting that desktop environments can cause xruns and hence JACK audio glitches, especially memory/process intensive ones and those desktops that utilize composited desktop effects. It is recommended you disable desktop effects when using JACK. You are likely to get the least xruns and best performance by running a lightweight desktop or just a window manager instead.<br />
<br />
==== A general example ====<br />
<br />
A general configuration example is [[JACK Audio Connection Kit#A shell-based example setup]].<br />
<br />
== Realtime kernel ==<br />
<br />
Since a while ago, the stock Linux kernel has proven to be adequate for realtime uses. The stock kernel (with {{Ic|CONFIG_PREEMPT&#61;y}}, default in Arch) can operate with a worst case latency of [https://rt.wiki.kernel.org/index.php/Frequently_Asked_Questions#What_are_real-time_capabilities_of_the_stock_2.6_linux_kernel.3F upto 10ms] (time between the moment an interrupt occurs in hardware, and the moment the corresponding interrupt-thread gets running), although some device drivers can introduce latency much worse than that. So depending on your hardware and driver (and requirement), you might want a kernel with hard realtime capabilities.<br />
<br />
The [https://rt.wiki.kernel.org/index.php/RT_PREEMPT_HOWTO RT_PREEPMT] patch by Ingo Molnar and Thomas Gleixner is an interesting option for hard and firm realtime applications, reaching from professional audio to industrial control. <br />
Most audio-specific distro Linux ships with this patch applied. A realtime-preemptible kernel will also make it possible to tweak priorities of IRQ handling threads and help ensure smooth audio almost regardless of the load.<br />
<br />
If you are going to compile your own kernel, remember that removing modules/options does not equate to a "leaner and meaner" kernel. It is true that the size of the kernel image is reduced, but in today's systems it is not as much of an issue as it was back in '''1995'''. <br />
<br />
In any way, you should also ensure that:<br />
* '''Timer Frequency''' is set to '''1000Hz''' (CONFIG_HZ_1000=y; if you do not do ''MIDI'' you can ignore this)<br />
* '''APM''' is '''DISABLED''' (CONFIG_APM=n; Troublesome with some hardware - default in x86_64)<br />
<br />
If you truly want a slim system, we suggest you go your own way and deploy one with ''static /devs''. You should, however, set your CPU architecture. Selecting "Core 2 Duo" for appropriate hardware will allow for a good deal of optimisation, but not so much as you go down the scale.<br />
<br />
General issue(s) with (realtime) kernels:<br />
<br />
* Hyperthreading (if you suspect, disable in BIOS)<br />
<br />
There are ready-to-run/compile patched kernels available in the ABS and AUR.<br />
<br />
{{note|Before you decide to use a patched kernel, see [http://jackaudio.org/faq/realtime_vs_realtime_kernel.html http://jackaudio.org/faq/realtime_vs_realtime_kernel.html].}}<br />
<br />
=== AUR ===<br />
<br />
From the [[AUR]] itself, you have the following options:<br />
<br />
* {{AUR|linux-rt}}<br />
* {{AUR|linux-rt-lts}} (Long Term Support, stable release)<br />
<br />
The first two are standard kernels with the CONFIG_PREEMPT_RT patch, while -ice includes patches some may consider to be nasty, while to others are a blessing.<br />
:''See: [https://rt.wiki.kernel.org/ Real-Time Linux Wiki]''<br />
<br />
==== Binaries ====<br />
<br />
Some users provide binaries for the AUR packages above in [[Unofficial user repositories]]:<br />
<br />
* [https://www.suruatoel.xyz/arch coderkun-aur-audio]<br />
<br />
== MIDI ==<br />
To decrease MIDI jitter when using external MIDI equipment jack2's -Xalsarawmidi option should be used. When doing this you need to use a2jmidid, too.<br />
<br />
With [https://github.com/koppi/alsa-midi-latency-test alsa-midi-latency-test] you could test how much jitter you get. PCI and PCIe cards are usually much better than USB MIDI devices.<br />
<br />
To work with MIDI, it is highly recommended that you install a2j ({{Pkg|a2jmidid}}), a bridge between alsa midi and jack midi. It allows you to connect applications that only communicate with alsa midi to applications that only use jack midi. Laditray can also start/stop a2j.<br />
:''See: [[JACK#MIDI]]''<br />
<br />
== Environment variables ==<br />
<br />
If you install things to non-standard directories, it is often necessary to set environment path variables so that applications know where to look (for plug-ins and other libraries). This usually affects only VST since users might have a Wine or external Windows location.<br />
<br />
We would usually not have Linux plug-ins (LADSPA, LV2, DSSI, LXVST) beyond standard paths, so it is not necessary to export them. But if you do, be sure to include those standard paths as well since Arch does not do anything for ''dssi'' or ''ladspa'', and some applications like ''dssi-vst'' will not look anywhere else if it finds predefined paths.<br />
<br />
{{hc|~/.bashrc|2=<br />
...<br />
export VST_PATH=/usr/lib/vst:/usr/local/lib/vst:~/.vst:/someother/custom/dir<br />
export LXVST_PATH=/usr/lib/lxvst:/usr/local/lib/lxvst:~/.lxvst:/someother/custom/dir<br />
export LADSPA_PATH=/usr/lib/ladspa:/usr/local/lib/ladspa:~/.ladspa:/someother/custom/dir<br />
export LV2_PATH=/usr/lib/lv2:/usr/local/lib/lv2:~/.lv2:/someother/custom/dir<br />
export DSSI_PATH=/usr/lib/dssi:/usr/local/lib/dssi:~/.dssi:/someother/custom/dir<br />
}}<br />
<br />
== Tips and tricks ==<br />
<br />
* Disable WiFi and close any programs that don't need to be open when recording such as browsers. Many have reported disabling WiFi has led to more reliable JACK performance.<br />
<br />
* Some USB audio hardware is known not to work properly when plugged into USB 3 ports so try USB 2/1 ports instead. <br />
<br />
* IRQ issues can occur and cause problems. An example is video hardware reserving the bus, causing needless interrupts in the system I/O path. See discussion at [http://subversion.ffado.org/wiki/IrqPriorities FFADO IRQ Priorities How-To]. If you have a realtime or a recent kernel, you can use {{Pkg|rtirq}} to adjust priorities of IRQ handling threads.<br />
<br />
* Do not use the '''irqbalance''' daemon, or do so carefully [http://docs.redhat.com/docs/en-US/Red_Hat_Enterprise_MRG/1.3/html/Realtime_Tuning_Guide/sect-Realtime_Tuning_Guide-General_System_Tuning-Interrupt_and_Process_Binding.html].<br />
<br />
* If you need to use multiple audio devices with JACK2, the '''alsa_in''' and '''alsa_out''' utilities. can be used to have extra devices wrapped and show up as outputs in the JACK patchbay.<br />
<br />
* Some daemons/processes can unexpectedly cause '''xruns'''. If you do not need it - kill it. No questions asked.<br />
<br />
$ ls /var/run/daemons<br />
$ top # or htop, ps aux, whatever you are comfortable with<br />
$ killall -9 $processname<br />
# systemctl stop $daemonname<br />
<br />
* If you are facing a lot of ''xruns'' especially with {{Pkg|nvidia}}, disable your GPU throttling. This can be done via the card's control applet and for nvidia it is "prefer maximum performance" (thanks to a mail in LAU by Frank Kober).<br />
<br />
* You may like to read more on ALSA: http://www.volkerschatz.com/noise/alsa.html<br />
<br />
== Hardware ==<br />
The majority of sound cards and audio devices will work with no extra configuration or packages, simply set the sound card jack is using to them and restart.<br />
<br />
This is not true for all devices, and so special cases are also listed.<br />
<br />
=== M-Audio Delta 1010 ===<br />
<br />
The M-Audio Delta series cards are based on the VIA Ice1712 audio chipset.<br />
Cards using this chip require that you install the alsa-tools package, because <br />
it contains the [[envy24control]] program. [[Envy24control]] is a hardware level<br />
mixer/controller. You ''can'' use alsa-mixer but you will save yourself some<br />
hassle not to try it. Note that this section has no information on MIDI setup or<br />
usage. <br />
<br />
Open the mixer application:<br />
$ envy24control<br />
<br />
This application can be more than a bit confusing; see [[envy24control]] for guidance<br />
on its use. That said, here is a very simple working setup for multitracking with Ardour.<br />
<br />
# On the "Monitor Inputs" and "Monitor PCMs" tabs, set all monitor inputs and monitor PCM's to around 20.<br />
# On the "Patchbay / Router" tab, set all to PCM out.<br />
# On the "Hardware Settings" tab, verify that the Master Clock setting matches what is set in Qjackctl. If these do not match you will have xruns out of control!<br />
<br />
=== M-Audio Fast Track Pro ===<br />
<br />
The M-Audio Fast Track Pro is an USB 4x4 audio interface, working at 24bit/96kHz. Due to limitation of USB 1, this device requires additional setup to get access to all its features. Device works in one of two configuration:<br />
<br />
* Configuration 1, or "Class compliant mode" - with reduced functionality, only 16bit, 48kHz, analogue input (2 channels) and digital/analogue output (4 channels).<br />
* Configuration 2 - with access to all features of interface.<br />
<br />
Currently with stock kernel it runs in configuration 2, but if you want to make sure in what mode you are, you can check kernel log for entries:<br />
<br />
usb-audio: Fast Track Pro switching to config #2<br />
usb-audio: Fast Track Pro config OK<br />
<br />
The interface also needs extra step of cofiguration to switch modes. It is done using option {{ic|device_setup}} during module loading. The recommended way to setup the interface is using file in {{ic|modprobe.d}}:<br />
{{hc|/etc/modprobe.d/ftp.conf|2=<br />
options snd_usb_audio vid=0x763 pid=0x2012 device_setup=XXX index=YYY enable=1<br />
}}<br />
where {{ic|vid}} and {{ic|pid}} are vendor and product id for M-Audio Fast Track Pro, {{ic|index}} is desired device number and {{ic|device_setup}} is desired device setup. Possible values for {{ic|device_setup}} are:<br />
<br />
{| class="wikitable"<br />
|+ device modes<br />
! device_setup value !! bit depth !! frequency !! analog output !! digital output !! analog input !! digital input !! IO mode<br />
|-<br />
| 0x0 || 16 bit || 48kHz || + || + || + || + || 4x4<br />
|-<br />
| 0x9 || 24 bit || 48kHz || + || + || + || - || 2x4<br />
|-<br />
| 0x13 || 24 bit || 48kHz || + || + || - || + || 2x4<br />
|-<br />
| 0x5 || 24 bit || 96kHz || * || * || * || * || 2x0 or 0x2<br />
|}<br />
<br />
The 24 bit/96kHz mode is special: it provides all input/output, but you can open only one of 4 interfaces at a time. If you for example open output interface and then try to open second output or input interface, you will see error in kernel log:<br />
<br />
cannot submit datapipe for urb 0, error -28: not enough bandwidth<br />
<br />
which is perfectly normal, because this is USB 1 device and cannot provide enough bandwidth to support more than single (2 channel) destination/source of that quality at a time.<br />
<br />
Depending on the value of {{ic|index}} it will setup two devices: {{ic|hwYYY:0}} and {{ic|hwYYY:1}}, which will contain available inputs and outputs. First device is most likely to contain analog output and digital input, while second one will contain analog input and digital output. To find out which devices are linked where and if they are setup correctly, you can check {{ic|/proc/asound/cardYYY/stream{0,1} }}. Below is list of important endpoints that will help in correctly identifying card connections (it easy to mistake analog and digital input or output connections before you get used to the device):<br />
<br />
EP 3 (analgoue output = TRS on back, mirrored on RCA outputs 1 and 2 on back)<br />
EP 4 (digital output = S/PDIF output on back, mirrored on RCA outputs 3 and 4 on back)<br />
EP 5 (analogue input = balanced TRS or XLR microphone, unbalanced TS line on front)<br />
EP 6 (digital input = S/PDIF input on back)<br />
<br />
This .asoundrc file enables 24-bit IO on the fast-track pro (and I'm sure it could be modified to work with other 3-byte usb devices) within the context of jack's 32-bit interface while routing default alsa traffic to jack outputs on the audio interface. Alsa will be in S24_3BE mode but jack can plug S32_LE data in and out of the interface and other alsa programs will be able to plug almost anything into jack.<br />
<br />
{{bc|<nowiki><br />
### ~/.asoundrc<br />
### default alsa config file, for a fast-track pro configured in 24-bit mode as so:<br />
### options snd_usb_audio device_setup=0x9<br />
### invoke jack with: (if you use -r48000, change the rate in the plugs as well)<br />
### $jackd -dalsa -P"hw:Pro" -C"hw:Pro,1" -r44100<br />
<br />
## setup input and output plugs so jack can write S24_3BE data to the audio interface<br />
<br />
pcm.maud0 {<br />
type hw<br />
card Pro<br />
}<br />
<br />
#jack_out plug makes sure that S32_LE data can be written to hw:Pro<br />
pcm.jack_out{<br />
type plug<br />
format S32_LE<br />
channels 2<br />
rate 44100<br />
slave pcm.maud0<br />
}<br />
<br />
pcm.maud1 {<br />
type hw<br />
card Pro<br />
device 1<br />
}<br />
## jack_in plug makes sure that hw:Pro,1 can read S32_LE data<br />
pcm.jack_in {<br />
type plug<br />
format S32_LE<br />
channels 2<br />
rate 44100<br />
slave pcm.maud1<br />
}<br />
#####<br />
# route default alsa traffic through jack system io<br />
<br />
pcm.jack {<br />
type jack<br />
playback_ports {<br />
0 system:playback_1<br />
1 system:playback_2<br />
}<br />
capture_ports {<br />
0 system:capture_1<br />
1 system:capture_2<br />
}<br />
} <br />
pcm.amix {<br />
type asym<br />
playback.pcm "jack"<br />
capture.pcm "jack"<br />
}<br />
pcm.!default {<br />
type plug<br />
slave.pcm amix<br />
}<br />
</nowiki>}}<br />
<br />
=== PreSonus Firepod ===<br />
<br />
#Startup: Either from command line or QjackCtl, the driver is called firewire.<br />
#Specs: The card contains 8/8 preamp'ed XLR plus a stereo pair, in total 10 channels.<br />
#Linking: Cards can be linked together without any problems.<br />
#Hardware Settings: Nothing particular, tweak the settings in QjackCtl to your likings.<br />
<br />
Volume levels are hardware and routing can be done through QjackCtl, even with more cards linked together, this is not a problem.<br />
The ffadomixer does not work with this card yet, hopefully in the future we can control more aspects of the card through a software interface like that.<br />
<br />
=== PreSonus AudioBox USB ===<br />
<br />
#Startup: It is called "USB" by ALSA. <br />
#Specs: Two mono TRS+XLR in, two mono TRS out, MIDI in and out, plus separate stereo headphone jack. Knob controls for both inputs, for main out, and for headphone, four in all.<br />
#Hardware: Works very well, audio and MIDI too. No software mixer controls at all.<br />
<br />
===Tascam US-122===<br />
'''''This does not apply to the US-122L'''''<br />
<br />
# Required packages: {{Pkg|alsa-tools}} {{Pkg|alsa-firmware}} {{Aur|fxload}}<br />
# udev rules: create the following rules file, then reload udev rules, [[Udev#Loading new rules]]<br />
{{hc|/etc/udev/rules.d/51-tascam-us-122.rules|<nowiki>SUBSYSTEMS=="usb", ACTION=="add", ATTRS{idProduct}=="8006", ATTRS{idVendor}=="1604", RUN+="/bin/sh -c '/sbin/fxload -D %N -s /usr/share/alsa/firmware/usx2yloader/tascam_loader.ihx -I /usr/share/alsa/firmware/usx2yloader/us122fw.ihx'"<br />
SUBSYSTEMS=="usb", ACTION=="add", ATTRS{idProduct}=="8007", ATTRS{idVendor}=="1604", RUN+="/bin/sh -c '/usr/bin/usx2yloader'"</nowiki><br />
}}<br />
Plug in the unit<br />
The device should now be working, there are no software mixer controls<br />
<br />
=== RME Babyface ===<br />
<br />
It works very well at low latencies (~5ms) with {{Pkg|alsa-utils}}, {{Pkg|jack2}} and {{AUR|linux-rt}}. Running on ALSA only with the standard kernel may cause crackling at lower latencies.<br />
<br />
To be recognized and work, the firmware version of the Babyface needs to be >= 200, which introduces the Class Compliant Mode. To enter Class Compliant Mode hold the "Select" and "Recall" buttons while connecting the Babyface to the computer via USB. It should now be recognized. <br />
<br />
To check if it is recognized:<br />
<br />
grep -i baby /proc/asound/cards<br />
<br />
For more info about the Class Compliant Mode visit RME's website, they have PDF which covers all the functionality.<br />
<br />
The Babyface does not need any special Jack Settings. But if you want to use the built in MIDI In/Out then you need to set the "MIDI Driver" to "seq" and optionally disable "Enable Alsa Sequencer Support" to use it in combination with other MIDI Devices (a USB Midi Keyboard for example).<br />
<br />
== Restricted software ==<br />
<br />
=== Steinberg's SDKs ===<br />
<br />
It is very clear - we can distribute neither the VST nor the ASIO headers in '''binary package form'''. However, whenever you are building a program which would host Windows ''.dll'' VST plug-ins, check for the following hints (that do not require use of any SDK):<br />
<br />
* dssi-vst<br />
* fst<br />
* vestige<br />
<br />
With that said, if you are building a program which would host native ''.so'' VST plug-ins, then there is no escape. For such cases, Arch yet again allows us to maintain a uniform local software database. We can "install" the SDK ''system-wide'' - you simply have to download it yourself and place it in the packaging directory.<br />
<br />
[https://aur.archlinux.org/packages.php?O=0&K=steinberg-&do_Search=Go Get them from AUR]<br />
<br />
''Note: Steinberg does not forbid redistribution of resulting products, nor dictate what license they can be under. There are many GPL-licensed VST plug-ins. As such, distributing binary packages of software built with these restricted headers is '''not''' a problem, because the headers are simply '''buildtime dependencies'''.''<br />
<br />
== Arch Linux Pro Audio Project ==<br />
<br />
Yes, we have one. Think of "Planet CCRMA" or "Pro Audio Overlay", less the academic connotations of the former: [http://archaudio.org ArchAudio].<br />
<br />
What this means is that the repositories are add-ons, i.e you need to have a running, sane Arch Linux installation.<br />
<br />
It is a relatively new effort although the initiative has been around since<br />
2006/2007. <br />
<br />
History: https://bbs.archlinux.org/viewtopic.php?id=30547<br />
<br />
For all your Arch- and ArchAudio-related audio issues hop on to '''IRC''': #archaudio @ Freenode<br />
<br />
== Linux and Arch Linux Pro Audio in the news ==<br />
<br />
* [https://www.linux.com/learn/tutorials/607117-build-a-serious-multimedia-production-workstation-with-arch-linux Build a Serious Multimedia Production Workstation with Arch] - Linux.com article, July 2012<br />
* [http://www.linuxjournal.com/content/arch-tale An Arch Tale] - Article by fellow musician and writer Dave Phillips, October 2011<br />
* [http://www.itwire.com/opinion-and-analysis/open-sauce/36698-from-windows-to-linux-a-sound-decision From Windows to Linux: a sound decision] - Interview with Geoff "songshop" Beasley, February 2010<br />
<br />
== Mailing list ==<br />
<br />
* [https://lists.archlinux.org/listinfo/arch-proaudio Arch Linux Pro-audio] Discussion about real-time multimedia, including (semi-)pro audio and video<br />
* [https://lists.linuxaudio.org/listinfo/linux-audio-dev Linux Audio Developer] The Linux pro-audio related mailing list with much traffic and a huge subscriber community of mainly developers.<br />
* [https://lists.linuxaudio.org/listinfo/linux-audio-user Linux Audio User] The Linux pro-audio related mailing list with much traffic and a huge subscriber community of users and developers.<br />
<br />
== IRC ==<br />
<br />
* #archlinux-proaudio on freenode.net: Arch Linux pro-audio channel<br />
* #lau on freenode.net: General Linux Audio channel for users<br />
* #lad on freenode.net: General Linux AUdio channel for developers</div>Mrshpothttps://wiki.archlinux.org/index.php?title=JACK_Audio_Connection_Kit&diff=536770JACK Audio Connection Kit2018-08-22T11:47:25Z<p>Mrshpot: Updated info about the realtime (was 'audio') group, according to recent changes in Arch repos</p>
<hr />
<div>[[Category:Sound]]<br />
[[fr:Jack]]<br />
[[ja:JACK Audio Connection Kit]]<br />
{{Related articles start}}<br />
{{Related|Professional audio}}<br />
{{Related articles end}}<br />
From [[Wikipedia:JACK Audio Connection Kit]]:<br />
:JACK Audio Connection Kit (or JACK; a recursive acronym) is a professional sound server daemon that provides real-time, low-latency connections for both audio and MIDI data between applications that implement its API. <br />
<br />
==Installation==<br />
In order for JACK to work properly, your user needs to be [[Users and groups#Group management|added]] to the {{ic|realtime}} group for access to higher ulimits defined in {{ic|/etc/security/limits.d/99-audio.conf}} (provided by the {{Pkg|realtime-privileges}} package), which is needed for realtime audio processing.<br />
{{Note|You need to manually add your user to the {{ic|realtime}} group even if you're using logind, since logind just handles access to direct hardware.}}<br />
<br />
There are two JACK implementations, see [https://github.com/jackaudio/jackaudio.github.com/wiki/Q_difference_jack1_jack2 this comparison] for the difference between the two. In short, Jack 1 and Jack 2 are equivalent implementations of the same protocol. Programs compiled against Jack 1 will work with Jack 2 without recompile (and vice versa). <br />
<br />
===JACK2===<br />
'''JACK2''' is a C++ implementation with SMP support. [[Install]] it with the {{Pkg|jack2}} package. If you are on a 64-bit installation and need to run 32-bit applications that require JACK, also install the {{Pkg|lib32-jack2}} package from the [[multilib]] repository.<br />
<br />
====JACK2 D-Bus====<br />
JACK2 with [[D-Bus]] can be installed via {{Pkg|jack2-dbus}}. It is the same as the {{Pkg|jack2}} package but does not provide the legacy "jackd" server.<br />
<br />
It is controlled by the {{ic|jack_control}} utility. The jack_control utility requires you to also install the {{pkg|python2-dbus}} package as well.<br />
<br />
The important commands are listed below:<br />
jack_control start - starts the jack server<br />
jack_control stop - stops the jack server<br />
jack_control ds alsa - selects alsa as the driver (backend)<br />
jack_control eps realtime True - set engine parameters, such as realtime<br />
jack_control dps period 256 - set the driver parameter period to 256<br />
<br />
===JACK===<br />
'''JACK''' uses a C API and supports more than one soundcard on Linux (plus MIDI). [[Install]] it with the {{pkg|jack}} package. If you are on a 64-bit installation and need to run 32-bit applications that require JACK, also install the {{Pkg|lib32-jack}} package from the [[multilib]] repository.<br />
<br />
===GUI===<br />
<br />
* {{App|Cadence|Set of tools useful for audio production. It performs system checks, manages JACK, calls other tools and make system tweaks.|https://kxstudio.linuxaudio.org/Applications:Cadence|{{Pkg|cadence}}}}<br />
* {{App|Patchage|Modular patch bay for audio and MIDI systems based on JACK and ALSA.|https://drobilla.net/software/patchage|{{Pkg|patchage}}}}<br />
* {{App|PatchMatrix|JACK patch bay in flow matrix style.|https://git.open-music-kontrollers.ch/lad/patchmatrix/about/|{{Pkg|patchmatrix}}}}<br />
* {{App|[[Wikipedia:Qjackctl|QjackCtl]]|Simple Qt application to control the JACK sound server daemon.|https://qjackctl.sourceforge.io/|{{Pkg|qjackctl}}}}<br />
<br />
==Basic Configuration==<br />
<br />
===Overview===<br />
The right configuration for your hardware and application needs depends on several factors. Your sound card and CPU will heavily affect how low of latency you can achieve when using JACK.<br />
<br />
The mainline Linux kernel now supports realtime scheduling, so using a patched kernel is no longer necessary. However, {{AUR|linux-rt}} in the AUR is a patched kernel that has some extra patches that can help to get lower latencies.<br />
<br />
===A shell-based example setup===<br />
The D-Bus edition of JACK2 can make startup much easier. Formerly, QjackCtl was used to start it, or a daemonizer was used, or some other method. But using {{Pkg|jack2-dbus}}, JACK2 can be easily started and configured via a shell script.<br />
<br />
Create a shell script that can be executed at X login:<br />
<br />
{{hc|start_jack.sh|<br />
#!/bin/bash<br />
<br />
jack_control start<br />
jack_control ds alsa<br />
jack_control dps device hw:HD2<br />
jack_control dps rate 48000<br />
jack_control dps nperiods 2<br />
jack_control dps period 64<br />
sleep 10<br />
a2jmidid -e &<br />
sleep 10<br />
qjackctl &<br />
}}<br />
<br />
The above will start a working JACK instance which other programs can then utilize. Details of each line follow. When discovering your own best configuration, it is helpful to do trial and error using QjackCtl's GUI with a non-D-Bus JACK2 version.<br />
<br />
====Details of the shell-based example setup====<br />
<br />
jack_control start<br />
Starts JACK if it is not already started.<br />
jack_control ds alsa<br />
Sets JACK to use the ALSA driver set.<br />
jack_control dps device hw:HD2<br />
Sets JACK to use ALSA-compatible sound card named HD2. One can find the names with {{ic|cat /proc/asound/cards}}. Most ALSA tutorials and default configurations use card numbers, but this can get confusing when external MIDI devices are in use; names make it easier.<br />
jack_control dps rate 48000<br />
Sets JACK to use 48000 khz sampling. Happens to work very well with this card. Some cards only do 44100, many will go much higher. The higher you go, the lower your latency, but the better your card and your CPU have to be, and software has to support this as well.<br />
jack_control dps nperiods 2<br />
Sets JACK to use 2 periods. 2 is right for motherboard, PCI, PCI-X, etc.; 3 for USB.<br />
jack_control dps period 64<br />
Sets JACK to use 64 periods per frame. Lower is less latency, but the setting in this script gives 2.67 ms latency, which is nicely low without putting too much stress on the particular hardware this example was built for. If a USB sound system were in use it might be good to try 32. Anything less than 3-4 ms should be fine for realtime synthesis and/or FX, 5 ms is the smallest a human being can detect. QjackCtl will tell you how you are doing; at no-load, which means no clients attached, you will want a max of 3-5% CPU usage, and if you cannot get that without xruns (the red numbers which mean the system cannot keep up with the demands), you will have to improve your hardware.<br />
sleep 10<br />
Wait for the above to settle.<br />
a2jmidid -e &<br />
Start the ALSA-to-JACK MIDI bridge. Good for mixing in applications which take MIDI input through ALSA but not JACK.<br />
sleep 10<br />
Wait for the above to settle.<br />
qjackctl &<br />
Load QjackCtl. GUI configuration tells it to run in the system tray. It will pick up the JACK session started by D-Bus just fine, and very smoothly too. It maintains the patchbay, the connections between these applications and any other JACK-enabled apps to be started manually. The patchbay is set up using manual GUI, but connections pre-configured in the patchbay are automatically created by QjackCtl itself when apps are started.<br />
<br />
===A GUI-based example setup===<br />
This example setup utilizes a more GUI focused configuration and management of JACK<br />
<br />
* Install {{Pkg|jack2-dbus}}.<br />
* Install {{Pkg|qjackctl}}, and tell your GUI window/desktop system to run it at startup.<br />
* Make sure QjackCtl is told to:<br />
** use the D-Bus interface,<br />
** run at startup,<br />
** save its configuration to the default location,<br />
** start the JACK audio server on application startup,<br />
** enable the system tray icon, and<br />
** start minimized to system tray.<br />
* Reboot.<br />
* After logging in, you will see QjackCtl in your system tray. Left-click on it.<br />
* Tweak settings in the QjackCtl GUI to lower latency. The Frame Size, Frame Buffer, and Bitrate settings all affect latency. Larger frame sizes lower latency, lower frame buffers lower latency, and higher bitrate settings lower latency, but all increase load on the sound card and your CPU. A Latency of about ~5ms is desirable for direct monitoring of instruments or microphones, as the latency begins to become perceptible at higher latencies.<br />
<br />
===Playing nice with ALSA===<br />
To allow Alsa programs to play while jack is running you must install the jack plugin for alsa with {{Pkg|alsa-plugins}}.<br />
<br />
And enable it by editing (or creating) /etc/asound.conf (system wide settings) to have these lines:<br />
{{bc|<nowiki><br />
# convert alsa API over jack API<br />
# use it with<br />
# % aplay foo.wav<br />
<br />
# use this as default<br />
pcm.!default {<br />
type plug<br />
slave { pcm "jack" }<br />
}<br />
<br />
ctl.mixer0 {<br />
type hw<br />
card 1<br />
}<br />
<br />
# pcm type jack<br />
pcm.jack {<br />
type jack<br />
playback_ports {<br />
0 system:playback_1<br />
1 system:playback_2<br />
}<br />
capture_ports {<br />
0 system:capture_1<br />
1 system:capture_2<br />
}<br />
}</nowiki>}}<br />
<br />
You need not restart your computer or anything. Just edit the alsa config files, start up jack, and there you go...<br />
<br />
Remember to start it as a '''user'''. If you start it with {{ic|jackd}} -d alsa" as user X, it will not work for user Y.<br />
<br />
Another approach, using ALSA loopback device (more complex but probably more robust), is described in [http://alsa.opensrc.org/Jack_and_Loopback_device_as_Alsa-to-Jack_bridge this article].<br />
<br />
=== GStreamer ===<br />
<br />
GStreamer requires the {{pkg|gst-plugins-good}} package to work with JACK, which contains the jackaudiosink plugin that adds JACK playback support.<br />
<br />
Further information (outdated): http://jackaudio.org/faq/gstreamer_via_jack.html<br />
<br />
=== PulseAudio ===<br />
If you need to keep {{Pkg|pulseaudio}} installed (in the event it is required by other packages, like {{Pkg|gnome-settings-daemon}}), you may want to prevent it from spawning automatically with X and taking over from JACK.<br />
<br />
Edit {{ic|/etc/pulse/client.conf}}, uncomment "autospawn" and set it to "no":<br />
;autospawn = yes<br />
autospawn = no<br />
<br />
''If you want both to play along, see: [[PulseAudio/Examples#PulseAudio through JACK]]''<br />
<br />
=== Firewire ===<br />
In order to prevent ALSA from messing around with your firewire devices you have to blacklist all firewire related kernel modules. This also prevents PulseAudio from using firewire. Create the following file:<br />
<br />
{{hc|/etc/modprobe.d/alsa-no-jack.conf|<br />
blacklist snd-fireworks<br />
blacklist snd-bebob<br />
blacklist snd-oxfw<br />
blacklist snd-dice<br />
blacklist snd-firewire-digi00x<br />
blacklist snd-firewire-tascam<br />
blacklist snd-firewire-lib<br />
blacklist snd-firewire-transceiver<br />
blacklist snd-fireface<br />
blacklist snd-firewire-motu<br />
}}<br />
<br />
''The list of modules is the most recent available at the time of writing at [https://github.com/takaswie/snd-firewire-improve Alsa Firewire Improve Repository].''<br />
<br />
Now you can unload your loaded firewire modules or reboot.<br />
<br />
==MIDI==<br />
<br />
JACK can handle one soundcard very well, and an arbitrary number of MIDI devices (connected e.g. via USB).<br />
If you start JACK and want to use a MIDI keyboard or a synthesizer or some other pure MIDI device, you have to start JACK with a proper soundcard (one that actually outputs or inputs PCM sound).<br />
As soon you have done that, you can connect the MIDI device. E.g. with QjackCtl ({{pkg|qjackctl}}), you click on the connect button and you will find your device listed under JACK-MIDI or ALSA-MIDI, depending on the driver.<br />
<br />
For JACK-MIDI, you may want to set the '''MIDI Driver''' to '''seq''' or '''raw''' in QjackCtl ''Setup > Settings''. This should make your MIDI device appear under the ''MIDI'' tab. You can also change the name of the client (from a generic "midi_capture_1" to something more descriptive), if you enable ''Setup > Display > Enable client/port aliases'' and then ''Enable client/port aliases editing (rename)''.<br />
<br />
For ALSA-MIDI, make sure to turn on '''Enable ALSA Sequencer support''' in QjackCtl ''Setup > Misc''. This will add the ''ALSA'' tab in QjackCtl ''Connect'' window where your MIDI controller will show up.<br />
<br />
For bridging ALSA-MIDI to JACK-MIDI, you may consider using a2jmidid ({{Pkg|a2jmidid}}). The following command will export all available ALSA MIDI ports to JACK MIDI ports:<br />
$ a2jmidid -e<br />
They will be visible in QjackCtl under the ''MIDI'' tab labelled "a2j" client.<br />
You can automate starting of a2jmidid by adding to QjackCtl ''Setup > Options > Execute script after Startup'': {{ic|/usr/bin/a2jmidid -e &}}<br />
{{note|When connecting MIDI keyboard controllers in QjackCtl, make sure to ''Expand All'' first and connect the desired ''Output Ports'' (below the ''Readable Clients'') to the ''Input Ports'' (below the ''Writable Clients''). As a shortcut, if you select a writable client instead of individual ports as your destination, it should connect all its currently displayed output ports underneath.}}<br />
<br />
*'''Q:''' What is the difference between JACK-MIDI and ALSA-MIDI?<br />
*'''A:''' The former has improved timing and sample accurate MIDI event alignment. It extends or may even replace the latter but at this point they both co-exist.<br />
<br />
To install some M-Audio MIDI keyboards, you will need the firmware package {{AUR|midisport-firmware}} in the [[AUR]]. Also, the snd_usb_audio module has to be available.<br />
For more information about specific USB MIDI devices, see http://alsa.opensrc.org/USBMidiDevices.<br />
<br />
==Troubleshooting==<br />
==="Cannot lock down memory area (Cannot allocate memory)" message on startup===<br />
<br />
See [[Realtime process management#Configuring PAM]] and ensure that the user is in the {{ic|realtime}} [[group]].<br />
<br />
===jack2-dbus and qjackctl errors===<br />
Still having the "Cannot allocate memory" and/or "Cannot connect to server socket err = No such file or directory" error(s) when pressing qjackctl's start button (assuming that you have package jack2-dbus installed) ?<br />
<br />
Please delete {{ic|~/.jackdrc}}, {{ic|~/.config/jack/conf.xml}}, {{ic|~/.config/rncbc.org/QjackCtl.conf}}. Kill ''jackdbus'' and restart from scratch :)<br />
(Thanks to nedko)<br />
<br />
Also try running <br />
$ fuser /dev/snd/*<br />
and check the resulting PID's with<br />
$ ps ax | grep [PID here]<br />
This will hopefully show the conflicting programs.<br />
<br />
==="ALSA: cannot set channel count to 1 for capture" error in logs===<br />
Change ALSA input and output channels from 1 to 2<br />
<br />
===Crackling or pops in audio===<br />
Your CPU or sound card is too weak to handle your settings for JACK. Lower the bitrate, lower the frame size, and raise the frame period in small increments until crackling stops.<br />
<br />
===Problems with specific applications===<br />
====VLC - no audio after starting JACK====<br />
Run VLC and change the following menu options:<br />
* Tools > Preferences<br />
* Show settings: All<br />
* Audio > Output modules > Audio output module: JACK audio output<br />
* Audio > Output modules > JACK: Automatically connect to writable clients (enable)<br />
<br />
==See also==<br />
<br />
* [https://github.com/jackaudio/jackaudio.github.com/wiki/Q_difference_jack1_jack2 Differences between JACK 1 and JACK2]<br />
* [http://jackaudio.org/faq/ JACK FAQ]</div>Mrshpot