# [Partially Outdated] JACK Audio Connection Kit Howto

## rojaro

Note

This Tutorial is now a little bit outdated and needs some points changed and/or replaced. I've started already writing a new completely new version of this document, but i currently i dont have much time to work on that and verify everything. So it will take a while until i have it finished.

Introduction

In my last tutorial, "Kernel support for MISC binaries" & Wine i showed how to run Windows (and other) binaries on Linux by just typing their names. While writing it i discovered that Wine now has JACK support and i just had to try it out. I never played with JACK before but read lots of good stuff about it and decided to install it myself and see if it works so well as people used to say. But that really gave me a hard time on hunting for howto's (which i havent found at all), Documentation etc., so i just started to write my own Howto. Although i havent recompiled Wine yet - therefore could not test it's JACK capabilities - i felt this paper is already good enough for a release.

But before we go on:

A BIG FAT WARNING: THIS HOWTO IS NOT FOR BEGINNERS OR PEOPLE THAT JUST WANT TO PLAY AROUND! THE SOFTWARE DISCUSSED (JACK) IS STILL UNDER DEVELOPMENT AND HAS SOME NASTY BUGS -> IT WILL CRASH YOUR MACHINE UNDER MANY CIRCUMSTANCES AND YOU MIGHT LOOSE PRECIOUS DATA. DO NOT TRY THIS IF YOU DONT KNOW WHAT THE SYSRQ KEY IS AS THAT ONE IS VERY LIKELY TO SAVE YOUR A**!

Jack, the Jack Audio Connection Kit, is still some pretty experimental stuff and to get the highest possible performance out of it , it still requires lots of hacking around. Right now there is no easy way to "just install" it and have it working. Also most audio applications still dont have support for it, but the ones that provide JACK support already are worth the time and effort installing it.

As it is still under development it still has quite some nasty downsides - you either have to run JACK and all the Applications that use it ass root or if you run JACK as a user, you loose most of it's advantages (that is it's high speed and low latency). But right now there is also another way available, but you should only do it on workstations without external services and you should be the only user on it.

Linux provides the so called "POSIX draft capabilities", which are a very nice idea for audio and video workstations, but in generall they are more likely to be consideresd as a security risk. These capabilities enable a setuid root program to get rights from the Kernel and give them to it's child's. Technically nothing bad, but this also allows these userspace programs to crash the kernel if they are not very carefully designed and as i said already, JACK will crash the machine under some certain circumstances. But as it seems it just likes to crash when a user presses the wrong button ... later more on that :)

I am using Linux-2.6.0-test-3-mm1 on my workstation with statically built ALSA drivers inside and i've had some weird effects here and there. I also could not compile everything i wanted (see the end of this document), but i assume that some of the problems that occured on my machine are very likely related to the gcc version i am running (3.2.3). I assume if you have a older kernel (2.4.x) and some older gcc (2.95.x) you will probably get much better results than i had with some of those packages.

However, the JACK installation itself worked well and alsaplayer works great ... with 2.67 milliseconds latency :)

REQUIREMENTS: A working ALSA installation and a properly configured soundcard -> this means YOU ALREADY HEAR SOUND out of it.

Step 1. - Kernel Setup

Make sure that you have the following Kernel Options Enabled:

CONFIG_PREEMPT (Processor tyoe and features -> Preemptibel Kernel)CONFIG_RTC (Character Devices -> Enhanced Real Time Clock)CONFIG_SND_RTCTIMER (Sound -> Advanced Linux Sound Architecture -> RTC Timer support)To run JACK as a normal user but with realtime scheduling, you also need to enable the "POSIX draft capabilities" but right now there is no "nice" way to do this. Open /usr/src/linux/include/linux/capability.h with your favorit text editor and look for the following line:

```
#define CAP_INIT_EFF_SET    to_cap_t(~0 & ~CAP_TO_MASK(CAP_SETPCAP))
```

and replace it with

```
#define CAP_INIT_EFF_SET    to_cap_t(~0)
```

below this line, there should be another line that should look like this:

```
#define CAP_INIT_INH_SET    to_cap_t(0)
```

replace it with

```
#define CAP_INIT_INH_SET    to_cap_t(~0)
```

or if you know how to handle the patch program, apply this patch.

now recompile your kernel, install it and reboot.

Step 2. - Building alsa-lib with JACK plugin

As soon JACK is running later, even ALSA applications won't be able to use the Soundcard unless they have JACK support. As there are right now only a hand full of applications that have native JACK support we need a workaround here for all our ALSA apps. Luckily, alsa-lib provides us with a jack-plugin that enables ordinary ALSA applications to work together with jack.

Unfortunately, the module doesnt get build by default and somebody of the alsa folks decided that it might be a good idea to require everybody to compile it by hand. The handy "--with-jack" flag (which already existed once and was well documented) got removed again, so i've just hacked up the alsa-lib ebuild to have the module built automatically. This is actually a really ugly hack, but it works.

Open /usr/portage/media-sound/alsa-lib/alsa-lib-0.9.6.ebuild with your favorite texteditor and do the following additions:

at the end of function scr_compile() add the following line:

```
(cd src/pcm/ext && (make jack || die "make jack failed"))
```

in function src_install add a new line after "make DESTDIR=${D} install || die" that reads

```
(cd src/pcm/ext && (make DESTDIR=${D} pkglibLDLIBRARIES_INSTALL="/bin/install -c" install-jack || die "make jack-install failed"))
```

 if you have done that, (re)emerge alsa-lib-0.9.6, which has to be done right now using the followin command:

```
ACCEPT_KEYWORDS="~x86" emerge alsa-lib
```

Step 3. - Install libcap

Libcap is required by the jackstart tool that gets compiled later when we install jack itself. But as there is no dependency in the ebuild you have to emerge it yourself.

```
emrge sys-libs/libcap
```

Step 4. - Which JACK version?

Now you have to choose which JACK version you want to use. There is the CVS version (media-sound/jack-cvs) and the release version	(media-sound/jack-audio-connection-kit). For this tutorial it doesnt matter which version you are going to use; the steps to do are basically the same, but you do them on diffrent files. On the following Steps i will use the current version 0.80.0 as example (which is right now still masked, but works very well).

