audacious-media-player / audacious

A lightweight and versatile audio player
https://audacious-media-player.org
Other
870 stars 115 forks source link

Wrong channel map when doing surround playback #330

Open Audacious-Bot opened 6 months ago

Audacious-Bot commented 6 months ago

Author Name: Adriano Moura Original Redmine Issue: https://redmine.audacious-media-player.org/issues/196 Original Date: 2012-10-12


Seems that Audacious pulseaudio output plugin has never set an appropriate channel map. This little patch will use pa_channel_map_init_auto and assume WAVEEX style channel mapping. Audacious can now properly output any 5.1 file I trow at it.

Before:

sample spec: float32le 6ch 88200Hz
channel map: front-left,front-left-of-center,front-center,front-right,front-right-of-center,rear-center
resample method: copy
module: 6
client: 20094 <Audacious>

Now:

sample spec: float32le 6ch 88200Hz
channel map: front-left,front-right,front-center,lfe,side-left,side-right
Surround 5.1
resample method: copy
module: 6
client: 20114 <Audacious>

For correct 4.0/6.1/7.1 surround mappings you will need some pulseaudio patches, but I'm still working on this. WAVEEX seems to be wrongly implemented in pulseaudio right now.

add_pulse_chmap.patch.txt

Audacious-Bot commented 6 months ago

Original Redmine Comment Author Name: John Lindgren Original Date: 2012-10-13T17:46:38Z


Won't this break playback formats that use another channel map (like Vorbis)? I think we should decide on one channel map to use throughout Audacious and require decoder plugins to convert to it if necessary. It would be good to do some research on what convention, if any, is used by other software, especially on Linux but on other systems as well. In particular:

  1. Am I correct in saying that Microsoft and Apple formats both use WAVEX?
  2. Vorbis has its own set of channel orderings: http://www.xiph.org/vorbis/doc/Vorbis_I_spec.html#x1-800004.3.9
  3. What convention does FLAC use?
  4. Does MP3 support more than two channels, and if so, what convention does it use?
  5. PulseAudio apparently supports WAVEX; which (if any) other conventions does it support/recommend?
  6. What channel orderings do other Linux sound systems (ALSA, OSS, Jack) allow/expect?
  7. To my knowledge, SDL supports only mono and stereo, so surround playback on Windows will require writing a DirectSound plugin.

I will try to look up the answers to some of these, but I would appreciate help.

Audacious-Bot commented 6 months ago

Original Redmine Comment Author Name: Adriano Moura Original Date: 2012-10-15T01:31:27Z


This patch won't really break anything because what we had before wouldn't properly work with anything aside from mono/stereo. However, it is right to assume that this will only work properly with WAVEEX. But then again, it's better to have something fairly common working than nothing. So far i've tested with a bunch of .flacs, some .wav and .dts and ac3 files. All worked fine.

Ideally we would use pa_channel_map_init and make our own pa_channel_map structure with whatever mapping is required by what we are playing, but that might complicate things a bit.

1) Microsoft yes, but apple might use aiff style mapping. 2) I don't have any vorbis files with surround... 3) They seem to use something similar to WAVEEX sans the bitmask: http://flac.sourceforge.net/format.html#frame_header (Scroll to <4> Channel assignment) 4) Not normally, but the extension does not seem that popular http://en.wikipedia.org/wiki/MP3_Surround

5) That is kind of a problem because as it is now some of their automatic mappings are kind of broken. Also, pa_channel_map_init_auto will never properly support WAVEEX because there is no support for the bitmask. PA has to settle with what is common when a program asks for 7.1 (8ch) WAVEEX. But anyway, as I said, the best would be to set our own chmap and do the conversions internally.

6) Alsa and OSS expect very different mappings. You can take a look at pa source code (pulseaudio/src/pulse/channelmap.c) and you will find how they arrange these, and also WAVEEX/AIFF. 7) You might have some luck asking this one to Steve Ballmer... :)

Audacious-Bot commented 6 months ago

Original Redmine Comment Author Name: John Lindgren Original Date: 2012-10-15T04:57:35Z


I'm not going to accept a patch given only the argument "it works for something fairly common".

Right now we have no channel ordering convention at all -- that is, we pass the data from every decoder library to every sound system exactly as-is. Before we start changing that behavior, it is essential that we decide which convention we are going to use. As a start, here is a quick list of some conventions already in use elsewhere. Please comment to help complete this list or to suggest which convention we should use.

RFC 3551 (more or less matches Apple AIFF): 2: left right 3: left right center 4: left center right rear 5: left right center rear-left rear-right 6: left left-center center right right-center rear

http://datatracker.ietf.org/doc/rfc3551/?include_text=1

FLAC (more or less matches Microsoft WAVE_FORMAT_EXTENSIBLE): 2: left right 3: left right center 4: left right rear-left rear-right 5: left right center rear-left rear-right 6: left right center LFE rear-left rear-right

http://flac.sourceforge.net/format.html#frame_header

Vorbis: 2: left right 3: left center right 4: left right rear-left rear-right 5: left center right rear-left rear-right 6: left center right rear-left rear-right LFE 7: left center right side-left side-right rear LFE 8: left center right side-left side-right rear-left rear-right LFE

http://www.xiph.org/vorbis/doc/Vorbis_I_spec.html#x1-800004.3.9

ALSA: 2: left right 4: left right rear-left rear-right 6: left right rear-left rear-right center LFE 8: left right rear-left rear-right center LFE side-left side-right

http://www.volkerschatz.com/noise/alsa.html http://permalink.gmane.org/gmane.comp.video.ffmpeg.devel/148163

Audacious-Bot commented 6 months ago

Original Redmine Comment Author Name: Adriano Moura Original Date: 2012-10-19T00:01:52Z


I would only add for FLAC both 7 and 8 undefined channels as whatever is used in WAVEEX:

FLAC 7: left right center LFE rear-left rear-right rear-center 8: left right center LFE rear-left rear-right side-left side-right

I'm sorry if I'm not providing elegant solutions... I was just disappointed that most linux software weren't working properly with surround audio and hacked some simple stuff.

Audacious-Bot commented 6 months ago

Original Redmine Comment Author Name: Larry Hastings Original Date: 2020-10-17T10:17:57Z


For what it's worth: this seems like it's still true. On my Ubuntu desktop*, if I play a 6 channel FLAC in VLC on my 7.1 stereo, it sounds great. If I play the same file in Audacious 4.0.5, the channels are all moved around. For example nothing comes out of my Front Right speaker when using Audacious, but when using VLC I'm definitely getting something.

I don't understand the technical issues involved. All I know is, I can use VLC for this and it works, so for now I'll stick with that. But naturally it'd be lovely if it worked in Audacious too!

Audacious-Bot commented 6 months ago

Original Redmine Comment Author Name: John Lindgren Original Date: 2021-04-13T03:48:24Z


Removing "with PulseAudio" from the title as this is a broader issue and affects e.g. ALSA as well. See also #1221.