Page 1 of 1

Dream Studio + Jack/Pulse

Posted: Sun Dec 16, 2012 3:26 am
by mdickson
I'm about to pull my hair out. (I'm trying various linux distros, including AVLilnux and Dream Studio (both seem to be great). Now I'm running Dream Studio (based on the latest Ubuntu) with all of the latest updates, because it seems to let pulsaeaduio and jack play nice.)

I've looked at a lot of stuff to solve my complicated problem, but let me start here, as I suspect it is the (or a) root of evil. If it gets more complicated, so be it. Jack starts up fine, no complaints, 1 or 0 Xruns even with loads of crap running (network, etc.). That's good.

When I click on the 'Sound Settings" icon at the top of the screen (under the volume icon), it gives me the option to set 'Sound Settings". When I click that, I have several options, including setting output to 'Analog Output (Scarlett 2i4 USB)". When I choose that option, playing music through RhythmBox, Youtube videos, etc., works just fine -- it comes through the monitors attached to my Focusrite 2i4.

When I start up Muse, load up some MIDI data and sound fonts and play, I hear nothing. Muse shows up in Jack, but no matter how I connect it to whatever, there is no sound. Muse is showing me that there is sound in its level indicator, so I don't think the problem is in Muse.

Any clues are much appreciated.

Re: Dream Studio + Jack/Pulse

Posted: Sun Dec 16, 2012 10:38 am
by Pablo
To narrow down the sources of the problem, try playing an audio file with a jack-aware audio player. I suggest aqualung because you don't have to tweak anything to "jackify" it, i.e., it should work out of the box.

If there is sound, then the problem is not related to jack.

EDIT: One more thing, if Muse is sending MIDI data to an external software synth you want the synth audio outputs (not Muse audio) connected to the system playbacks. It is different if the synth is an instrument plugin in Muse.

Re: Dream Studio + Jack/Pulse

Posted: Sun Dec 16, 2012 3:55 pm
by mdickson
Thanks for the thoughts. I'll give those things a try and report back.

Re: Dream Studio + Jack/Pulse

Posted: Sun Dec 16, 2012 6:39 pm
by English Guy
The Dream Studio forum is really helpful as well. The chances are Dick MacInnis (the dream studio dev) will be around & answer your post himself.

Re: Dream Studio + Jack/Pulse

Posted: Mon Dec 17, 2012 1:03 am
by mdickson
Thanks again. Maybe I'll try to Dream Studio forum as well.

I installed aqualung and ran it. It shows up fine in Jack, I can connected it to whatever, but no sound. (I tried all possible combinations of connections.)

i also installed and ran Cadence but see nothing there that suggests what the problem is.