Be carefull, there is a package named jack which is also in media-sound but that one has nothing to do with the JACK Audio connection Kit. One of media-sound/jack-cvs or media-sound/jack-audio-connection-kit is what you want.

Step 5. - Installing JACK

because i am a lazy guy i am not going to use the PORTAGE_OVERLAY directory in this example as this would require lots more of typing :)

but you should use it. see the portage user document on how to use it. really.

```
cd /usr/portage/media-sound/jack-audio-connection-kit
```

open the jack-audio-connection-kit-0.80.0.ebuild file in your favorite texteditor and goto line 45 and modify it so it will read

```
myconf="${myconf} --enable-optimize --with-gnu-ld --enable-capabilities --enable-stripped-jackd"
```

save the file and finally install JACK :)

```
USE="jack-tmpfs" ACCEPT_KEYWORDS="~x86" emerge media-sound/jack-audio-connection-kit
```

Step 6. - Configure ALSA

to make jack and alsa work as a team, we will have to tell jack which soundcard's it should use. this is done either through /etc/asound.conf or ~/.asoundrc. if none of these files exist, create one of them (i prefer /etc/asound.conf) and read this document. as a example i provide my configuration here:

```
pcm.cmipci {

   type hw

   card 0

}

ctl.cmipci {

   type hw

   card 0

}

pcm.!default {

   type plug

   slave { pcm jack }

}

pcm.jack {

   type jack

   playback_ports {

      0 alsa_pcm:playback_1

      1 alsa_pcm:playback_2

   }

   capture_ports {

      0 alsa_pcm:capture_1

      1 alsa_pcm:capture_2

   }

   monitor_ports {

      0 alsa_pcm:monitor_1

      1 alsa_pcm:monitor_2

   }

}
```

remember, this is my configuration from my workstation, so you have to read the alsa-docs and create a config file for your own soundcard (it probably looks very similar if you dont have a MIDIMAN or RME HAMMERFALL card). my workstation has only a very cheap onboard soundchip - a C-MEDIA 8738 MC6. but as it has fiber ports which are connected directly to my hifi, so it doesnt matter much if it is onboard or not. the sound is superb.

Step 7. - Testing JACK

now login as a user and start jackd via the following command remeber to use the name of your soundcard and not cmipci, unless you've got the same card):

```
jackstart -v -R -d alsa -d cmipci -H -M -m
```

WARNING: DO NOT PRESS CTRL+S NOW TO STOP THE SCROLLING! IT WILL CRASH YOUR MACHINE - YOU CANNOT RECOVER BY PRESSING CTRL-Q! Happend to me and i was lucky that i had the magic sysrq enabled which still allowed me to sync and unmount the disks so nothing really important got lost, and vim also recovered this tutorial :)

The output shown is there for debugging reasons and you probably want to see it in the next step. If you want to stop it scrolling, press CTRL-C. This will stop JACK, but it wont crash your machine :)

Step 8. - Alsaplayer

Since version 0.99.70, the alsaplayer supports jack as a output-plugin, but it will not be compiled unless it's configure script detects the installed jackd. therefore you probably will have to recompile the alsaplayer if you had it installed already.

```
emerge alsaplayer
```

by default, the alsaplayer wants to use alsa directly for playback. this we're going to fix i a later step, so for now run

```
alsaplayer -o jack
```

play some tune and look at the output of jackd. if you hear sound and see no errormessages from jack (alsaplayer might throw a notice that your "interface" is running at some higher number than 44100) the hard part has been done. For testing you might want to start 10 other alsaplayers, all playing the same track (electrionic music is nice) and play with the pitch and the volume on all of them :)

Step 9. - Starting JACK

there are two ways to start jack:

manually like in step x. but you probably don't want the debug output

```
jackstart -R -d alsa -d cmipci
```

jackstart has a few options you can set - but watch it, the first occuring "-d alsa" separates the jackstart options from the alsa driver options which you can (and probably want) set as well. so 

```
jackstart --help
```

shows the first set of options (the jackstart options) and

```
jackstart -d alsa --help
```

shows the driver options. Remember to put the jackstart options in front of the "-d alsa".

or emerge qjackctl (HIGHLY RECOMMENDED)

```
ACCEPT_KEYWORDS="~x86" emerge qjackctl
```

which is kind of a multifunctional jack control tool. with it you can start and stop jack, setup connections between applications and see a complete status. when it's done emerging run

```
qjackctl &
```

you cannot yet start JACK as a real deamon, and as it's used right now by very few applications. some alsa applications will work directly with JACK as we've created the asound config file above containing the jack plugin. Others that have a poorly designed ALSA driver will try to connect to the hardware device and wont work at all.

Step 10. - Setup Alsaplayer to use JACK whenever it's available.

Open the file ~/.alsaplayer/config with your favorite text editor. look for a line that says

```
main.default_output=alsa
```

and change it into

```
main.default_output=jack
```

if you start alsaplayer now, it will automatically use JACK if it's running. otherwise it will fall back to use ALSA.

Unsolved Problems

media-libs/libjackasynThis tool can connect OSS applications to JACK. of course, they wont work in synchronous mode, but for stuff like mplayer, xine etc this should be good enough. It doesnt find jack/error.h, and there really is no such file. So i uncommented the include in the source and tried to compile by hand. That worked, but the resulting app did nothing more than crash the alsaplayer which was connected at that time through jackd. So i didnt do much more with it as i think this app is kinda outdated and needs to be "synced" with JACK.

too bad, would have loved to use it.media-libs/ladcca-0.3.1ladcca doest compile on my machine - dies with the following error message

```
depmode=gcc3 /bin/sh ../depcomp \

gcc -DHAVE_CONFIG_H -I. -I. -I.. -I.. -g   -DLADCCA_BUILD -DHAVE_LADCCA -I/usr/include/alsa   -I.. -march=pentium4 -O3 -pipe -fomit-frame-pointer -c -o \

ladccad-client.o `test -f 'client.c' || echo './'`client.c

main.c: In function `main':

main.c:133: `LONG_MAX' undeclared (first use in this function)

main.c:133: (Each undeclared identifier is reported only once

main.c:133: for each function it appears in.)

main.c:134: `LONG_MIN' undeclared (first use in this function)

