Bug 94563

Summary: Option to minimally upmix or remap "mono" channel only (for speaker configurations greater than 2.x)
Product: PulseAudio Reporter: freedesktop
Component: daemonAssignee: pulseaudio-bugs
Status: RESOLVED FIXED QA Contact: pulseaudio-bugs
Severity: normal    
Priority: medium CC: lennart
Version: unspecified   
Hardware: Other   
OS: All   
Whiteboard:
i915 platform: i915 features:

Description freedesktop 2016-03-16 02:58:21 UTC
At present, PA's remix logic seems to work well for 2.0 speaker configurations:

* Mono is upmixed to each channel (so its apparent origin for a person in front of the speakers is front/centre
* Stereo goes to the relevant channels
* 5.1 etc. are downmixed to the left and right channels - centre is mixed to both, etc.

It doesn't work well for 5.1 speaker configurations:

* Mono is upmixed to all channels, instead of either front-left+front-right or centre only (so its apparent origin for a centrally positioned user is in their head, more or less, instead of front/cenre)
* Stereo is upmixed to all channels, instead of being mapped to front-left and front-right (this happens even with a sink input with "channel map: front-left,front-right)
* 5.1 goes to the correct channels. Not 100% sure about 7.1 etc.

If remixing is disabled with a 5.1 speaker configuration:

* Mono audio (sink input with "channel map: mono") is discarded entirely
* Stereo goes to front-left and front-right
* 5.1 goes to the correct channels. Presumably additional channels from 7.1 etc. are lost.

Applications such as Firefox appear as a mono sink input when playing back mono audio (of which there are many examples on the web, for instance many YouTube and Twitter videos and probably many more). At present a PA user has to choose between one of:

* No audio output in these cases (and other applications presenting a mono source), or
* Both mono and stereo audio being upmixed to *all* channels, or
* Continually switching PA's speaker configuration from 2.0 to 5.1, or
* Continually toggling PA remixing.

A presumably fairly easy fix so 5.1 users could avoid this would be an option to remap the "mono" channel to "centre". Another would be to have the option to upmix mono to front-left+front-right.

Note, this is not the same as bug 39360, which started as a request to have auto-switching of PA speaker configuration, and evolved into a request for more sophisticated "least-necessary" remixing.
Comment 1 Raymond 2016-03-16 07:00:30 UTC
https://cgit.freedesktop.org/pulseaudio/pulseaudio/commit/?id=a9059be749b6043d6cbc5b79652e8a4adda8994e

IF LFE mixing is enabled by default, this mean the mono signal has already pass through the high pass filter

can you post the pulseaudio channel matrix in the pulseaudio verbose server log
Comment 2 Raymond 2016-03-16 07:09:11 UTC
if you are using hda-intel, this may be bug of the driver when playing stereo to 5.1 since it is driver copy front to surround channels

https://git.kernel.org/cgit/linux/kernel/git/tiwai/sound.git/commit/sound/pci/hda/hda_codec.c?id=4b3acaf5b56f53ef259a6ddf8e17dcb529631d9b
Comment 3 Raymond 2016-03-16 15:20:13 UTC
(In reply to freedesktop from comment #0)

> * Stereo is upmixed to all channels, instead of being mapped to front-left
> and front-right (this happens even with a sink input with "channel map:
> front-left,front-right)
> * 5.1 goes to the correct channels. Not 100% sure about 7.1 etc.
> 

 you may need to mute surround , center/lfe playback switchrwhen playing stereo since snd-hda-intel provide upmix when you play stereo
Comment 4 Raymond 2016-03-16 15:23:12 UTC
the alternative is to create a control which allow you to enable/disable this upmix by the driver
Comment 5 freedesktop 2016-03-18 14:46:43 UTC
(In reply to Raymond from comment #3)
>  you may need to mute surround , center/lfe playback switchrwhen playing
> stereo since snd-hda-intel provide upmix when you play stereo

In which case I should expect upmixing to happen when enable-remixing in PA is disabled, but that is not the case. Am I missing something?

(In reply to freedesktop from comment #0)
> If remixing is disabled with a 5.1 speaker configuration:

> * Stereo goes to front-left and front-right
Comment 6 freedesktop 2016-03-18 14:48:16 UTC
(In reply to Raymond from comment #1)
> https://cgit.freedesktop.org/pulseaudio/pulseaudio/commit/
> ?id=a9059be749b6043d6cbc5b79652e8a4adda8994e
> 
> IF LFE mixing is enabled by default, this mean the mono signal has already
> pass through the high pass filter

I don't have it enabled, but would that be relevant to this issue in any case?
Comment 7 Raymond 2016-03-18 15:34:53 UTC
It is the hda-intel driver which upmix stereo to  5.1 or 7.1


if card 1 is your hda intel with analog codec 


speaker-test -c2 -t wav -D hw:1,0 

You have to ask the author who wrote the patch 
"feed front to surround"
Comment 8 Raymond 2016-03-18 15:50:57 UTC
If you can hear signal from those surround speakers
 

http://git.alsa-project.org/?p=alsa-lib.git;a=blob;f=src/conf/cards/HDA-Intel.conf;hb=HEAD


Need to add hook to front device which mute the suuround playback switch so that only front speakers are unmuted
Comment 9 freedesktop 2016-03-18 16:08:24 UTC
(In reply to Raymond from comment #7)
> It is the hda-intel driver which upmix stereo to  5.1 or 7.1
> 
> 
> if card 1 is your hda intel with analog codec 
> 
> 
> speaker-test -c2 -t wav -D hw:1,0 
> 
> You have to ask the author who wrote the patch 
> "feed front to surround"

With analogue 5.1 I am getting front->rear copying, but not on HDMI 5.1 (which is what I use ordinarily).

On HDMI though, with PA remixing enabled, there is still mono and stereo upmix to all 6 channels, so that suggests that PA is doing the upmixing in that case.
Comment 10 Raymond 2016-03-20 02:01:18 UTC
For hdmi, you have to provide output of

xrandr --verbose

This contain EDID of your HDMI monitor/receiver 

https://cgit.freedesktop.org/xorg/app/edid-decode/tree/edid-decode.c
Comment 11 Raymond 2016-03-20 02:08:36 UTC
(In reply to freedesktop from comment #9)
> (In reply to Raymond from comment #7)
> > It is the hda-intel driver which upmix stereo to  5.1 or 7.1
> > 
> > 
> > if card 1 is your hda intel with analog codec 
> > 
> > 
> > speaker-test -c2 -t wav -D hw:1,0 
> > 
> > You have to ask the author who wrote the patch 
> > "feed front to surround"
> 
> With analogue 5.1 I am getting front->rear copying,

The problem is left and right channel copy to center and LFE
Comment 12 freedesktop 2016-03-27 20:28:53 UTC
(In reply to Raymond from comment #10)
> For hdmi, you have to provide output of
> 
> xrandr --verbose
> 
> This contain EDID of your HDMI monitor/receiver 
> 
> https://cgit.freedesktop.org/xorg/app/edid-decode/tree/edid-decode.c

Shouldn't have any relevance to this bug, or am I missing something?
Comment 13 freedesktop 2016-03-27 20:31:44 UTC
(In reply to Raymond from comment #11)
> (In reply to freedesktop from comment #9)
> > (In reply to Raymond from comment #7)
> > > It is the hda-intel driver which upmix stereo to  5.1 or 7.1
> > > 
> > > 
> > > if card 1 is your hda intel with analog codec 
> > > 
> > > 
> > > speaker-test -c2 -t wav -D hw:1,0 
> > > 
> > > You have to ask the author who wrote the patch 
> > > "feed front to surround"
> > 
> > With analogue 5.1 I am getting front->rear copying,
> 
> The problem is left and right channel copy to center and LFE

OK, so you're saying that with analogue PA is only remixing stereo to FL+C+FR+LFE, and only hda-intel is doing front->rear copying?
Comment 14 Raymond 2016-03-28 00:57:57 UTC
https://git.kernel.org/cgit/linux/kernel/git/tiwai/sound.git/commit/sound/core?id=2d3391ec0ecca37efb6bc995906292f47522b471

There are std and alt channel map, some sound card/hda codec may support center/lfe swap
Comment 15 Raymond 2016-03-28 01:26:18 UTC
http://voices.canonical.com/david.henningsson/2011/11/29/turn-your-mic-jack-into-a-headphone-jack/
If your stereo speaker is connected to grey jack, you just need pulseaudio to mute side playback switch when playing stereo or surround51
Comment 16 Raymond 2016-03-28 01:31:24 UTC
http://git.alsa-project.org/?p=alsa-lib.git;a=blob;f=src/conf/cards/HDA-Intel.conf;hb=HEAD

Just add hooks to mute side playback switch to front and surround51 and unmute side playback switch to surround71
Comment 17 freedesktop 2016-03-28 01:47:47 UTC
You've lost me.

* Channel maps don't relate to upmixing/remixing do they?
* With analogue the speakers are connected to the standard jacks. This issue is also seen with HDMI audio so nothing related to only analogue jack connections will fix it.
* You're also describing 7.x (or greater) setups that would include side channels, which I don't have and so can't test, but I'm not sure what the connection is to the initially described issue in any case?
Comment 18 freedesktop 2016-04-10 11:51:59 UTC
Please let me know if this bug is waiting on information from me.
Comment 19 Raymond 2016-04-10 12:39:20 UTC
you have to provide info of your HDMI 

https://git.kernel.org/cgit/linux/kernel/git/tiwai/sound.git/commit/sound/pci/hda/patch_hdmi.c?id=5a61358433b1f89b500f2c365746c73cb7a27e2f


output of alsa-info.sh


xrandr --verbose 


your HDMI receiver EDID
Comment 20 Tanu Kaskinen 2017-01-08 21:04:34 UTC
This is now fixed in the "next" branch. There's a new daemon.conf option, "remixing-use-all-sink-channels". By default it's set to "yes", which keeps the old remixing behaviour. Setting the option to "no" changes the remixing logic so that we don't try to fill all output channels if there are no corresponding input channels, but all input channels are still mixed to some output.

Thanks to David Mandelberg for implementing the change, and to Alexander Patrakov for coming up with the idea!
Comment 21 freedesktop 2017-01-08 23:05:53 UTC
Fantastic, thanks!

So this new option will, for example, route a mono signal to the centre channel (or to FL+FR?) when outputting to a 5.1, 7.1 etc. setup?
Comment 22 Tanu Kaskinen 2017-01-09 00:18:07 UTC
Mono audio will go to the center channel when that's available. Otherwise it will go to left+right. If those are not available either, it will go to all channels.

Use of freedesktop.org services, including Bugzilla, is subject to our Code of Conduct. How we collect and use information is described in our Privacy Policy.