You are not logged in.

#1 2011-04-25 05:31:57

jcci
Member
From: China / Germany
Registered: 2007-06-10
Posts: 185

[Solved] Alsa with 24 bit Output Exclusively

This might be an unusual request hoping to find any ALSA expert. Hope this is a right place to post.

I just made an asynchronous USB2 audio device supporting 44.1k, 48k, 88.2, 96k, 192k sampling frequencies. The firmware so far just supports 24bit word length. Since this is a truly audiophile device the mixer / re-sampler is no option although it works (e.g. Amarok with Xine backend). MPlayer plays bit-perfect as long as the content is 24 bit and one of the above sampling frequencies - works since ALSA update in February 2011. It is really fun this way! However, most peoples's music content is 16 bit.
For Windows the ASIO driver is solving the problem, but I doubt it transfers bit-perfect (Tests to follow soon).
I really would like to recommend Linux for the use, but in this case the problem must be resolved. i could imagine 2 ways of doing:
1. Simple: ALSA is configured to output any content with 24 bit word length. Means adding zeros after the 16th bit.
                Disadvantage: Following Digital to Analog converters would accept the signal as true 24 bit and skip the quantization smoothing.
2. Perfect: If there is an available option for doing this re-quantization in Alsa or MPlayer it would be perfect. As long as the algorithm is good, it doesn't matter this process is done within the DAC or within the computer.

My goal is to make a clear instruction of how to use our device with Linux without compromise.
Thanks for any idea!

Last edited by jcci (2011-05-04 02:41:04)

Offline

#2 2011-04-25 13:17:08

toofishes
Developer
From: Chicago, IL
Registered: 2006-06-06
Posts: 602
Website

Re: [Solved] Alsa with 24 bit Output Exclusively

You can do something like this for ALSA that does a straight upsample. I'd be interested to hear responses to your second query though; this does no re-quantization at all.

pcm_slave.slave_format_s32le {
  pcm "plug:front"
  format "S32_LE"
}

pcm.front32 {
  @args [ CARD DEV ]
  @args.CARD {
    type string
  }
  type plug
  slave slave_format_s32le
  hint {
    show {
      @func refer
      name defaults.namehint.basic
    }
    description "Front speakers, converted to S32_LE"
    device 0
  }
}

pcm.!default front32

Offline

#3 2011-04-25 13:36:42

brebs
Member
Registered: 2007-04-03
Posts: 3,742

Re: [Solved] Alsa with 24 bit Output Exclusively

jcci wrote:

re-quantization

Have you looked for a LADSPA plugin to do that?

Offline

#4 2011-04-25 13:58:36

GogglesGuy
Member
From: Rocket City
Registered: 2005-03-29
Posts: 610
Website

Re: [Solved] Alsa with 24 bit Output Exclusively

jcci wrote:

This might be an unusual request hoping to find any ALSA expert. Hope this is a right place to post.

I just made an asynchronous USB2 audio device supporting 44.1k, 48k, 88.2, 96k, 192k sampling frequencies. The firmware so far just supports 24bit word length. Since this is a truly audiophile device the mixer / re-sampler is no option although it works (e.g. Amarok with Xine backend). MPlayer plays bit-perfect as long as the content is 24 bit and one of the above sampling frequencies - works since ALSA update in February 2011. It is really fun this way! However, most peoples's music content is 16 bit.
For Windows the ASIO driver is solving the problem, but I doubt it transfers bit-perfect (Tests to follow soon).
I really would like to recommend Linux for the use, but in this case the problem must be resolved. i could imagine 2 ways of doing:
1. Simple: ALSA is configured to output any content with 24 bit word length. Means adding zeros after the 16th bit.
                Disadvantage: Following Digital to Analog converters would accept the signal as true 24 bit and skip the quantization smoothing.
2. Perfect: If there is an available option for doing this re-quantization in Alsa or MPlayer it would be perfect. As long as the algorithm is good, it doesn't matter this process is done within the DAC or within the computer.

My goal is to make a clear instruction of how to use our device with Linux without compromise.
Thanks for any idea!

Quantization is a many-to-few mapping, an irreversible process. You cannot upscale and expect more of the original signal to be available. I don't think that even adding dithering would produce any effect.

Offline

#5 2011-04-25 14:11:13

brebs
Member
Registered: 2007-04-03
Posts: 3,742

Re: [Solved] Alsa with 24 bit Output Exclusively

GogglesGuy wrote:

I don't think that even adding dithering would produce any effect.

Of course it *would*.

Offline

#6 2011-04-25 14:15:24

GogglesGuy
Member
From: Rocket City
Registered: 2005-03-29
Posts: 610
Website

Re: [Solved] Alsa with 24 bit Output Exclusively

brebs wrote:
GogglesGuy wrote:

I don't think that even adding dithering would produce any effect.

Of course it *would*.

Yeah, but the question whether it would produce the desired effect.  At the hydrogenaudio forum they don't think it needs it:
http://www.hydrogenaudio.org/forums/ind … opic=29963

Offline

#7 2011-04-25 14:19:22

student975
Member
From: Russian Federation
Registered: 2011-03-05
Posts: 613

Re: [Solved] Alsa with 24 bit Output Exclusively

GogglesGuy wrote:

You cannot upscale and expect more of the original signal to be available. I don't think that even adding dithering would produce any effect.

Agree, from "psychoacoustics point of view"  that's just a hype. OTOH it is possible to design a hardware (say, DAC) the way when more bits/rate is "more native" rather 16/44 format, and last one (going through such defective hardware) results in audible artefacts.


"I exist" is the best myth I know..

Offline