main.c:136: `UINT_MAX' undeclared (first use in this function)

make[2]: *** [ladccad-main.o] Error 1

make[2]: *** Waiting for unfinished jobs....

make[2]: Leaving directory

`/var/tmp/portage/ladcca-0.3.1/work/ladcca-0.3.1/ladccad'

make[1]: *** [all-recursive] Error 1

make[1]: Leaving directory `/var/tmp/portage/ladcca-0.3.1/work/ladcca-0.3.1'

make: *** [all] Error 2
```

therefore i could not compile other applications like media-sound/museseq (The Linux [midi] MUSic Editor [a sequencer]) and others that rely upon ladcca.media-sound/ardour-0.9_beta3also dies while compiling with an error message

```
[ cutted compiler stuff ]

diskstream.cc: In member function `int ARDOUR::DiskStream::do_flush(bool)':

diskstream.cc:1309: no matching function for call to `min(long unsigned int, size_t)'

[ cutted compiler stuff ]

make[4]: *** [diskstream.lo] Error 1
```

Probably more to come ... :)

The End (?)

Nope, for sure not. Although JACK is not finished yet, i see a great future for the project. I will also update this document as soon as i have new informations, got more stuff running or got feedback from you folks :)

I hope someone can provide some patches or hacks to get more stuff working with JACK and please, people, provide some feedback on other applications that you've got working with JACK!

----------

## Herodot

Nice work, well done!

I got most of these things to work last night, and then I found your guide - doh! So let me add my experiences with the things you mention.

- I've never had JACK crash my machine. Not even when running in realtime.

- I'm using a 2.4.20-gentoo-r7 kernel, so I can't use the "Enhanced Real Time Clock". Things are still working fine, though.

- The changes in /usr/src/linux/include/linux/capability.h also work with my kernel. They are described on the JACK homepage also.

- Building alsa-lib with JACK plugin is the one thing I can't get to work. As I understand it, this should route all calls to ALSA through the JACK server. It won't work. Maybe my asoundrc is wrong, I'll try again when I get the time.

- I can't get JACK to work when I use the ebuild. I can't get the realtime capabilities to work, no matter what arrangement of permissions on jackstart and jackd I try. Compiling it manually with the same configure parameters works for me, after I change the permissions on those two files.

- Configuring ALSA is a big problem. There's simply aren't any thorough guides to asoundrc, and it difficult to find specific hardware documentation. My soundcard is a Terratec DMX 6Fire 24/96. It's very nice, and has a lot of channels and mixers and monitors, and it's completely impossible for me to understand how to write a good asoundrc. The ALSA project obviously has a hard time getting hardware details from the hardware makers, and their sparse documentation is rarely helping us users. IMO. I'll try to find better documentation, and work more with it.

- qjackctl would be much more useful if it could store several settings for JACK, so you could start the server with different parameters. I haven't really looked into this, I must admit.

The reason I started looking on this was that I wanted to use a MIDI interface with ALSA. I started by cleaning out all traces of OSS in /etc/modules.d/alsasound (which turned out to be most of it...), and after several tries it actually started working.

I then emerged JACK 0.80, but it turns out that this blocks emerging other audio applications. They simply won't compile. So I downgraded JACK to 0.7? (latest stable), and emerged a couple of synths and stuff. They were rather disappointing, and mostly used OSS (bummer!). That's when I decided to get JACK working properly, OSS be damned. After too many hours of going through all of the above I had a working JACK, Rosegarden, Hydrogen and Alsaplayer. Then I found your guide.

It would be nice to replace Arts (in KDE) with JACK, or at least get XMMS, Xine and Mplayer to use JACK and then disable Arts. None of this is possible, to the best of my experience. It's just too new, and we have to patch a lot of programs to get JACK working at all. I suppose we'll just have to wait, and that's an awful solution to any problem! ( There is an JACK plugin for XMMS, but I can't get it to work.)

I have three sound devices: The aforementioned Terratec, which is my main soundcard. A small C-media 8738 that I'm not really using. And a Roland UM-1 USB MIDI interface. The ALSA layer works fine with the drivers in 0.9.6/7. There is a special mixer application for the ice1712 chip (in the Terratec) called envy24control. It is reportedly very good, but it has so many knobs and buttons that I go dizzy. And it's not clear wether all these options apply to my specific card - they probably don't. What I mean by "the ALSA layer works fine" is that the sound I get is indistinguisable from what I get from the same hardware in Windows, and directly from an audio CD-player. The UBS MIDI works fine also, which was a bit of a surprise - not much to say about that.

Running JACK with ASIO enabled actually works, which was a nice surprise after just about everything else failed to. Starting JACK with "jackstart -v -R -a -d alsa -d hw:0 -r 44100 -p 64" gives me a playback and record latency of 2 and 1 ms, as reported by Rosegarden. This with jackd having 10-15% cpu-load when running idle (Athlon 1800+), so it's not really usable, but it shows that it's possible to get the latency low enough for real audio work, which was my main concern. I'll look into this later.

I recommend qjackconnect, which gives a good overview of the current jack connections.

And now to something completely different: Maybe some of this should be added to the Gentoo sound guide (from the user docs)? It's actually "Gentoo Linux ALSA Guide", and doesn't touch upon JACK or MIDI. Judging from the questions in the Multimedia forum, many people have problems getting started, despite of this user doc. And the "only one sound at a time"-question is asked three times a day. That particular question (and others like it) should be answered in the Gentoo documentation (ie. the user docs), but the "Gentoo Linux ALSA Guide" doesn't cover everything. What does everybody think? Should we try to make a larger "Gentoo Linux sound Guide"?

----------

## rojaro

 *Herodot wrote:*   

> - I've never had JACK crash my machine. Not even when running in realtime.

 

well, i've got it running now for quite some time, and i also havent found anymore problems so far, except the ones which i've explained already

 *Herodot wrote:*   

> - Building alsa-lib with JACK plugin is the one thing I can't get to work. As I understand it, this should route all calls to ALSA through the JACK server. It won't work. Maybe my asoundrc is wrong, I'll try again when I get the time.

 

i found out that it will work with any alsa application that uses alsalib for playback (which are just very few) while the ones that use the alsa-devices will not work. e.g. xine, xmms (with alsa driver) and mplayer won't work (which is a real pity).

 *Herodot wrote:*   

