Re: Digital bit perfect ouptut with ALSA

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Paulo Moura Guedes wrote:
> On Thursday 11 December 2008 01:20:23 stan wrote:
>  > Paulo Moura Guedes wrote:
>  > > I'm trying to get bit perfect output out of my linux box, but I can't
>  > > find much
>  > > info on the web. I'm using ALSA.

I think you are somewhat confused.  ALSA is a low level 
interface between user space and the kernel/hardware.  You 
can do whatever you want if you write the software to do it 
with alsa.  But alsa is *not* Foobar2000.  For that you have 
to use a player.  Alsa provides a simple player called aplay 
and a device called hw that does no alteration on the sound 
stream it receives.  It sounds like exactly what you want.

To use it type at the command line,

aplay -lLv

This will give you a list of your sound devices and sub 
devices.  Select the sound device number.  Then look for the 
subdevice number that has IEC958 in it.

Put that into a command that looks like

aplay -Dhw:device#,subdevice#  file-to-play-here.

By my understanding of how aplay and alsa works that should 
stream the raw input from the file to the digital hw device 
without any alteration whatsoever.  You can look for more 
information by typing aplay -h or man aplay

To use a more sophisticated player, you will have to do 
research on the available players and see what configuration 
of alsa they expose.

>  > >
>  > >
>  > > Some questions:
>  > >
>  > >
>  > > - does Linux/ALSA features dynamic sample rates?
>  >
>  > yes. You can specify whatever rate you want and it will
>  > happen. eg 57,325 frames/second.
> 
> 
> I meant "dynamic", e.g., if my FLAC file has a sample rate of 96KHz, 
> that will be used, but if next I play a 44.1KHz file it would dynamicaly 
> changes to 44.1.

This has nothing to do with alsa.  alsa does what the player 
tells it to do.  All files play at the rate they are encoded 
at in most players.  I use xmms and when a file plays it 
tells me the rate (usually 44,100).  But the *player* is 
telling alsa what rate to play at.  alsa couldn't care less. 
  It just does what you tell it to.

>  >
>  > > - is it possible to set the bit-depth? (in my case to 24 bit)
>  >
>  > yes, but your card has to support it. Most new cards have
>  > internal processing larger than 24 bits
> 
> 
> I have a Benchmark DAC1 which supports 24 bit.
> Were can I set the bit-depth?
> 
It is set via an api call to the alsa interface.  The player 
will set that depth when it opens alsa to play.  It gets 
this depth from the encoded sound.
> 
>  > > - what other variables do i have to consider in order to get bit
>  > > transparent ouput,
>  > > i.e., no resampling at all?

Did you read the article at the links you provided?

>  >
>  > Use only hardware rates supported by your card.
> 
> 
> You mean sample-rates?

yes.  Otherwise the card has to resample.

> 
> 
>  > You can
>  > ensure this by using plughw as your device instead of
>  > default. That converts from the audio application sound
>  > format to the sound card internal format, but does no
>  > resampling. You can avoid even the conversion if you make
>  > sure the audio is in the format that your sound device uses
>  > internally.
> 
> 
> Can you elaborate?

I thought this was elaborated. ;-)  The article you pointed 
to  had a list of things to worry about.

quoting"...
To maintain quality during digital-audio playback, the 
following criteria must be accounted for:

     * Sample-rate capabilities
     * Word-length capabilities
     * Digital volume control capabilities
     * DSP and plug-ins
     * Dither
     * Multiple application mixing/exclusivity

These qualities are not completely independent of each 
other. For instance, 'sample-rate conversion' can be evoked 
because of 'multiple application mixing'. Also, 'digital 
volume control capabilities' are closely related to 
'word-length capabilities' and 'dither'. Other relationships 
exist as well, and it is encouraged to read more on each 
subject.
..."

For instance, let's suppose that you have audio in 32 bit 
floating point format.  You decide you want to get it as bit 
perfect digital output (as bill said, why are you using a 
sound card at all, why not send the data stream to your 
external DAC?)  The trouble is that sound devices process 
your sound internally on hardware that is predefined. What 
if the bus in your sound device expects to receive 24 bit 
signed integer samples?  Then your digitally pristine sound 
from storage has to be converted from 32 bit float to 24 bit 
signed integer.  You are no longer bit perfect.  Ditto for 
supported hardware rates.  If you ask for a rate, say 
88,200, that the hardware in your sound card does not 
natively support, it has to be resampled to the rate.  As 
Bill said, this is very costly either in time or quality. 
High quality means it takes lots of time.  Hiqh speed means 
it is low quality.

What I said above is that if you use the plughw device it 
automatically does this conversion to the card's internal 
format for you, but won't change the sample rate.

I've sent hw output to a sound device that was in the wrong 
format, and as you would expect the result wasn't 
harmonious. :-)

> 
> 
> Thanks,
> Paulo

The long and short of it is that alsa is as bit perfect as 
you ask it to be and as the device and digitial input it is 
using is.  The method I outlined above, or close facsimile 
thereof, should be able to prove it to your satisfaction.


------------------------------------------------------------------------------
SF.Net email is Sponsored by MIX09, March 18-20, 2009 in Las Vegas, Nevada.
The future of the web can't happen without you.  Join us at MIX09 to help
pave the way to the Next Web now. Learn more and register at
http://ad.doubleclick.net/clk;208669438;13503038;i?http://2009.visitmix.com/
_______________________________________________
Alsa-user mailing list
Alsa-user@xxxxxxxxxxxxxxxxxxxxx
https://lists.sourceforge.net/lists/listinfo/alsa-user

[Index of Archives]     [ALSA Devel]     [Linux Audio Users]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [Yosemite Photos]     [KDE Users]     [Fedora Tools]

  Powered by Linux