Configuring Jack Audio With KDE

I just finished one of those long fights we sometimes accept just to get some really minor problem solved. I got myself an usb microphone. After successfully getting it to run under alsa and recordmydesktop i went and looked for some graphical sound level meter (or however that is correctly named). There is apparently no such thing in kde and a google search was unsuccessful too. Some pulseaudio based solution ... thanks but no thanks. And some jack based ones.

So i finally looked into jack. I remembered from some attempts long time ago the need for realtime kernel. Not anymore. So i decided to give it a try. Feel free to learn from my feeble (and successful) adventures that follow.

After installing the needed packages i tried to start jack. It complained the sound device is busy. The culprit is obviously phonon somehow. Since i tried unsuccessfully before to free the sound device while keeping a kde session running i didn't even try. After adding a file with the following content to $HOME/.kde/Autostart i rebooted. Make sure you have those programs btw.

  1. #!/bin/sh
  2. killall timidity
  3. killall jackd
  4.  
  5. cd /tmp
  6. nohup qjackctl --start >/tmp/${LOGNAME}-qjackctl.log &
  7. sleep 2
  8. nohup timidity -iA -Oj >/tmp/${LOGNAME}-timidity.log &

I do not know exactly at which point those scripts are called, but my hope was before any kde daemon graps the sound device. And it works. Kinda. On login qjackctl always tells me jackd has crashed. But simply starting it again workd. So i had a running jackd daemon but obviously no kind of sound. Phonon - btw. didn't we try to get rid of those kind of names? - noticed that it was no longer able to use the current default sound device but that has to wait. To make sure that jack works first two tools are important. First qjackctl which embedded itself into the systray and jack_metro. First raise qjackctl from the systray and open up the connections dialog. Then from a command line start jack_metro -b 60. That creates a beep every second. Now lets try to make it hearable. You should see a metro entry on the left side of the qjackctl connections dialog. Connect that to system:playback_1 on the right sight by drag and drop. You can hear the beep? Great. If not you have to play with the preferences in qjackctl. Especially on the first tab, right side in and out channel (sorry translated form german here). There is a '>' button on the right side. Select different devices and restart jackd. Attention: Make sure jackd is really stopped after clicking on stop in qjackctl. That does not work here. Kill it if not.

Now you should have sound. If not it is obviously a good idea to stop here and undo what is done so far. No luck today.

Back to phonon. There is no phonon-jack backend so we have to find a way to take a longer route. My google fu brought up Jack Faq. The section "How can I play audio from .... via JACK?" is interesting. For my system it was the Routing GStreamer audio via JACK part. Hop over there for the needed steps i won't repeat them here. The gconf part was kinda annoying (didn't someone complain somewhere of kde apps pulling in hole mountains just to work?) but it worked. A gstreamer only check is done with gst-launch -v playbin uri=file:///my/music/file .

Back to phonon. I needed some time to figure out i had to go to kcmshell4 phonon and select the "Jack Audio Connection Kit" Device for all audio playback (Do not forget the "Apply Device List To ..." button). After restarting a phonon enabled application it should work., And it did.

That was to easy till now. If things go that smooth i get irritated.

Next thing is how to get alsa applications up and running again. Like flash for example. There is a nice thing called "The Alsa Jack Plugin". and it is nicely described how to setup that one in How do I route audio to/from generic ALSA-using applications?. This did work to sometimes. Then stopped to work. When flash once again (is does that from time to time) froze my complete X-Server so i had to reset i asked why i care. Other apps work great as you can check with aplay.

Talking about arecord. If you want to record audio that should work out of the box too. Just make sure the same conditions are met as when trying to record with alsa. The channel is active and set to recording (this is reset very often. Double check in case of trouble). Use either alsamixer or kmix to do that. In kmix notice the button on the left of the tab bar to add more hardware tabs and the channels entry from the context menu to make sure you see all needed channels (That cost me some time some weeks ago :) ).

If your micro shows up in the connections dialog just connect it to the output and you should hear yourself.

All of that btw. for this small command: meterbridge -t ppm [port]. Either specify a port on the command line or connect manually. A graphical sound level meter. Hooray.

Unintended side effects. Try jack-rack. Has nice sound effects. And jackeq. If you understand the latter one blog about it. I don't. Audacity is nice too.

Have fun

Comments

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.

redirect all

nohup qjackctl --start >/tmp/${LOGNAME}-qjackctl.log &
could be:
nohup qjackctl --start &>/tmp/${LOGNAME}-qjackctl.log &