> - I can't get JACK to work when I use the ebuild. I can't get the realtime capabilities to work, no matter what arrangement of permissions on jackstart and jackd I try. Compiling it manually with the same configure parameters works for me, after I change the permissions on those two files.

 

hmm.. works fine for me .. although i've modified the ebuild (as i wrote in the tutorial)

 *Herodot wrote:*   

> - Configuring ALSA is a big problem. There's simply aren't any thorough guides to asoundrc, and it difficult to find specific hardware documentation. My soundcard is a Terratec DMX 6Fire 24/96. It's very nice, and has a lot of channels and mixers and monitors, and it's completely impossible for me to understand how to write a good asoundrc. The ALSA project obviously has a hard time getting hardware details from the hardware makers, and their sparse documentation is rarely helping us users. IMO. I'll try to find better documentation, and work more with it.

 

actually, the whole alsa documentation seems to be VERY outdated and very incomplete. the only document about the asoundrc i've found was a basic parameter listing (which looked like being generated with doxygen or something similar) which doesnt contain a single example.

 *Herodot wrote:*   

> - qjackctl would be much more useful if it could store several settings for JACK, so you could start the server with different parameters. I haven't really looked into this, I must admit.

 

qjackctl 0.0.8 stores it's settings in ~/.qt/qjackctlrc, but it seems it only does this when it is creating the file. if you change something later on, it won't be saved.

 *Herodot wrote:*   

> After too many hours of going through all of the above I had a working JACK, Rosegarden, Hydrogen and Alsaplayer. Then I found your guide.

 

still could not get ardour, rosengarten and hydrogen working on my machine, but mostly due to compilation errors of other libraries (as noted above) :(

 *Herodot wrote:*   

> It would be nice to replace Arts (in KDE) with JACK, or at least get XMMS, Xine and Mplayer to use JACK and then disable Arts. None of this is possible, to the best of my experience. It's just too new, and we have to patch a lot of programs to get JACK working at all. I suppose we'll just have to wait, and that's an awful solution to any problem! ( There is an JACK plugin for XMMS, but I can't get it to work.)

 

I don't use Arts at all. i found it to be too slow for me, memory consuming and completely laggy to do anything with it. there are options to disable it completely in kcontrol. I also configured all the other programms (like xmms, mplayer and xine) to use alsa natively. there is no need for the big bloated artsd ...

 *Herodot wrote:*   

> I have three sound devices: The aforementioned Terratec, which is my main soundcard. A small C-media 8738 that I'm not really using.

 

thats the one i have ... it's analogue outputs are really bad, but the sp/dif is pretty much flawless :)

 *Herodot wrote:*   

> This with jackd having 10-15% cpu-load when running idle (Athlon 1800+), so it's not really usable, but it shows that it's possible to get the latency low enough for real audio work, which was my main concern. I'll look into this later.

 

i think the cpu-load which jackd reports is kinda unreliable. on my machine (which is a p4/3ghz) it also always reports something around 10% but my top actually never ever reported it to be using more than 1.7%. i've also ran for testing like 10 alsaplayers simultaneously together with freqtweak (which produced kind of a very weird sound as all where playing diffrent shoutcast streams) but even then top reported it to be just around 4% which is f***ing cool.

 *Herodot wrote:*   

> I recommend qjackconnect, which gives a good overview of the current jack connections.

 

well, qjackctl also provides that feature, and it even looks better ... :)

edit: fixed typo

----------

## Herodot

 *rojaro wrote:*   

>  *Herodot wrote:*   - I can't get JACK to work when I use the ebuild. I can't get the realtime capabilities to work, no matter what arrangement of permissions on jackstart and jackd I try. Compiling it manually with the same configure parameters works for me, after I change the permissions on those two files. 
> 
> hmm.. works fine for me .. although i've modified the ebuild (as i wrote in the tutorial)

 I tried again, and this time it worked. I didn't even have to chmod anything.

 *rojaro wrote:*   

> actually, the whole alsa documentation seems to be VERY outdated and very incomplete. the only document about the asoundrc i've found was a basic parameter listing (which looked like being generated with doxygen or something similar) which doesnt contain a single example.

 

Exactly - it's borderline worthles. Many projects need better documentation, but ALSA is certainly one of the worst.

 *rojaro wrote:*   

> still could not get ardour, rosengarten and hydrogen working on my machine, but mostly due to compilation errors of other libraries (as noted above) 

 

I'm also having problems with several programs. At first I managed to get some compiled by having a JACK 0.7, not 0.8. But ladcca and ardour still won't compile. Somebody ought to file a bug!

 *rojaro wrote:*   

> I don't use Arts at all. i found it to be too slow for me, memory consuming and completely laggy to do anything with it. there are options to disable it completely in kcontrol. I also configured all the other programms (like xmms, mplayer and xine) to use alsa natively. there is no need for the big bloated artsd ...

 True, I've seen that particular light as well. But it would certainly be preferable to go through JACK, to get multiple streams.

 *rojaro wrote:*   

> i think the cpu-load which jackd reports is kinda unreliable. on my machine (which is a p4/3ghz) it also always reports something around 10% but my top actually never ever reported it to be using more than 1.7%.

 

I agree. Not do I think top is completely reliable.

 *rojaro wrote:*   

> i've also ran for testing like 10 alsaplayers simultaneously together with freqtweak (which produced kind of a very weird sound as all where playing diffrent shoutcast streams) but even then top reported it to be just around 4% which is f***ing cool.

 

Yes! I'll have to try that!

 *rojaro wrote:*   

>  *Herodot wrote:*   I recommend qjackconnect, which gives a good overview of the current jack connections. 
> 
> well, qjackctl also provides that feature, and it even looks better ... 

 

You're absolutely right. It seems that checking "Details" in qjackctl was too difficult for me, so I thought it was just a start/stop button. Now that I've seen what it really does, I use it all the time.

I claimed that there's no "CONFIG_RTC (Character Devices -> Enhanced Real Time Clock)" in the 2.4.20 kernel. That's wrong, it's there. But there's no "CONFIG_SND_RTCTIMER (Sound -> Advanced Linux Sound Architecture -> RTC Timer support)" - I wonder if I can emerge the alsa-driver with a similar parameter?