One possible additional clue: in both Cadence and in QJackCtl the parameters that are shown (for example, sample rate and frames/period are *different* from what are in the Setup menu in QJackCtl and in .jackrc. Not sure how/why that would be.

My focusrite shows up in the MIDI connections in Jack, so it isn't entirely invisibile to Jack, and it definitely isn't invisible to the system as a whole -- as I said in a previous post, I can set the output (in 'Sound Settings) to the Focusrite and it works. Just not in Jack, apparently.

In case it helps:

Code: Select all

$ arecord -l && aplay -l 
**** List of CAPTURE Hardware Devices ****
card 0: SB [HDA ATI SB], device 0: STAC92xx Analog [STAC92xx Analog]
  Subdevices: 2/2
  Subdevice #0: subdevice #0
  Subdevice #1: subdevice #1
card 1: USB [Scarlett 2i4 USB], device 0: USB Audio [USB Audio]
  Subdevices: 1/1
  Subdevice #0: subdevice #0
**** List of PLAYBACK Hardware Devices ****
card 0: SB [HDA ATI SB], device 0: STAC92xx Analog [STAC92xx Analog]
  Subdevices: 1/1
  Subdevice #0: subdevice #0
card 0: SB [HDA ATI SB], device 1: STAC92xx Digital [STAC92xx Digital]
  Subdevices: 1/1
  Subdevice #0: subdevice #0
card 1: USB [Scarlett 2i4 USB], device 0: USB Audio [USB Audio]
  Subdevices: 1/1
  Subdevice #0: subdevice #0
card 2: Generic [HD-Audio Generic], device 3: HDMI 0 [HDMI 0]
  Subdevices: 1/1
  Subdevice #0: subdevice #0
I've got Jack input and output set to hw:1 (in Jack and in .jackrc -- but as I said, Jack seems to be running with a mind of its own...).

In case it helps, here's what QJackCtl says in the main window after I start it:

Code: Select all

Active    RT 0.xx% 48000 Hz
0 (0)                     00:00:00
Stopped  --             -.-.---
One final possible clue: When I reboot the computer and start Jack, the messages in Jack are all benign. If I stopJack the messages in Jack say:

Code: Select all

# making sure pulseaudio will restart if it crashes
# starting pulseaudio
# connecting pulseaudio to JACK
Failure: Module initalization failed
Failure: Module initalization failed
18:54:07.692 Post-shutdown script terminated with exit status=256.
However, if I restart Jack no error messages are displayed and it seems to start up 'normally'.

Re: Dream Studio + Jack/Pulse

Posted: Mon Dec 17, 2012 2:44 am
by mdickson
New Info:

So I was listening to music through RhythmBox, with the sound set to go to "Soeakers/Built-in Audio" (and playing through them), then quit Jack and the sound cut out. I restart Jack and RhythmBox now show up as a device in Jack (it never had before), but no matter how I connect anything (in Jack or on "Sound Settings") I get zero sound.

I'm utterly baffled.

(But: If I quit and restart RhythmBox it plays fine.)

Re: Dream Studio + Jack/Pulse

Posted: Mon Dec 17, 2012 5:25 pm
by Pablo
I am not sure what happens but firstly, you have to be completely sure that jack is configured to use the Scarlett. In what you show, yes, it is hw:1 but this number can change when you reboot the computer, making difficult diagnose the problem. this is typical and very annoying. To make sure, call the card by name instead of by number. In your case, the Scarlett is called hw:USB (double-check via "cat /proc/asound/cards", this should be the short name between square brackets). So, instead of hw:1 or whatever, write down "hw:USB" in the Interface field of qjackctl, even if it is not selectable in the drop-down menu (yes, it is an editable text box). As the Scarlett has a unique duplex device, you don't need to select input and output separately, just use hw:USB as your "Interface".

Secondly, there is jackdbus and jackd and I am not sure about the interaction between them or even the point of jackdbus at all. Then, there is pulseaudio (the default audio server). Sometimes this becomes very confusing... To make sure if jack is running or not (the stop button in qjackctl should be enough but you never know) type in a terminal window:

ps aux | grep jack

This ps command shows the running processes in your computer. "aux" are some options for display. "| grep jack" is a text filter. It means that only the lines that have "jack" (including jackd and jackdbus) in them will be printed. You will see at least a line caused by the grep command itself. But there could be more, if jackd or jackdbus is running despite your thinking you stopped jack.

To start from scratch, kill the jackd /jackdbus process.

killall -9 jackd
killall -9 jackdbus

Cheers, Pablo

Re: Dream Studio + Jack/Pulse

Posted: Thu Dec 20, 2012 1:07 am
by mdickson
OK, piecing together clues from this thread and another on the same topic (at the Dream Studio forum), I was able to come up with a solution

I came to the conclusion that I needed to simplify and that the fact that pulseaudio and jack were running simultaneously was quite possibly the source of my particular problem.

So, in case it helps anybody, here are the steps I took.

First, as a reminder, I'm using a Focusrite Scarlett 2i4 (USB 2) device and Dream Studio with all latest updates. OUTPUT: I've got studio monitors plugged in to outputs 1 and 2 (and a normal consumer amp plugged in to the RCA outputs 1 and 2), and headphones plugged in as well. INPUT: There are mics plugged in at the front and a MIDI controller (M-Audio keyboard) plugged into the MIDI in on the back.

Step 1: Kill Pulseaudio.

This is easier said than done. Edit the file /etc/pulse/client.conf and change the line autospawn = yes to autospawn = no, and set daemon-binary to /bin/true. Make sure these lines are not commented out (don't ask me why I mentioned this point...). Think you're done killing it? Probably not. Also look in ~/.pulse/client.conf and you might have to make the same changes there. Now, I've read online that pulseaudio –kill will, finally do the deed. Didn't work for me. Instead, say

Code: Select all

ps aux | grep pulse
look for the process number (or numbers) and kill them all (kill -9 xxxx where xxxx is the number of a running pulseaudio instance).

OK, now it's dead.

If you want to be sure it stays dead after reboot, you'll need to do some more work. This can be somewhat system-dependent, but will probably involve looking at the files in the various /etc/rc#.d directories and moving files called Sxxpulseaudio (where xx is a number) to Kxxpulseaudio. Depending on your setup, other stuff could be involved, such as editing /etc/rc.local or eliminating a file from ~/.config/autostart.

Probably not a bad idea to reboot at this point and be sure it is well and truly dead.

If you have an application that absolutely needs pulseaudio, you can start it by hand. I've been able to do that, though I do need to be sure that Jack is killed first or ugly things tend to happen. There are various partial guides to getting pulseaudio to play nice with Jack. I was originally attracted to Dream Studio because it looked like it did this successfully. (I guess it does for some. It didn't for me.) If I ever get that working I'll post about it (but I'm not very motivated because I don't seem to be missing life with pulseaudio...).

Step 2: Configure Jack.

Start QJackCtl and open the Setup. Do NOT start Jack from the dropdown 'jack' menu at the top of your screen. At least, this (still) doesn't work for me -- it starts Jack with the wrong settings and I haven't bothered to find out where to edit them. No need.

Dream Studio doesn't have a real-time kernel by default, so uncheck that if it is checked (unless you've switched to a real-time kernel, but if you've successfully done that, then you probably don't need my help...) It is best (as far as I can tell) to use the 'real' name of your audio device rather than its device number (which can change on reboot). So say

Code: Select all

cat /proc/asound/card

and you'll see something like this:

Code: Select all

 0 [SB             ]: HDA-Intel - HDA ATI SB 
                      HDA ATI SB at 0xfeb00000 irq 16 
 1 [USB            ]: USB-Audio - Scarlett 2i4 USB 
                      Focusrite Scarlett 2i4 USB at usb-0000:02:00.0-2, high speed 
 2 [Generic        ]: HDA-Intel - HD-Audio Generic 
                      HD-Audio Generic at 0xfea40000 irq 81 
(Yours likely won't be identical to mine!) In my case, the Focusrite is the device I want Jack to use, so under “Interface” I typed in “hw:USB”. This (or whatever the name of your device is) might not be an option for you in the menu, but you can type it directly in. Do not select anything for 'Input' and 'Output' (assuming that your audio device is duplex, as the Focusrite is). The other settings are beyond the scope of this post. However, it is a good idea to be sure that the file ~/.jackrc matches the config that you've set in QjackCtl. In principle they match. I found a glitch that required me to make them match manually. If you need to learn what the stuff in ~/.jackrc means, say “man jackd” and read. Save your setup.

Not a bad idea to reboot again. Just to be sure. Check that pulseaudio is not running. If it is, go directly back to step 1 without collecting $200.

At this point, I was able to boot the machine, start QjackCtl and from there start Jack. The window says “Started” at the top left, and “Stopped” and the bottom left, which can be a little confusing to a newbie like me, but they are referring to two different things. The top left refers to the fact that jackd is running, and so you can use it to connect stuff to other stuff. The bottom left refers to whether transport control is rolling. (You can roll it by clicking the 'play' button in QjackCtl.) If you click the 'Connect' button in Jack, and if you've got no jack-aware programs running (which is a good idea at this point), you'll see inputs and outputs for 'system'. I was initially disappointed to see this because I thought it was referring to my on-board (crappy) system sound card. Nope. As somebody (very helpfully) pointed out to me in a thread somewhere, all 'system' means is “Jack sees some hardware”. If you've got Jack configured properly and all the stars are aligned, the number of inputs and outputs under 'system' should match what your device actually has (in my case, 2 ins and 4 outs). And if you've been eating your veggies, the numbers attached to those ins and outs should match up with the numbers on your device.

A good test at this point is to fire up a Jack-aware music player such as aqaulung and connect it to your 'system' outputs (probably called 'playback_x” where x is a number. Play around with those connections (with some sound playing of course) and you'll learn, or at least confirm, what the connections are doing. (For example, the Scarlett is able to swap headphone from outputs 1/2 to 3/4. I was able to test that by moving connections around in Jack.)

You might find it more convenient to use Patchage to play with these connections. It is nice, especially when things get complicated.

Anyway, at this stage I was able to start Ardour and record from the mics, play out through the headphones or monitors. The whole nine yards. Success!

On to MIDI... Yeah, reboot again. It just helps.

Step 3. Make MIDI work.

My default for testing MIDI has become (for better or worse) to start up Yoshimi, pray that it shows up in the appropriate places in Jack, and play around with connections until I hear sound. So..., I fired up Yoshimi, selected an instrument (Cathedral Organ 3 if you must know) and looked in Patchage. There I see Yoshimi with a MIDI in and left/right outs. I connected the left/right outs system outs as deisred. I also see, in Patchage, system “midi capture 1” and “midi capture 2”. So I connect “midi capture 1” to yoshimi midi in. Nothing. Then I connect system “midi capture 2” to yoshimi midi in and suddenly I'm channeling Bach preludes through my headphones. Good stuff! I don't know why the Focusrite's midi 'in' is seen as 2 and not 1, but whatever.

Later, I click on the 'Connect > MIDI' tab in QjackCtl and I see that there are in fact SIX MIDI capture ports. I wouldn't be surprised if we need to play around with these to get MIDI devices talking to each other properly, as I certainly will in the near future.

But the good news is that, at this point it looks like all that remains is fine tuning. It appears that I'm able to access all of the functionality of the Scarlett 2i4. I've also run guitarix with my guitar plugged into the Focusrite. More happiness.

Step 4.

Well, there's a lot more to do. The main thing (for me at least) is to get rid of the (fortunately few) Xruns. When recording, I've killed just about everything I can find to kill that isn't essential, and this has done wonders. You might will also want to play with other settings in Jack. There's lots of good advice out on the web about these things. My point here was just to give a little back on the specific issue that prompted my original threads, in thanks to those who helped out.

Re: Dream Studio + Jack/Pulse

Posted: Sun Dec 23, 2012 3:57 pm
by mdickson
Just heard from Dick MacInnis on the Dreamn Studio forum. Two corrections to my previous post:

1. You can check 'realtime' in QJackCtl even without a realtime kernel -- it runs Jack with realtime permissions, which can be done without a realtime kernel.

2. There is a script in Dream Studio to kill pulseaudio (though I believe it will not persist through a reboot). It si called dreamstudio-stop-pulseaudio. (I haven 't tested it b/c pulse is permanently dead on my system...)

Re: Dream Studio + Jack/Pulse

Posted: Sun Dec 23, 2012 5:16 pm
by Pablo
Especialized distros like kxstudio and dreamstudio try to configure the system so that the user does not have to tweak conf files. It is always good to have some know-how but note that some hints you might find on the net were learned at the times where apps like Cadence or custom scripts like dreamstudio's didn't exist.

Nowadays it is supposed to be easier than you describe in your previous post.

Anyway, I am glad you solved the problem and can make some music!