#8 2011-04-28 08:34:12

jcci
Member
From: China / Germany
Registered: 2007-06-10
Posts: 185

Re: [Solved] Alsa with 24 bit Output Exclusively

First of all thanks for so much response!

LADSPA was not known to me and I will study what I can do with it. Do you know how to use it?
Edit: LADSPA is meant for production software. No popular Linux player can use those plugins. A solution that works with Mplayer, gstreamer or xine would be accepted by most Linux users, since there are a lot of players on top of those.

Every modern DAC is using re-quantization, synchronous up-sampling and depending on the architecture also noise shaping. The general requirements for s/n can not be achieved with a pure 16bit approach. This is not a problem of the DAC hardware. The USB device can not be initialized when using a 16bit audio file; so the music never reaches the DAC.

The re-sampler inside Linux (or Windows) is definitely downgrading the audio quality. You don't need to have "golden ears" for experiencing this, rather than just a good audio system.
A clean re-quantization could do good, depending on the algorithm.
In case of just enlarging the word length (means in fact no signal change) the re-quantization would be also skipped in the DAC - a very puristic approach which should be proofed to be better. So how to configure ALSA for this?
A dither below on the very low bits of the 24bit signal should be a good idea since it is proofed to statistically shuffle the linearity errors and make the less audible.

Today I did some tests with a very high grade audio system and Linux performs great with 24 bit content. It is not easy to beat top grade CD players on the same DAC. In fact this USB solution is part of a DAC.
The Windows driver works good on my desktop system, but gets choppy on my Macbook... Still some work to do before I can compare.

I admit the cleanest solution would be a firmware revision, but the original firmware making company has no interest in solving this problem and Linux user would have to wait too long or sacrifice sound quality by re-sampling.

Last edited by jcci (2011-04-28 08:42:31)

Offline

#9 2011-04-28 12:22:42

brebs
Member
Registered: 2007-04-03
Posts: 3,742

Re: [Solved] Alsa with 24 bit Output Exclusively

jcci wrote:

No popular Linux player can use those plugins.

Nonsense. Audacious can use bs2b etc. directly (look at its Output - Effects menu), and anyway, it's specified in ~/.asoundrc rather than the player.

You don't need to have "golden ears" for experiencing this, rather than just a good audio system.

What do you have, then?

Offline

#10 2011-04-28 12:51:26

student975
Member
From: Russian Federation
Registered: 2011-03-05
Posts: 613

Re: [Solved] Alsa with 24 bit Output Exclusively

brebs wrote:

Audacious can use bs2b etc. directly (look at its Output - Effects menu)

aur/aqualung is the next.


"I exist" is the best myth I know..

Offline

#11 2011-04-30 04:32:14

schivmeister
Developer/TU
From: Singapore
Registered: 2007-05-17
Posts: 971
Website

Re: [Solved] Alsa with 24 bit Output Exclusively

brebs wrote:
GogglesGuy wrote:

I don't think that even adding dithering would produce any effect.

Of course it *would*.

It would, in a useless way. Quantization is always there in the ADC/DAC, it is part of a 5-step conversion process. If you have content decreasing in bit-depth, the dithering and shaping helps. Otherwise, no effect when going up the scale. At least, not in production. What goes on in "audiophile" circles is magic, so no comment on that.

jcci wrote:

Edit: LADSPA is meant for production software. No popular Linux player can use those plugins.

They're just plug-ins; anyone can use them. I know XMMS does LADSPA. However, as mentioned, you want to load the plug-ins for the system mixer, not the application. That is, use in asoundrc.

You have a great deal of documentation to write for your users; it won't fit on the back of a CD/DVD case.

Last edited by schivmeister (2011-04-30 04:33:08)


I need real, proper pen and paper for this.

Offline

#12 2011-05-02 14:28:46

jcci
Member
From: China / Germany
Registered: 2007-06-10
Posts: 185

Re: [Solved] Alsa with 24 bit Output Exclusively

brebs wrote:
jcci wrote:

No popular Linux player can use those plugins.

Nonsense. Audacious can use bs2b etc. directly (look at its Output - Effects menu), and anyway, it's specified in ~/.asoundrc rather than the player.

I'm happy to be wrong about the LADSPA plugin in popular players. Even happier that Audacious offers the bit-length setting out of the box. If this works, the Linux solution would be pretty easy, also in terms of documentation. Thanks for this one! Tomorrow I will test it right away.

You don't need to have "golden ears" for experiencing this, rather than just a good audio system.

What do you have, then?

Two soft and warm ears females hopefulle like to chew on.... sorry offtopic.

Offline

#13 2011-05-04 02:40:36

jcci
Member
From: China / Germany
Registered: 2007-06-10
Posts: 185

Re: [Solved] Alsa with 24 bit Output Exclusively

Again thanks for all the advices.
Audacious was not the solution. It offers a bit resolution setting which is obviously in a union with a re-sampler.

The good news is: MPD did the job just the way it should be. When de-activating the re-sampler in the /etc/mpd.conf it plays all the content and also plays 16 bit data correctly. Any sample rate change is transferred correctly to the DAC.
The solution with MPD beats the playback with the proprietary Windows driver. It is not too surprising since the Windows driver "offers nice features" like software volume control, sacrificing a bit-perfect playback. MAC-OSX works out of the box since it implemented the USB2 audio stack to the OS long time ago. But it always plays through the system mixer and can not compare with the quite good Windows solution and the excellent Linux playback. There might be some space for tweaking on the Mac later on.

I would be still happy for suggestions which could further improve the Linux experience for audiophiles. Beside that this thread is solved.

Offline

Board footer

Powered by FluxBB