I just got fluidsynth to work with JACK, that's important. But I'm still having problems with figuring out how everything connects.

----------

## keef

rojaro said:

Step 2 - 2

 *Quote:*   

> in function src_install add a new line after "make DESTDIR=${D} install || die" that reads
> 
> ```
> 
> (cd src/pcm/ext && (make DESTDIR=${D} pkglibLDLIBRARIES_INSTALL="/bin/install -c" install-jack || die "make jack-install failed"))
> ...

 

For alsa-lib-0.9.7 (don't know about previous revs) pkglibLDLIBRARIES_INSTALL should be pkglibLTLIBRARIES_INSTALL.

---

 *Quote:*   

> media-libs/ladcca-0.3.1
> 
>       ladcca doest compile on my machine - dies with the following error message

 

Same here...I've entered a bug report for this as well as the a fix...including ebuild, digest, and patch:

  Bug# 30925

----------

## azhyd

just a very basic advise : you may have to re-emerge alsa-driver after the kernel recompiling (the correcponding modules are deleted) and fix the mixer volumes.

----------

## fireboy1919

I've gotten it working, and libjackasyn compiled fine for me.

I'm not exactly sure what to do AFTER that, though.  How exactly do you make libjackasyn do it's thing?  I've tried using LD_PRELOAD and jacklaunch, but the result is the same:  /dev/dsp is considered busy.

Also, anybody know how to get one machine's client to communicate with another?  Is this beyond jack's capabilities?

----------

## orb9

First of all: I mainly followed the howto of the original poster rojaro (thanks man) and now i have JACK running in realtime as an ordinary user on my MAudio Delta 66 (which is one the none standard cards i guess). I'm currently working with JACK version 0.90.1, ALSA-lib v 0.9.8, ALSA driver v 0.9.8 (kernel modules) and everything described below was tested with this configuration. Here are my little additions to some of the steps:

1) Kernel setup for JACK realtime-priority

Besides the kernel setup i needed to suid root the jackstart executable via

```
chmod u+s `which jackstart`
```

to be able to run JACK with realtime-priority as an ordinary user.

I am using kernel-2.6.0 (development-sources-2.6.0) and everything described under Step 1 worked well with this kernel.

2) Building alsa-lib with JACK plugin 

In my portage tree alsa-lib is no longer in media-sound but rather in media-libs. 

Additionally the alsa-lib-0.9.8.ebuild already contains the code to build the jack-plugin when your USE flags contain "jack".

5) Installing JACK 

The jack-audio-connection-kit-0.90.1-r1.ebuild (and above) already contains the described modifications. They are activated only if your USE flags contain "jack-tmpfs jack-caps". Summarized my JACK part of the USE environment variable contains the three items "jack jack-tmpfs jack-caps". With this you should be able to emerge alsa-lib and jack-audio-connection-kit without ebuild modifications.

Now on to the applications. Since i want music during the day i need an MP3 player. And here the struggle begins. I know there is alsaplayer which is working with JACK but i'm into xmms for years now and i wanted to get it JACKified. 

XMMS

In short: it should work - but not for me. It only works if your JACK demon is running at 44100hz. My soundcard is driven by 48000hz so xmms complains about incompatile sample rates (most of the mp3 files are 44100hz). So if you're running JACK at 44100hz this should work and here's what i've done:

1) Used this (selfmade) ebuild:

```

# Copyright 1999-2003 Gentoo Technologies, Inc.

# Distributed under the terms of the GNU General Public License v2

S=${WORKDIR}/${P}

DESCRIPTION="Allows XMMS to output via jack."

HOMEPAGE="http://xmms-jack.sourceforge.net/"

SRC_URI="http://cesnet.dl.sourceforge.net/sourceforge/xmms-jack/xmms-jack-0.6-20031201.tar.gz"

SLOT="0"

LICENSE="GPL-2"

KEYWORDS="x86 ~ppc"

DEPEND="media-sound/xmms

   >=media-libs/alsa-lib-0.9.2

   >=media-sound/alsa-driver-0.9.2"

src_compile() {   

   cd ${WORKDIR}/${PN}

   rm config.cache

   econf || die

   emake || die

}

src_install() {

   cd ${WORKDIR}/${PN}

   einstall \

      libdir=${D}/usr/lib/xmms/Output || die

   dodoc AUTHORS README NEWS COPYING ChangeLog

}

```

Put this into your PORTDIR_OVERLAY dir under media-plugins/xmms-jack and name it xmms-jack-0.6.ebuild.

Then do 

```
ebuild $PORTDIR_OVERLAY/xmms-jack/xmms-jack-0.6.ebuild digest
```

and

```
emerge $PORTAGE_OVERLAY/xmms-jack/xmms-jack-0.6.ebuild
```

and xmms now offers an jack output plugin. Hurray - one may say at 44100hz. As described above my card runs 48000hz. When running JACK with this rate (which is possible) the sound is pitched up because my card interprets it as 48000hz. What is necessary here is some kind of sample-rate conversion. Can anybody tell me if this should theoretically be done by the JACK demon or the xmms output plugin?

Hydrogen

Hydrogen is a drum-machine with JACK support. Compiled cleanly and works fine here. 

Ardour

Compiled and running. Never tried it, though.

KDE, Arts and JACK

Short story.. doesn't work for now. There are some bugs filed at bugs.kde.org which vote for JACK support in arts. If you are a registered kde developer vote for these over there. 

Bug 62465: aRts: more output modules needed, expecially JACK 

Bug 64696: Make artsd able to use alsa and especially jackd 

Interesting also (it's ALSA related only):

Bug 70802: showstopper: artsd fails at using a modern alsa setup: pcm.default not used

----------

## krinkle

just an update, i followed the guide and everything  works fine. I'm using alsa-lib 1.0.2, jack .94, and 2.6.2 kernel. getting alsa to emerge took a couple steps though. i had to emerge alsa-lib without the jack flags, then emerge jack, then re-emerge alsa-lib with the jack flags. xmms-jack now works again as of version .8. also, i think it is because of the version of jack i am using, i had to modify the headers of spiral modular to get it to compile. i'll look up what I did and post it.

----------

## sumin k'adra

@orb9: Your soundcard is not 'driven' at any rate. You can set your sample rate to 44100--or whatever proper number you want for that matter--with envy24control (media-sound/alsa-tools). Starting jack with '-r 44100' should automagically set your card to 44100 hz. But seeing as it apparently doesn't, just set it with envy24control. Always remember, young grasshopper, resampling is bad!

'tis a shame to not know the full capabilities of one's own $200+ sound card : ) j/k, we're all here to learn.

-sk, proud delta 44 owner and lover

----------

## spitzwegerich

I loosely followed this tutorial for getting jack working and want to mention some points:

1) Great! Many thanks for this tutorial!!

2) Some things are easier as described, using the USE-flags jack, jack-caps and  jack-tmpfs which may not have existed when this tutorial was written.

3) An updated Version (using the USE-flags) of this tutorial would be very nice! Also, as suggested by Herodot , I think a "Gentoo Linux sound Guide" is a great idea. In my opinion, gentoo with its huge possibilities to tweak and optimize makes it a perfect joice for serious linux audio work.

4) I may be blind, but where can I look up the actual latency of my system?

5) As far as I can see, the jackstart parameter -a for using ASIO got removed. Does anyone know why?

6) My card is a Terratec EWX 24/96 (ice1712 alsa-driver). This card is capable of 96kHz sampling frequency. When running

```
jackstart -v -R -d alsa -d ice1712 -r 96000
```

 i get this output:

```
back from read, ret = 1 errno == Success