to redirect every output not just stdout
Comment by Francesco R. (not verified) on Jul 25th, 2011 at 11:29 am

I have recently stumbled upon

I have recently stumbled upon KXStudio .......... (thanks to wonderful folks in #opensourcemusicians) ......... and i must tell you, i havent had a single Jack related problem since then... "KXStudio makes extensive use of JACK, by making it the default sound server on the system.Non-JACK applications are "bridged", to make sure you never have to worry about the 'Linux audio mess'." -http://kxstudio.sourceforge.net/ Just thought it would be nice to share here :)
Comment by Dinesh (not verified) on Jul 24th, 2011 at 2:06 am

I have been using Jack + KDE for a while.

I have found the GStreamer backend for phonon performs poorly with jack on my system and vlc doesn't auto connect streams, Xine backend works nicely though. I am using jackdbus rather than straight jack. jack doesn't always survive session loading. in which case the following works quite well killall -9 jackdbus; killall qjackctl; qjackctl& Pulseaudio now seems to play with jack quite nicely (it didn't use to) and is necessary if you want to run skype. I did have to hack the config files to force jack to be the default input output. Once jack is started pulseaudio --kill restarts pulseaudio and pulseaudio starts redirecting everything to jack including flash.
Comment by Danni (not verified) on Jul 23rd, 2011 at 8:11 pm

Disadvantages of PulseAudio

Could you elaborate a little bit on your personal dislikes of PulseAudio. Please, don't take this as flame or something - I'm just asking as a curious PulseAudio user :) No harsh feelings intended :)
Comment by Dimitar (not verified) on Jul 23rd, 2011 at 6:04 pm

Hi Dimitar No offense taken.

Hi Dimitar

No offense taken. Let us just keep it at: Me and pulseaudio have a colorful history. I solved our communication problems by showing it the door. I lived happily ever after..

Mike

Comment by admin on Jul 23rd, 2011 at 6:42 pm

Similar story here. Back in

Similar story here. Back in KDE3, first thing I always did was removing Arts (remember? it was the KDE3 sound daemon). That usually fixed my sound problems. I was happy to see KDE4 does not use a sound daemon per default.
On a friend's laptop, who's using Ubuntu which in turn uses PulseAudio per default, the microphone did not work. I removed PulseAudio, had some small fight with Gnome since the Ubuntu-Gnome is hard-wired to PulseAudio (at least, audio control is), and then the mic worked.

I really do not understand why, in times of ALSA, a sound daemon should be necessary at all. Why should my sound data go from the app though a socket to a server, and then to the ALSA device, instead of directly to the ALSA device? There just is no point, IMHO, now that OSS is really dead. What advantages does GStreamer+Pulse/Phonon+Pulse have over directly using GStreamer, or Phonon with a different backend - because there got to be some advantage for the cost of (latency-critical) data going through more processes, and for the cost of introducing a single point of failure in the sound pipe.
This is not meant as a rant, I am just really puzzled why anybody is using that software at all^^

Comment by Ralf (not verified) on Jul 23rd, 2011 at 10:04 pm

A couple years before, I had

A couple years before, I had to fight with alsa and pulseaudio to make my hda-intel works and then gave up to use OSSv4, but it couldn't do suspend ... eventually alsa got good support for my soundcard and until recently I switched to it exclusively. Then in my frenzy to optimise power consumption, I chanced upon a blog describing how pulseaudio saves power. I tested it just last week and I'm sold. While I don't just see any use for pulseaudio network capabilities or per applications volume control or supposedly improved bluetooth/usb headset support, power saving is useful, the rest is just icing on the cake. Also, you don't need zero latency to listen to music or video, only audio pro needs it. It consumes much more CPU cycles and power.
Comment by ChoK (not verified) on Jul 24th, 2011 at 4:39 pm

Of course there's a reason

Of course there's a reason why just about every distro out there uses Pulseaudio, including Maemo, MeeGo, Chrome OS and WebOS. To set a little light why, you could read the list of features in wikipedia article: http://en.wikipedia.org/wiki/PulseAudio It might be possible to directly add some of the features to alsa but that would probably introduce similar problems that pulseaudio had. Pulseaudio even might use less CPU than alsa because it uses better software mixing (or so I have heard). Overall when it works the problems get down to higher latency which matters most likely only in studio environments. I for one use pulseaudio for better bluetooth support.
Comment by Anonymous (not verified) on Jul 24th, 2011 at 3:53 pm

Post new comment

The content of this field is kept private and will not be shown publicly.
CAPTCHA
This question is for testing whether you are a human visitor and to prevent automated spam submissions.

Recent comments