Jackd doesn't like my Headphones (pulse does)

What other apps and distros do you use to round out your studio?

Moderators: MattKingUSA, khz

Post Reply
airfritz
Posts: 1
Joined: Fri Oct 22, 2010 1:10 pm

Jackd doesn't like my Headphones (pulse does)

Post by airfritz »

Hi,

I'm running Ubuntu 10.10 with jackd 1.9.6. With pulseaudio, the speakers shutdown when I plug in headphones, and sound is going to the headphones only. If I kill pulse, start jackd and fire up alsaplayer -o jack some.mp3, I get sound from the speakers. If I then connect the headphones, the speakers shutdown, but there's no sound on the headphones.

Is there any configuration setting that I have missed?

Best regards,
Christian
Havoc
Established Member
Posts: 179
Joined: Sat Oct 04, 2008 6:57 pm

Re: Jackd doesn't like my Headphones (pulse does)

Post by Havoc »

This isn't a Jack problem but an Alsa problem. I see 2 possibilities:

- first check with alsamixer that everything is unmuted. Sometimes there are separate controls for the headphones and speakers

- then it can be because the wrong codec is selected with the "option ... model=..." statement. Like here: https://help.ubuntu.com/community/HdaIntelSoundHowto and more specific here: http://www.kernel.org/pub/linux/kernel/ ... udio_codec If this is your problem then some experimenting will be needed.
tedfelix
Posts: 2
Joined: Sun Aug 07, 2011 2:48 am

Re: Jackd doesn't like my Headphones (pulse does)

Post by tedfelix »

I've been struggling with this for two or three weeks and I finally found a solution that works for me. It turns out that my laptop has 4 output channels. Two of them go to the speakers while the other two go to the headphones. I used jack_lsp to list the JACK audio ports I have and the connections (using the -c option) like this:

Code: Select all

$ jack_lsp -c
system:capture_1
system:capture_2
system:playback_1
   fluidsynth:l_00
system:playback_2
   fluidsynth:r_00
system:playback_3
system:playback_4
fluidsynth:l_00
   system:playback_1
fluidsynth:r_00
   system:playback_2
This shows fluidsynth connected to system:playback_1 and system:playback_2. Those two channels happen to be the speakers. What I needed to do is get fluidsynth connected to channels 3 and 4 as well. I used jack_connect to do this:

$ jack_connect fluidsynth:l_00 system:playback_3
$ jack_connect fluidsynth:r_00 system:playback_4

And now the headphones work fine.

You can also use patchage to do this graphically. I think qjackctl lets you examine and modify connections as well. qjackctl usually crashes for me, so I've not been able to try it.

Ted.
tedfelix
Posts: 2
Joined: Sun Aug 07, 2011 2:48 am

Re: Jackd doesn't like my Headphones (pulse does)

Post by tedfelix »

Well, the above fix works for me in some situations, but not in others. It appears that messing with connections like that is troublesome as applications commonly modify JACK connections. So with some programs you might find that it works for a time, but then stops working.

Fortunately, I have discovered another solution. Using the .asoundrc file, you can create a virtual device that remaps the channels on your soundcard. Here's my .asoundrc:

Code: Select all

# hpfixpb - Headphone Fix Playback Side
# This one routes two channels to hw:0's channels 1,3 and 2,4.
# Requires JACK's "-P" option as there's no capture side to this.
# JACK complains that this brings in the plug layer.  When using plughw:0
# I have all sorts of trouble.  But this works fine for me.  I think it is
# safe to ignore JACK's warnings.
pcm.hpfixpb {
	type route

	# Our slave is "hw:0" which has 4 channels
	slave.pcm "hw:0"
	slave.channels 4

	# Transfer Table
	# ch0 => slave ch0 (speaker left), volume = 1 (full)
	ttable.0.0 1
	# ch1 => slave ch1 (speaker right), volume = 1 (full)
	ttable.1.1 1
	# ch0 => slave ch2 (headphone left), volume = 1 (full)
	ttable.0.2 1
	# ch1 => slave ch3 (headphone right), volume = 1 (full)
	ttable.1.3 1
}

# We also need a "ctl" or else ALSA will complain.  Note that there
# is no "device" line.
ctl.hpfixpb {
	type hw
	card 0
}

# hpfix - Headphone Fix
# This combines hpfixpb on the playback side with the hardware interface on
# the capture side to give us one virtual device "hpfix" we can use to fix
# the headphone problem.  Just launch jackd like this:
#   jackd -d alsa --period 32 --device hpfix
# Tested both sides with ardour and audacity.  No problems.
pcm.hpfix {
	type asym
	playback.pcm "hpfixpb"
	capture.pcm "hw:0"
}

# Again, the mandatory "ctl".
ctl.hpfix {
	type hw
	card 0
}
As the comments explain, with this .asoundrc in place (in your home directory: ~/.asoundrc), you can use "hpfix" instead of the usual "hw:0":

Code: Select all

jackd -d alsa --period 32 --device hpfix
This is working fine for me so far.

Ted.
emarsk
Established Member
Posts: 96
Joined: Wed Jul 27, 2011 3:50 pm

Re: Jackd doesn't like my Headphones (pulse does)

Post by emarsk »

Is there a way to make this solution work with falktx's cadence? I'm trying right now but I can't find a way, and if I start jackd by hand, the cadence tools seem to think that there's no jackd running at all, even if it's working fine.
Also, I had to make .asoundrc read-only because it was been overwritten (by cadence, I suppose).

PS: This is my first post here, even if I've been following for some time, so "hello to everybody :D"
Please, avoid some common spelling errors:
http://theoatmeal.com/comics/misspelling
emarsk
Established Member
Posts: 96
Joined: Wed Jul 27, 2011 3:50 pm

Re: Jackd doesn't like my Headphones (pulse does)

Post by emarsk »

What a pity... having to manually re-route the outputs every time is so a PITA! And Cadence is so nice!
Please, avoid some common spelling errors:
http://theoatmeal.com/comics/misspelling
emarsk
Established Member
Posts: 96
Joined: Wed Jul 27, 2011 3:50 pm

Re: Jackd doesn't like my Headphones (pulse does)

Post by emarsk »

I found another solution. And it works with cadence too! :mrgreen:
It just suffices to tell jackd to use only 2 output channels:

Code: Select all

jackd -dalsa --outchannels 2
or for short:

Code: Select all

jackd -dalsa -o2
(Plus any other parameter you may like as "-r44100" an so on...)

In cadence you can set "Output Channels" to "2" in the jack configuration window.

It seems to work fine for me.
Please, avoid some common spelling errors:
http://theoatmeal.com/comics/misspelling
noisemaker
Established Member
Posts: 12
Joined: Thu Oct 27, 2011 7:12 am

Re: Jackd doesn't like my Headphones (pulse does)

Post by noisemaker »

i had similar problems with my both laptops. i have figured that you have to have to plug in the headphone jack befor you do start the jackd server.. you schould use hw:0 if you use the standard onboard laptop sndcrd... after the server has started you need to set the connections of the audio output of the desired application to the outputs 3/4 of the sndcrd...

also sometimes it is helpfull to open the terminal and use alsamixer to see if there is anything muted and so on.. i also suggest not to use pulse audio and jackd together.. i also use ubuntu 11,04 but uninstalled all of pulseaudio.. i only use alsa and jackd thats it
Post Reply