getting driver descriptor from /usr/lib/jack/jack_dummy.so

getting driver descriptor from /usr/lib/jack/jack_alsa.so

jackd 0.94.0

Copyright 2001-2003 Paul Davis and others.

jackd comes with ABSOLUTELY NO WARRANTY

This is free software, and you are welcome to redistribute it

under certain conditions; see the file COPYING for details

registered builtin port type 32 bit float mono audio

capabilities: =i cap_setpcap,cap_ipc_lock,cap_sys_nice,cap_sys_resource+ep

loading driver ..

new client: alsa_pcm, id = 1 type 1 @ 0x805cb58 fd = -1

apparent rate = 96000

creating alsa driver ... ice1712|ice1712|1024|2|96000|0|0|hwmon|swmeter|rt|32bit

configuring for 96000Hz, period = 1024 frames, buffer = 2 periods

new buffer size 1024

registered port alsa_pcm:capture_1, offset = 4096

[snip]

registered port alsa_pcm:playback_10, offset = 0

++ jack_rechain_graph():

client alsa_pcm: internal client, execution_order=0.

-- jack_rechain_graph()

15766 waiting for signals

load = 0.1969 max usecs: 42.000, spare = 10624.000

delay of 12528.000 usecs exceeds estimated spare time of 10624.000; restart ...

delay of 12405.000 usecs exceeds estimated spare time of 10624.000; restart ...

delay of 12423.000 usecs exceeds estimated spare time of 10624.000; restart ...

delay of 12426.000 usecs exceeds estimated spare time of 10624.000; restart ...

delay of 12399.000 usecs exceeds estimated spare time of 10624.000; restart ...

delay of 12405.000 usecs exceeds estimated spare time of 10624.000; restart ...

delay of 12424.000 usecs exceeds estimated spare time of 10624.000; restart ...

delay of 12417.000 usecs exceeds estimated spare time of 10624.000; restart ...

delay of 12417.000 usecs exceeds estimated spare time of 10624.000; restart ...

delay of 12404.000 usecs exceeds estimated spare time of 10624.000; restart ...

delay of 12407.000 usecs exceeds estimated spare time of 10624.000; restart ...

delay of 12426.000 usecs exceeds estimated spare time of 10624.000; restart ...

delay of 12426.000 usecs exceeds estimated spare time of 10624.000; restart ...

delay of 12397.000 usecs exceeds estimated spare time of 10624.000; restart ...

delay of 12408.000 usecs exceeds estimated spare time of 10624.000; restart ...
```

I don't get the delay lines with other frequencies, and I do not really understand what they mean. Are these the good old XRuns? Does anyone have an idea on this? I want to get rid of them.

----------

## Kristleifur

 *spitzwegerich wrote:*   

> 4) I may be blind, but where can I look up the actual latency of my system?

 

In qjackctl, there's a little box in the lower right corner of the Setup window that shows you the latency, according to the buffers you've set.

I like this thread. How's everybody doing?

Qjackctl starting jack with jackstart and then running alsaplayer is now working on an Audiophile card (ice1712).

Sometimes, the programs connecting to the jack server don't seem to want to connect unless run as root. Sometimes they do. Any ideas about that?

Any must-try tricks?

----------

## Kristleifur

Today I learned that DRI / GLX aren't compatible with jack running in realtime. It caused many things to hang on my system, including ps and top. Disabling the glx line in my xf86config seems to have fixed it. Here's a link to a thread on the jack developer mailing list: http://sourceforge.net/mailarchive/message.php?msg_id=7005966

Tomorrow will be fun.

----------

## spitzwegerich

Now I know the reason why I got these lines:

```
delay of 12408.000 usecs exceeds estimated spare time of 10624.000; restart ...
```

My sample rate was locked at 44,1 kHz. After unlocking it in envy24control, everything is fine.

----------

## Blahbbs

I'm planning on tackling this soon, but using the 2.4.x kernel.  My question is this:  The 2.4.25-gentoo-sources kernel doesn't seem to have the low latency patches, so I thought I'd apply Andrew Morton's 2.4.25 patches and do it myself.  

If I do it that way, should I be using the 2.4.25 vanilla sources, or is there another set of 2.4 sources that has the low latency patches in it?

I tried patching the 2.4.25-gentoo-r2 sources, but I had a few failed patched.  I made a best guess to resolve them, and the kernel did compile, but I'm not a kernel hacker, so I'm not sure that's the best way to do it.

Any suggestions?  I'm anxious to get a audio workstation going....

Thanks!

----------

## spitzwegerich

As far as I know, the gentoo-sources already should contain the low-latency patch. But you have to enable it in make menuconfig.

----------

## krinkle

dunno if it's a bug in the ebuild or just a brand new ebuild, but the USE flag jack-caps has changed to just caps in the .98.1 ebuild

----------

## spitzwegerich

In fact, this already changed some time ago.

----------

## shakti

deleted wrong info about /tmp and jack

----------

## shakti

the alsa-libs ebuild is in media-libs/alsa-lib/... and not media-sound

----------

## BennyP

everytime I try to start JACK, I get this error: 

```
 loading driver ..

