Introducció al Jack

De wikijoan
Salta a la navegació Salta a la cerca

What is JACK?

Have you ever wanted to take the audio output of one piece of software and send it to another? How about taking the output of that same program and send it to two others, then record the result in the first program? Or maybe you're a programmer who writes real-time audio and music applications and who is looking for a cross-platform API that enables not only device sharing but also inter-application audio routing, and is incredibly easy to learn and use? If so, JACK may be what you've been looking for.

JACK is system for handling real-time, low latency audio (and MIDI). It runs on GNU/Linux, Solaris, FreeBSD, OS X and Windows (and can be ported to other POSIX-conformant platforms). It can connect a number of different applications to an audio device, as well as allowing them to share audio between themselves. Its clients can run in their own processes (ie. as normal applications), or can they can run within the JACK server (ie. as a "plugin"). JACK also has support for distributing audio processing across a network, both fast & reliable LANs as well as slower, less reliable WANs.

JACK was designed from the ground up for professional audio work, and its design focuses on two key areas: synchronous execution of all clients, and low latency operation. More background information is available.

JACK is a system for sending audio between applications as well as allowing them to all share an audio interface. Each application is run in exact sample sync with each other, and the entire system is designed to run at very low latencies (as low as your hardware will allow).

JACK vs ALSA

ALSA: both a HAL (Hardware Abstraction Layer) and a user-space library for audio under Linux. ALSA is used to provide the default audio i/o driver for JACK. ALSA is a very powerful audio API, but it does not provide a callback-based API or offer any solutions for inter-application communication, though it has been discussed and is theoretically possible.

MidiShare proporciona un driver ALSA, que permet que MidiShare sigui reconegut per dispositius físics. Quan treballo amb JACK, el driver per defecte és el d'ALSA. Com que MidiShare proporciona un driver ALSA, els meus clients MidiShare es poden comunicar i connectar amb altres aplicacions.

Llegir també:

Doesn't use JACK add latency?

There is NO extra latency caused by using JACK for audio input and output. When we say none, we mean absolutely zero. The only impact of using JACK is a slight increase in the amount of work done by the CPU to process a given chunk of audio, which means that in theory you could not get 100% of the processing power that you might get it if your application(s) used ALSA or CoreAudio directly. However, given that the difference is less than 1%, and that your system will be unstable before you get close to 80% of the theoretical processing power, the effect is completely disregardable.

How do I install JACK?

Prerequisites

   * 2.4, 2.5 or 2.6 series kernel with tmpfs turned on (CONFIG_TMPFS)
   * Shared memory file system mounted on /dev/shm. add the following to /etc/fstab to get it mounted at boot:
      	shmfs       /dev/shm     shm    defaults        0       0

(Note: you may have to make the /dev/shm directory)

Once you have the correct shmfs support, you should be able to build jack with the following sequence of commands:

sh ./autogen.sh
./configure
make
make install

Good luck!

JACK, jackd, libjack, jackit, wha?

There is a profusion of names surrounding the JACK project, and hopefully this will help clear things up.

JACK

JACK is the name of the whole system. It may be written as Jack if you prefer. It is an acronym for "Jack Audio Connection Kit". Do you know JACK?

jackd, libjack

As a system, JACK has a number of parts. The server process is called jackd, and the library that applications link to is called libjack. From a theoretical perspective, this distinction is not important, but it is helpful to note the difference when describing JACK internals, due to the fact that these components execute in different processes and address spaces.

jackit, jack-audio-connection-kit

As luck would have it, by the time we got around to registering a sourceforge site for JACK, there was already another program out there by the same name. "jackit" is a play on the original JACK acronym. Not only does that other project have the sourceforge name, it has mandrake and debian packages too, so we needed a new name for releases. At the moment, we are releasing tarballs as jack-audio-connection-kit.

Altra informació per llegir

Configuració bàsica

Jack vkeybd fluid.png

Aquest és un test per comprovar el correcte funcionament del Jack. Tinc un Ubuntu Studio 9.04 (Jaunty) acabat d'instal.lar (el portàtil DELL ja va una mica just), i després d'instal.lar midishare, fluidsynth amb compatibilitat midishare,... em disposo a comprovar el funcionament del Jack i tunejar una mica el tema de la latència.

Arrenco el vkeybd i el fluidsynth (driver midi=alsa_seq (carrego un soundfont). Arrenco el Jack, que s'engega sense problemes. Totes les proves les faig amb al targeta de so pròpia del portàtil DELL (sense connectar el Edirol UA25-EX).

L'objectiu és fer sonar el Virtual Keyboard pel fluidsynth, a través del Jack, Per fer-ho, he de configurar les connexions del Jack tal com es mostra a la figura. En la pestanya MIDI he de connectar el vkeybd amb el fluidsynth. Però això no fa que soni, perquè el fluidsynth no sap a quin dispositiu hardware ha de redirigir-se. Per tant, en la pestanya Audio he de connectar el fluidsynth a System (que representa la tarja de so), i veig que té dos canals (estereo). I ja està. Toco la pianola i sento el so segons hagi ficat el soundfont.

Ara configuro una mica la latència, i el resultat és molt satisfactori. Evidentment, tinc marcat Real Time. Per defecte, a cuadros por periodo (que representa la resolució de les mostres) tinc el valor de 1024, que suposa una latència de 46.4mseg. Canvio 'cuadros por periodo a 128, i obtinc una latència de 5,8mseg. Torno a arrencar el Jack, i encara que no s'aprecia, estic treballant amb una latència baixa.

the playback device "hw:0" is already in use

the playback device "hw:0" is already in use. Please stop the application using it and run JACK again

Aquest missatge és perquè hi ha alguna altra aplicació ocupant la targeta de so, i que fa servir Pulseaudio. Per exemple, pot passar amb un video del Youtube. El tema de la incompatibilitat amb Pulseaudio se n'ha parlat molt, i en principi amb la versió 10.04 (Lucid Lynx) ja està solucionat: quan s'engega el JACK s'apaga el Pulseaudio, i al revés quan apaguem el JACK. Si aquest problema persisteix, la solució:

$ sudo /sbin/alsa force-reload

lsof: WARNING: can't stat() fuse.gvfs-fuse-daemon file system /home/joan/.gvfs
      Output information may be incomplete.
Terminating processes: 4765 5019 5317lsof: WARNING: can't stat() fuse.gvfs-fuse-daemon file system /home/joan/.gvfs
      Output information may be incomplete.
 5416lsof: WARNING: can't stat() fuse.gvfs-fuse-daemon file system /home/joan/.gvfs
      Output information may be incomplete.
 5434lsof: WARNING: can't stat() fuse.gvfs-fuse-daemon file system /home/joan/.gvfs
      Output information may be incomplete.
 5452lsof: WARNING: can't stat() fuse.gvfs-fuse-daemon file system /home/joan/.gvfs
      Output information may be incomplete.
 (with SIGKILL:) 5470lsof: WARNING: can't stat() fuse.gvfs-fuse-daemon file system /home/joan/.gvfs
      Output information may be incomplete.
 (failed: processes still using sound devices: 5489(pulseaudio)).
lsof: WARNING: can't stat() fuse.gvfs-fuse-daemon file system /home/joan/.gvfs
      Output information may be incomplete.
/sbin/alsa: Warning: Processes using sound devices: 5489(pulseaudio). 

podem veure com efectivament Pulseaudio era el causant del problema.