Skip to contentSkip to conversation

Long-standing 5.1ch huge LFE/rear swap annoyance (ALSA vs. Windows!)

DISCUSSION Andreas Mohr 6 participants 8 messages Nov 18, 2006 – Nov 21, 2006

lore
Share & tools
lore
#0 lore raw

Hi,

as I'm trying to improve support for my el-cheapo USB audio adapter, I found that one of the bigger issues is swapping of Center/LFE vs. rear speakers, as can be seen when running

speaker-test -c 6 -D pcm.USBAudio

Having ALSA use different output assignment versus the printed labels on the box is somewhat of a PITA, I'd say.

This doesn't only happen with my card, but with many many many many many (yes, I did quite some research) other cards:

http://cvs.icculus.org/cvs/twilight/darkplaces/snd_main.c?rev=1.53
"// Our speaker layouts are based on ALSA. They differ from those // Win32 and Mac OS X APIs use when there's more than 4 channels. // (rear left + rear right, and front center + LFE are swapped). "
(probably the most insightful comment on the entire web)

http://alsa.opensrc.org/SurroundSound
"Some of the six channel wave files that you can find on the web are in "wave extensible" format, which have the interleaved channels in an order differing from what Alsa expects (center and lfe come before left and right rear). It's a MS thing. You can play those with sfplay, a simple command line player I adapted from an example program in Erik de Castro Lopo's libsndfile distribution. sfplay recognizes wave extensible files and flips the channel order so they can be played using Alsa."
(second most insightful)

http://lists.mplayerhq.hu/pipermail/mplayer-dev-eng/2003-June/019180.html
http://blog.gmane.org/gmane.linux.alsa.devel/month=20051101
http://www.mythtvtalk.com/forum/viewtopic.php?t=1858&view=previous
http://www.nvnews.net/vbulletin/showthread.php?t=62108
http://www.cse.ohio-state.edu/~bondhugu/alsamch.shtml
http://ubuntuforums.org/showthread.php?t=253725&page=5
etc.pp. ad nauseam.

(search bug tracking for "swap" for two tons more reports of swapped channels)

One could even be brave enough to ask "are there *any* 5.1 cards which work correctly on ALSA??" ;), as such we should think hard about adding generic support to compensate for this, *automatically*.

[yes, I know about asoundrc hackery to semi-easily get this tweaked]

My theory is that since wave extensible is an established format with different channel ordering that some soundcards chose to use this swapped ordering in hardware.
And ALSA didn't care much since it didn't want to have to expensively remix samples into correct order?

But OTOH *if* the comment above is correct and ALSA *does* employ a modified channel order vs. Windows and Mac OS X, then it seems as if it might be speaker-test which *doesn't* obey this ALSA ordering??? But that could probably be checked by playing some public surround .wav samples or DVD playback or so.

Could we please try to put an end to this insanity?

Is there anyone who has extensive experience with 5.1 surround channel ordering status of many different soundcards on ALSA? How many "ok", how many swapped?

Oh, and if the answer is that I should try to fix this on a per-driver (per-card) basis, then could anyone tell me where the heck I'd have to tweak snd-usb-audio for correct channel order?

Rather confused,

Andreas Mohr (a non-Surround user who still cares as much as even writing this whole mail)

-------------------------------------------------------------------------
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your opinions on IT & business topics through brief surveys - and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV

#1 lore raw

Comment at the bottom...

Quoted 76 lines · Andreas Mohr

Hi,

as I'm trying to improve support for my el-cheapo USB audio adapter, I found that one of the bigger issues is swapping of Center/LFE vs. rear speakers, as can be seen when running

speaker-test -c 6 -D pcm.USBAudio

Having ALSA use different output assignment versus the printed labels on the box is somewhat of a PITA, I'd say.

This doesn't only happen with my card, but with many many many many many (yes, I did quite some research) other cards:

http://cvs.icculus.org/cvs/twilight/darkplaces/snd_main.c?rev=1.53
"// Our speaker layouts are based on ALSA. They differ from those // Win32 and Mac OS X APIs use when there's more than 4 channels. // (rear left + rear right, and front center + LFE are swapped). "
(probably the most insightful comment on the entire web)

http://alsa.opensrc.org/SurroundSound
"Some of the six channel wave files that you can find on the web are in "wave extensible" format, which have the interleaved channels in an order differing from what Alsa expects (center and lfe come before left and right rear). It's a
MS thing. You can play those with sfplay, a simple command line player I adapted from an example program in Erik de Castro Lopo's libsndfile distribution. sfplay recognizes wave extensible files and flips the channel order so they can be played using Alsa."
(second most insightful)