apparent rate = 44100

creating alsa driver ... hw:0|hw:0|1024|2|44100|0|0|nomon|swmeter|-|32bit

control device hw:0

configuring for 44100Hz, period = 1024 frames, buffer = 2 periods

Couldn't open hw:0 for 32bit samples trying 24bit instead

Couldn't open hw:0 for 24bit samples trying 16bit instead

Couldn't open hw:0 for 32bit samples trying 24bit instead

Couldn't open hw:0 for 24bit samples trying 16bit instead

19:47:02.580 MIDI connection change.

19:47:04.593 Could not connect to JACK server as client.
```

----------

## krinkle

what is your sound card/what are you starting jack with?

(should this go in another thread?)

----------

## BennyP

i have an sblive value and i use qjackctl (jackd)

----------

## shakti

Make sure ARTS is not running, use USE="jack" when emerging alsa...

----------

## BennyP

I followed up till STEP 7, but i dont have jackstart

----------

## shakti

Did you try all the steps (particular Kernel, Alsa and 7) in the HowTo above? I had same error at first but it turned out to be a alsa prob. What alsa / kernel version are you using?

----------

## BennyP

For a brief and wonderful time, jack was running well with alsa-lib 1.0.3-r3, then I started getting these massive xruns, 

I did

chmod u+s /usr/bin/jackd and

chmod u+s /usr/bin/jackstart

and now jack wont run at all! I get the infamous  

Could Not Connect to JACK as client error

This is after remerging alsa-lib and jack with jack-tmpfs and caps use flags and only after I ran the chmod. Now I cant start jack in realtime or otherwise and i'm FREAKING OUT because I'm going to Teknival in 2 days to perform!!!

----------

## BennyP

*shameless bump*

It occurs to me that aftr syncing portage any changes i made t the alsa and jack ebuilds are lost, but now alsa-lib is 1.0.5 and jack is 0.98.

will I still need to edit these ebuilds?

----------

## shakti

Just to update, no modifications to any e-builds are nessesary, the only thing one has to do to get jack to work with gentoo is patch 2.6 kernel for real time.

----------

## benxor

I've been following this and other tutorials - I've managed to get jack *working*, but only if I run it and all the clients that connect to it as root. I still can't get it running as a normal user. Here are the steps I've followed, maybe somebody might see something wrong in what I'm doing and could put me on the right course:

I'm running kernel 2.6.10-rc1-mm2

I've got a C-MEDIA 8738 sound 'card' onboard, the module compiled for it, and that's all configured and working fine with ALSA

I have the following packages:

```

alsa-lib (1.0.6), alsa-oss (1.0.6), alsa-jack (1.0.6), alsa-headers (1.0.6a), alsa-utils (1.0.6), jack-audio-connection-kit (0.99.0), mplayer (1.0_pre5-r4)
```

and the following use flags:

```
USE="3dnow 3dnowex aac acpi acpi4linux aim audiofile caps cdinstall \

     cdparanoia cdrom cdrw codecs curl dba dga divx4linux dts dv dvd dvdr \

     dvdread dvdrw faac faad fbcon ffmpeg flac freetype ftp gd gimp gimp2 \

     gstreamer hal icq imlib2 ipod ipv6 jabber jack jack-tmpfs java \

     javascript jp2 jpeg2k lcms libcaca libsamplerate lirc live lzo \

     matroska mime mmx mng mp3 mp4 mpeg4 mpi mplayer msn network no_wxgtk1 \

     nptl offensive ogg openal oscar pda pic plotutils ppds radeon real \

     recode rtc samba silc sndfile soundtouch sse svg tga theora thumbnail \

     tiff transcode unicode usb vcdimager vorbis wmf xpm xvid xvmc yahoo \

     -oss -arts -libg++ -opengl -xmms -esd -kde"
```

I have patched my kernel code directly to get POSIX capabilities working, have emerged realtime-lsm from portage and built it against the kernel, turned on default capabilties and other security sruff exactly as requested by the realtime-lsm emerge instructions, and I load the following modules at startup:

```

/etc/modules.autload.d/kernel-2.6:

commoncap

realtime gid=18 mlock=1
```

group id 18 is the audio group, and here is it's entry in /etc/group:

audio:x:18:benxor,jack

I've added the 'jack' user in hopes of getting that to run jackd, but it's working about as well as running it as my standard user 'benxor'.

When I run jackd or jackstart as root, everything's fine. I can use jack, mplayer et al can use jack - but only if I run *them* as root. If I run jackstart or jackd as a normal user, I get simply:

```
back from read, ret = 1 errno == Success

jackd 0.99.0

Copyright 2001-2003 Paul Davis and others.

jackd comes with ABSOLUTELY NO WARRANTY

This is free software, and you are welcome to redistribute it

under certain conditions; see the file COPYING for details

cannot bind server to socket (Permission denied)

cannot create server sockets

cannot create engine
```

jackstart is suid root, but only because if I don't do this it gives me a warning to suid it root anyway. If suid root jackd, and then run it as a normal user, I get:

```
mugatu /home/benxor # chmod u+s /usr/bin/jackd

mugatu /home/benxor # exit

benxor@mugatu ~ $ jackd -p -R -dalsa -dhw:0 -r 44100 -H -D -z s

jackd 0.99.0

Copyright 2001-2003 Paul Davis and others.

jackd comes with ABSOLUTELY NO WARRANTY

This is free software, and you are welcome to redistribute it

under certain conditions; see the file COPYING for details

loading driver ..

apparent rate = 44100

creating alsa driver ... hw:0|hw:0|1024|2|44100|0|0|hwmon|swmeter|-|32bit

control device hw:0

configuring for 44100Hz, period = 1024 frames, buffer = 2 periods

Couldn't open hw:0 for 32bit samples trying 24bit instead

Couldn't open hw:0 for 24bit samples trying 16bit instead

Couldn't open hw:0 for 32bit samples trying 24bit instead

Couldn't open hw:0 for 24bit samples trying 16bit instead

Noise-shaped dithering at 16 bits

cannot create shm segment /jck-[32 bit float mono audio] (Invalid argument)

cannot create new port segment of 0 bytes, name = /jck-[32 bit float mono audio] (Invalid argument)

no ports available!

ALSA: cannot register port for capture_1

no ports available!

ALSA: cannot register port for playback_1
```

trying to access the damaged deamon by playing a song (as normal user) with say mplayer in the next console, I just get 'can't open sound, can't open video', blah blah blah, mplayer doesn't work.

So *what* is going on? What have I forgotton, or done wrong, to get jackd just running as a normal user? I'm up to my eyeballs in properly implemented realtime scheduling stuff, but nothing seems to work. I know the realtime modules are loaded, and even that jackstart/jackd is hooking into them to some extent because I got the old 

```
jackstart: cannot get realtime capabilities, current capabilities are:

           =ep cap_setpcap-ep

    probably running under a kernel with capabilities disabled,

    a suitable kernel would have printed something like "=eip" 
```

when I had forgotten to go into include/linux/capabilities.h in my kernel and patch those two lines. I no longer get that error, and the realtime module runs happily, but of course this doesn't mean I can actually get realtime for normal user processes in the audio group, oh no.

So since I've done that; enabled capabilities; enabled alsa, and alsa-oss compatability; have sound working on my soundcard; have *jack* working; why can't i get jack running as a normal user? Can anyone help me out?

----------

## shakti

My first guess is that you did some mistake in patching your kernel, retrace your steps, all you need is right in this forum. Does alsa work ok? If you did more than emerge  jackblabla and patched kernel you did something wrong. No chmod's are nessessary.  But again make sure alsa works fine before trying to get jack to work.

----------

## benxor

alsa works fine, and indeed jack works fine with it (running as root).

how do you mean messed up patching? getting things working for realtime-lsm, or just changing those two lines in capabilities.h?

----------

## benxor

Just an update - I discovered the problem was not the kernel, capabilities, realtime or any of that at all - it was actually problems with jack grabbing virtual memory. When I removed the jack-tmpfs USE flag, everything suddenly worked =)  Now I can run Jack as a normal user, and I'm working on an init script =D

----------

## jannis

Hello, I just wanna post my experiences here:

I emerged jackd yesterday and it was working great! I was totally happy with it, even arstd worked using the jack-output. It was the first time I could listen to music (xmms with jack output), hear my icq-msgs (artsdsp play <file>) which were played by arts to the jackd and play Q3A (artsdsp -m quake3) at the same time.

Then I emerged anything (maybe I updated jackd or something similar, I don't know anymore) and suddenly, artsd wasn't able to play his sound through the jackd. It could connect to jack and was shown in the "connect"-panel of qjackctl but didn't play any sound. "mplayer -ao artsd" got stuck when it tried to play sound. even worse: "mplayer -ao jack" crashed after loading the jack-library.

My solution up to now:

JACKD is running fine. I emerged libjackasyn (it worked ^^) (it routes the sound going to /dev/dsp to jack, similar to artsdsp), I can start artsd with "jacklaunch artsd -a oss" but I didn't find a way to do so automatically. Renaming artsd to something else and making an script called "artsd" which launches "jacklaunch artsd $1" doesn't work. So the sound from artsd goes to jack, fine!

My licq plays his sound by jacklaunch, too.

The only problem is that Q3A needs MMAP and jacklaunch can't do this. Q3A is launched with "artsdsp -m quake3", meaning the q3a-sound goes to alsa, which has it's sound-output routed to jack which plays the sound to the soundcard. Hm..... "low delay system"? Not really. Playing quake3 with 1 second sound-delay SUXX.

BTW: The way, I start my jackd:

/etc/conf.d/local.start:

```
su - kripton -c "jackstart -s -d alsa -p 2048 -o 2 -i 2 -H -M -S -D &"
```

it doesn't detach from the console but it works.

I didn't manage to get the alsa-jack-plugin working. Here's my /etc/asound.conf:

```
pcm.intel8x0 {

   type hw

   card 0

}

ctl.intel8x0 {

   type hw

   card 0

}

pcm.!default {

   type plug

   slave { pcm jack }

}

pcm.jack {

   type jack

   playback_ports {

      0 alsa_pcm:playback_1

      1 alsa_pcm:playback_2

   }

   capture_ports {

      0 alsa_pcm:capture_1

      1 alsa_pcm:capture_2

   }

   monitor_ports {

      0 alsa_pcm:monitor_1

      1 alsa_pcm:monitor_2

   }

}

```

Maybe someone can help me with this so the artsd can play his sound to "ALSA".

Thanks for all the stuff in this thread, it was pretty useful.

*UPDATE*:

I ran artsd in debug mode and here is the problem:

```
AudioSubSystem: rBuffer is too full

(The previous message was repeated 383 times.)
```

Artsd sourcecode tells me:

```

         if(rBuffer.size() < _fragmentSize * _fragmentCount * bits() / 8 * channels())

         {

             rBuffer.write(len,fragment_buffer);

#ifdef DEBUG_WAVEFORM

            float * end = (float *)(fragment_buffer + len);

            float * floatbuffer = (float *)fragment_buffer;

            while(floatbuffer < end)

            {

               d->plotfile << *floatbuffer++ << "\n";

               ++floatbuffer;

            }

#endif

         }

         else

         {

            arts_debug( "AudioSubSystem: rBuffer is too full" );

         }
```

No, it doesn't help me :/

Anyone got artsd working with the jack-driver?

[code]The strange thing is: I got it working once :/

----------

## jannis

Ok, another update.

After having emerged jackd-0.98.1 (I had 0.99.0 before) and re-emerging arstd aftwewards my artsd really plays his sound through jack.

it works great again =DDD

----------

## Coltie

[quote="fireboy1919"]Also, anybody know how to get one machine's client to communicate with another?  Is this beyond jack's capabilities?[/quote]

Just in case, here is the app you are looking for: jack.plumbing

http://www.alphalink.com.au/~rd/sw/jack.html

----------