http://lists.mplayerhq.hu/pipermail/mplayer-dev-eng/2003-June/019180.html
http://blog.gmane.org/gmane.linux.alsa.devel/month=20051101
http://www.mythtvtalk.com/forum/viewtopic.php?t=1858&view=previous
http://www.nvnews.net/vbulletin/showthread.php?t=62108
http://www.cse.ohio-state.edu/~bondhugu/alsamch.shtml
http://ubuntuforums.org/showthread.php?t=253725&page=5
etc.pp. ad nauseam.

(search bug tracking for "swap" for two tons more reports of swapped channels)

One could even be brave enough to ask "are there *any* 5.1 cards which work correctly on ALSA??" ;), as such we should think hard about adding generic support to compensate for this, *automatically*.

[yes, I know about asoundrc hackery to semi-easily get this tweaked]

My theory is that since wave extensible is an established format with different
channel ordering that some soundcards chose to use this swapped ordering in hardware.
And ALSA didn't care much since it didn't want to have to expensively remix samples
into correct order?

But OTOH *if* the comment above is correct and ALSA *does* employ a modified channel
order vs. Windows and Mac OS X, then it seems as if it might be speaker-test which
*doesn't* obey this ALSA ordering??? But that could probably be checked by playing
some public surround .wav samples or DVD playback or so.

Could we please try to put an end to this insanity?

Is there anyone who has extensive experience with 5.1 surround channel ordering status
of many different soundcards on ALSA? How many "ok", how many swapped?

Oh, and if the answer is that I should try to fix this on a per-driver (per-card)
basis, then could anyone tell me where the heck I'd have to tweak snd-usb-audio
for correct channel order?

Quoted 4 lines

Rather confused,

Andreas Mohr (a non-Surround user who still cares as much as even writing this whole mail)

I have just dealt with this channel-swapping issue last month:
http://sourceforge.net/mailarchive/message.php?msg_id=37102586

Microsoft's Channel Ordering API is explained in this URL:
http://www.microsoft.com/whdc/device/audio/multichaud.mspx

Default Channel Ordering and dwChannelMask are what matter most.

As it is now, there appeared to have 5.1 channels media files in Microsoft's channel ordering and there are others in ALSA's ordering.

There needs a systematic and comprehensive way to detect which of the two ordering the clip is using. Suggestion would be great.

Signature · 8 lines
Daniel Yek


-------------------------------------------------------------------------
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your
opinions on IT & business topics through brief surveys - and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
#2 lore raw
In reply to Andreas Mohr
Quoted 8 lines · Andreas Mohr

as I'm trying to improve support for my el-cheapo USB audio adapter, I found that one of the bigger issues is swapping of Center/LFE vs. rear speakers, as can be seen when running

speaker-test -c 6 -D pcm.USBAudio

My theory is that since wave extensible is an established format with different channel ordering that some soundcards chose to use this swapped ordering in hardware.

Some do, some don't.

Quoted 2 lines

And ALSA didn't care much since it didn't want to have to expensively remix samples into correct order?

Rerouting channels is actually quite cheap.

Quoted 3 lines

But OTOH *if* the comment above is correct and ALSA *does* employ a modified channel order vs. Windows and Mac OS X, then it seems as if it might be speaker-test which *doesn't* obey this ALSA ordering???

speaker-test _does_ obey the ALSA ordering. However, USB devices do not, and there is not yet an ALSA configuration file for remapping channels on USB devices.

This is a bug in the ALSA library.

Quoted 1 line

Could we please try to put an end to this insanity?

I'm working on this.

Quoted 2 lines

Is there anyone who has extensive experience with 5.1 surround channel ordering status of many different soundcards on ALSA? How many "ok", how many swapped?

AFAIK USB devices are the only ones where channels are swapped.

Quoted 3 lines

Oh, and if the answer is that I should try to fix this on a per-driver (per-card) basis, then could anyone tell me where the heck I'd have to tweak snd-usb-audio for correct channel order?

You would have to write /usr/share/alsa/cards/USB-Audio.conf.

HTH
Clemens

-------------------------------------------------------------------------
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your opinions on IT & business topics through brief surveys - and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV

#3 lore raw

At Mon, 20 Nov 2006 15:06:50 +0100,

Quoted 10 lines · Clemens Ladisch
Quoted 4 lines

But OTOH *if* the comment above is correct and ALSA *does* employ a modified channel order vs. Windows and Mac OS X, then it seems as if it might be speaker-test which *doesn't* obey this ALSA ordering???

speaker-test _does_ obey the ALSA ordering. However, USB devices do not, and there is not yet an ALSA configuration file for remapping channels on USB devices.

This is a bug in the ALSA library.

I'd call it rather a configuration bug.

Quoted 3 lines
Quoted 1 line

Could we please try to put an end to this insanity?

I'm working on this.

What solution in sight?

Quoted 4 lines
Quoted 2 lines

Is there anyone who has extensive experience with 5.1 surround channel ordering status of many different soundcards on ALSA? How many "ok", how many swapped?

AFAIK USB devices are the only ones where channels are swapped.

Possibly some ice172x-based devices may have similar problems. There are many untested boards.

Takashi

-------------------------------------------------------------------------
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your opinions on IT & business topics through brief surveys - and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV

#4 lore raw

Hi,

Quoted 13 lines · Takashi Iwai

At Mon, 20 Nov 2006 15:06:50 +0100,

Quoted 10 lines · Clemens Ladisch
Quoted 4 lines

But OTOH *if* the comment above is correct and ALSA *does* employ a modified channel order vs. Windows and Mac OS X, then it seems as if it might be speaker-test which *doesn't* obey this ALSA ordering???

speaker-test _does_ obey the ALSA ordering. However, USB devices do not, and there is not yet an ALSA configuration file for remapping channels on USB devices.

This is a bug in the ALSA library.

Quoted 8 lines

I'd call it rather a configuration bug.

Quoted 3 lines
Quoted 1 line

Could we please try to put an end to this insanity?

I'm working on this.

What solution in sight?

Sorry for the strong wording ;)
I'll have a look at getting done an USB-Audio channel config.

Quoted 7 lines
Quoted 4 lines
Quoted 2 lines

Is there anyone who has extensive experience with 5.1 surround channel ordering status of many different soundcards on ALSA? How many "ok", how many swapped?

AFAIK USB devices are the only ones where channels are swapped.

Possibly some ice172x-based devices may have similar problems. There are many untested boards.

To me it sounded like that scope is far bigger than USB-only, from internet research (and bug tracker).

I also had a quick visit to #ubuntu (openprojects) where I was absolutely SHOCKED about the amount of sound config issues. Those even exceeded the amount of wireless configuration requests. At least 3 sound/mixer issues within the one hour that I was in there (weirdly swapped channels on surround, almost no sound or none at all, ...).

Thus I think there should be more effort towards getting currently implemented chipset drivers to work on all those cards easily.
Of course this is much easier said than done...

Andreas Mohr

-------------------------------------------------------------------------
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your opinions on IT & business topics through brief surveys - and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV

#5 lore raw
Quoted 9 lines · Andreas Mohr

I also had a quick visit to #ubuntu (openprojects) where I was absolutely SHOCKED about the amount of sound config issues. Those even exceeded the amount of wireless configuration requests. At least 3 sound/mixer issues within the one hour that I was in there (weirdly swapped channels on surround, almost no sound or none at all, ...).

Thus I think there should be more effort towards getting currently implemented chipset drivers to work on all those cards easily. Of course this is much easier said than done...

It would help tremendously if the Ubuntu people could push these upstream. Bugs that end up in the ALSA bug tracker do get addressed. Sometimes I think that the distro people assume that ALSA developers must know about all these issues, which is impossible because of the amount of hardware out there.

Lee

-------------------------------------------------------------------------
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your opinions on IT & business topics through brief surveys - and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV

#6 lore raw
In reply to Takashi Iwai
Quoted 8 lines · Takashi Iwai
Quoted 5 lines · Clemens Ladisch

...
and there is not yet an ALSA configuration file for remapping channels on USB devices.
...
I'm working on this.

What solution in sight?

Creating a surround51 device with a route plugin is trivial.

Selecting device-specific device definitions can be done with a new card_shortname configuration function and lots of indirections.

The biggest problem is dmix. I do no want to impose some default sample rate/format on unknown devices because this would break most USB headsets or other unusual devices. I think the best solution would be to add an option to dmix to automatically select some suitable sample format when it's first opened.

Regards,
Clemens

-------------------------------------------------------------------------
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your opinions on IT & business topics through brief surveys - and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV

#7 lore raw

At Tue, 21 Nov 2006 11:21:19 +0100,

Quoted 9 lines · Clemens Ladisch
Quoted 7 lines · Takashi Iwai
Quoted 5 lines · Clemens Ladisch

...
and there is not yet an ALSA configuration file for remapping channels on USB devices.
...
I'm working on this.

Quoted 6 lines
Quoted 1 line

What solution in sight?

Creating a surround51 device with a route plugin is trivial.

Selecting device-specific device definitions can be done with a new card_shortname configuration function and lots of indirections.

OK. My initial thought is to use USB IDs, but shortname should be enough, too.

For a long term solution, we can create an API for the driver to provide the channel-mapping information. This could be done, for example, by a special read-only control element, or via a new ioctl. IIRC, usb descriptor contains the channel-mapping information, so this process could be (partly) automated instead of device-base configuration.

Quoted 5 lines

The biggest problem is dmix. I do no want to impose some default sample rate/format on unknown devices because this would break most USB headsets or other unusual devices. I think the best solution would be to add an option to dmix to automatically select some suitable sample format when it's first opened.

Agreed. For example, we can change the dmix code to accept the rate option as a list instead of an integer. When it's a list, dmix tries to choose the first matching one via hw_params call.

Takashi

-------------------------------------------------------------------------
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your opinions on IT & business topics through brief surveys - and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV