Bit Perfect Audio from Linux
Jul 9, 2011 at 2:33 PM Thread Starter Post #1 of 543

TheKisho

500+ Head-Fier
Joined
Aug 24, 2009
Posts
519
Likes
16
I've never got a very clear answer or understanding if it's posible to configure ALSA to output a bit perfect copy of a playing music file (as the only sound playing), no resampling or mixing for supported output sample rates and bit rates.  I wouldn't mind it to work like WASAPI in shared mode on Windows Vista and 7 (bit perfect until another application needs to play audio).  Would JACK help configure ALSA to do what I'm looking for?  What settings do I need to play with to get it do what I want?  How well does it resample (downsampling for sample rates and bit rates not supported by hardware) and/or how well does it mix down surround sound to stereo; and how well is the quality of the mixer compared to Windows, Mac, and other Linux (OSS,....) audio sub-systems mixers'?  I don't think a computer forum would understand bit perfect output or the point in bothering to set it up and configure it.  I think this is the best place for this question, I just hope there is some linux audiophiles in the house. (Even if what I want is shared/mixed mode depending if audio needs to be mixed together [Bit perfect the majority of the time]).  Thanks in the advance.
 
 
P.S.  I'm not worried about audio delay/lag, long as the audio memory buffer doesn't have issues (aka keeping 0.25s-1s sound clips and playing back at random intervals randomly.  I've had that happened time to time on some slower linux machines when using audactiy. [only when the is no audio being outputed]).
 
Jul 9, 2011 at 6:09 PM Post #3 of 543
  I've never got a very clear answer or understanding if it's posible to configure ALSA to output a bit perfect copy of a playing music file (as the only sound playing), no resampling or mixing for supported output sample rates and bit rates.  I wouldn't mind it to work like WASAPI in shared mode on Windows Vista and 7 (bit perfect until another application needs to play audio).  Would JACK help configure ALSA to do what I'm looking for?  What settings do I need to play with to get it do what I want?  How well does it resample (downsampling for sample rates and bit rates not supported by hardware) and/or how well does it mix down surround sound to stereo; and how well is the quality of the mixer compared to Windows, Mac, and other Linux (OSS,....) audio sub-systems mixers'?  I don't think a computer forum would understand bit perfect output or the point in bothering to set it up and configure it.  I think this is the best place for this question, I just hope there is some linux audiophiles in the house. (Even if what I want is shared/mixed mode depending if audio needs to be mixed together [Bit perfect the majority of the time]).  Thanks in the advance.
 
 
P.S.  I'm not worried about audio delay/lag, long as the audio memory buffer doesn't have issues (aka keeping 0.25s-1s sound clips and playing back at random intervals randomly.  I've had that happened time to time on some slower linux machines when using audactiy. [only when the is no audio being outputed]).


You can get bit-perfect audio from Linux without too much difficulty using ALSA. Most popular distributions of Linux (Ubuntu, Mint, Fedora, OpenSuse) to name but a few, use the Pulse Audio Sound Server which, by default, will mix all audio down to 16/44.1 or 48 for movies. Not good for 24/96 or higher. Those who want bit perfect audio in Linux need to bypass this "feature"
mad.gif
.
 
While I am no Linux guru, here are a few ways to do it using Ubuntu Linux, without removing Pulse Audio or hopefully resorting to the terminal/command line. All will yield excellent results:
 
1. You need to install a music player that allows you to select certain ALSA settings. Each of my recommendations has pluses and minuses. IMO, the closest to perfection is "gmusicbrowser".  My 4 recommendations for top notch music players are:
 
     DeaDBeef            http://deadbeef.sourceforge.net/
     Gmusicbrowser  https://launchpad.net/~shimmerproject/+archive/ppa
     Guayadeque        http://sourceforge.net/projects/guayadeque/
     Quod Libet          https://code.google.com/p/quodlibet/
   
2.  To get bit-perfect output from each of the above:
 
    DeaDBeef:  (a) Click on the Edit menu, then Preferences.
                       (b) In the Preferences window under "Sound" tab > "Output plugin" = "ALSA"
                                                                                                          "Output device" = "HDA Intel ALC889,
                                                                                                                                      IEC958, S/PDIF
 
                            NOTE: the "Output device" choice will depend on the type of sound card in your computer. It may be labeled differently from the one I have.                           
 
                       (c) In the same Preferences window select > Plugins
                            In the left column select "Alsa Output Plugin" and then click the "Configure" button
                            In the configuration window make sure that ALSA resampling is unchecked and that you place a check in box to "Release device when stopped".
 
You are now done setting up DeaDBeeF for bit perfect playback.
 
    Quod Libet:  (a) click on the Music menu > Preferences > Player tab
                          (b) for the "Output pipeline" type "alsasink device=hw:0,1"  (omit quotes)
 
    Gmusicbrowser: see post 5 in this thread: http://www.head-fi.org/t/561961/bit-perfect-audio-from-linux#post_7596563
 
 
    Guayadeque:  (a) click on Library menu > Preferences and select "Playback" from left column
                            (b) for Output device = ALSA and in the white box to the right type "hw:0,1"  or "plughw:0,1" (omit quotes)
 
PLEASE NOTE WELL: in each case above, you will see that ALSA hardware device setting for the sound card is "hw:0,1". This is usually the case if you have one and only one sound card in your system. If you have more than one sound card, you should, if possible, remove or disable all sound cards but one you intend to use for audio output. Motherboard sound chips are usually disabled in the BIOS. If the above "hw:0,1" doesn't work for you, sorry, but you will have to open a terminal and type:
 
Code:

 
for a single sound card setup, this command (aplay -l) will display a result like:
 
Code:
**** List of PLAYBACK Hardware Devices ****
card 0: Intel [HDA Intel], device 0: ALC889 Analog [ALC889 Analog]
  Subdevices: 1/1
  Subdevice #0: subdevice #0
card 0: Intel [HDA Intel], device 1: ALC889 Digital [ALC889 Digital]
  Subdevices: 1/1
  Subdevice #0: subdevice #0

 

 
The above output shows that my primary sound card is, card "0",  device "1" (written as:  "hw:0,1") for my digital S/PDIF output.
 
Please read post 5, Notes 1 & 2 below for additional helpful info on using "aplay -l" for ALSA output. http://www.head-fi.org/t/561961/bit-perfect-audio-from-linux#post_7596563
 
Also be aware that when using exclusive ALSA mode, Gmusicbrowser, Guayadeque and DeaDBeeF have one significant advantage over other players. When you stop playback with the "stop" button, you immediately have access to sound for other programs, like answering a Skype call. With other players (like Quod Libet), they take exclusive control of the audio (like Windows WASAP mode) and no other applications can use audio.
 
This can also be done using the Linux MPD (Media Player Daemon) but it requires more work and file editing.
 
Jul 9, 2011 at 7:35 PM Post #4 of 543
Quote:
 
Sorry but this not bit perfect by design.
In shared mode all audio is routed to the Win mixer and dithered.

 
Only when there is more than one program using the audio.  When one program like WinAmp (with plugins) or other program is using WASAPI in shared mode it's bit perfect until knocked into mixing another programs audio into the output (like a browser or VLC or something else), but will return to bit perfect once it's the only program using it.  In exclusive mode it disables all other audio steams but program which took exclusive control.  There has been verification.  That's why I use it in shared mode, but make sure there is no interruptions from other applications.  Well maybe I'm talking about non-exclusive mode of WASAPI and Shared mode is the name of when more than one audio stream is trying to access the audio output.  So I was lead to believe.  The person also use a DTS or AC/3 audio stream to prove that when it has to share with another applications active audio stream the decoder drops out during the two mixed audio streams.
 
 
And thanks Rizlaw.  I'll check that out when I have time.  Is there anymore applications that you know of that can be configured in one way or another to do the above?  I probably should of mention that my favorite distro is Fedora (Gnome, .rpm), but that shouldn't change anything you discribed.  (Just application support at most).
 
Jul 9, 2011 at 8:37 PM Post #5 of 543
Yes. Gmusicbrowser (also excellent). http://gmusicbrowser.org/
Currently, my preferred music player in Linux.
 
Once downloaded and installed, to set up Gmusicbrowser for bit perfect playback:
 
Click the Main menu > Settings > Audio tab
 
In the Audio tab box make sure you have ALSA selected
 
Click on the topmost Advanced Settings tab to the right, this will pop up a small window. In this window, if you like gapless playback you can check it off. Most importantly, in the Alsa device box make certain to add hw:0,1
 
Do not enable enable any other features in this window. Close window.
 
NOTE 1: as I mentioned in post #3 above, if this setting is to work properly for you, you must check to see that your sound card actually is at hw:1,0 . If you are not sure, use the command aplay -l in a terminal window to determine the correct setting for your sound card. Sometimes, when you have multiple sound devices in your computer (e.g. a video card with HDMI out; a plug in sound card and the sound chip on the Motherboard) a reboot of the OS will change the order of the device drivers for these devices. So, if the sound card you use was initially listed as hw:1,0, a reboot of the OS might change it to hw:3,0. When you try to play something you won't hear any sound or it will be coming from the wrong sound device. This happened to me frequently. To prevent your setting from changing: instead of using, for example, hw:1,0 for the ALSA device, use the name of the device to permanently identify it to the OS, for example,  hw:STX,0 (where "STX" is your Audigy STX sound card). The "name" does not change.
 
Note 2  below explains how this is done:
 
NOTE 2:
Quote: powerhouse64   http://www.head-fi.org/t/561961/bit-perfect-audio-from-linux/360#post_12136621
 
  1. Open a terminal and enter the following (copy & paste):
 
aplay -l | awk -F \: '/,/{print $2}' | awk '{print $1}' | uniq
 
You will get one or more names for available audio devices, depending on how many you got. In my case I get:
 
STX
HDMI
Device
 
2. Inside gmusicbrowser, select Settings -> Audio:
 
3. Select output device = ALSA
 
4. Click "advanced options"
 
5. Enter the device of choice you found above into the "alsa device" field as follows: hw:STX,0
 
I selected the STX option which represents the Asus Xonar STX.
 
6. To make sure you got the right entry, double check using the following terminal command:
 
aplay -l
 
Here the output on my PC (shortened list):
 
**** List of PLAYBACK Hardware Devices ****
card 0: STX [Xonar STX], device 0: Multichannel [Multichannel]
  Subdevices: 0/1
  Subdevice #0: subdevice #0
card 0: STX [Xonar STX], device 1: Digital [Digital]
  Subdevices: 1/1
  Subdevice #0: subdevice #0
card 1: HDMI [HDA ATI HDMI], device 3: HDMI 0 [HDMI 0]
  Subdevices: 1/1
  Subdevice #0: subdevice #0
...

 
Recently Gmusicbrowser added a nice "nowplaying" widget that you can place on your desktop which will show: transport control buttons, track title, artist, Album and Album art of the currently playing song. It's one of the nicest I've seen in Linux. It is enabled by doing the following:
 
Main Menu > Settings > Plugins tab >
Put a check in the "Desktop Widgets" selection, then in the Layout window select "Buttons, Song & Cover" and click the Add button. This will pop up a control panel that will allow you to move the widget around on your desktop for placement.
 
NOTE: if you are using Ubuntu 11.10 or higher, you will need to have the latest version of gmusicbrowser (1.1.9 deb) obtained here http://gmusicbrowser.org/devel.html
and read this post: http://forum.gmusicbrowser.org/index.php?topic=469.msg2191 and https://github.com/squentin/gmusicbrowser/commit/3d75f91e33
 
 
Recently, I started a thread on the Gmusicbrowser forum about enhancing this widget which you can read here: http://forum.gmusicbrowser.org/index.php?topic=536.0
 
If you read and follow the post, you will obtain a "nowplaying" desktop widget that looks like the one below. It will only show the transport buttons (back, stop, play/pause, forward)  below the cover art, when you mouse over the cover art):

 
Jul 17, 2011 at 12:04 PM Post #6 of 543

 
Quote:
You can get bit-perfect audio from Linux without too much difficulty using ALSA. Most popular distributions of Linux (Ubuntu, Mint, Fedora, OpenSuse) to name but a few, use the Pulse Audio Sound Server which, by default, will mix all audio down to 16/44.1 or 48 for movies. Not good for 24/96 or higher. Those who want bit perfect audio in Linux need to bypass this "feature"
mad.gif
.
 
While I am no Linux guru, here are a few ways to do it using Ubuntu Linux, without removing Pulse Audio or hopefully resorting to the terminal/command line. All will yield excellent results:
 
1. You need to install a music player that allows you to select certain ALSA settings. My 3 recommendations for top notch music players are:
 
     DeaDBeef          http://deadbeef.sourceforge.net/
     Quod Libet        https://code.google.com/p/quodlibet/
    Guayadeque      http://sourceforge.net/projects/guayadeque/
 
2.  To get bit-perfect output from each of the above:
 
    DeaDBeef: (a) Click on the Edit menu, then Preferences.
                       (b) In the Preferences window under "Sound" tab > "Output plugin" = "ALSA"
                                                                                                          "Output device" = "HDA Intel ALC889,
                                                                                                                                      IEC958, S/PDIF
 
                            NOTE: the "Output device" choice will depend on the type of sound card in your computer. It may be labeled differently from the one I have.                                               
 
                       (c) In the same Preferences window select > Plugins
                            In the left column select "Alsa Output Plugin" and then click the "Configure" button
                            In the configuration window make sure that ALSA resampling is unchecked and that you
                            place a check in box to "Release device when stopped".
 
You are now down setting up DeaDBeeF for bit perfect playback.


I love you dude.
 
 
Nov 30, 2011 at 5:36 AM Post #7 of 543
Linux audio is a mess, I mean there are many options to get perfect audio, but theres no out-of-the box setup :)
Another thing that increases confusion in this matter are people who fight in the sound system wars :) the entire whats best pulse audio or alsa or even OSS4 subject - but most of those ppl are not even close to beeing an audiophile and hq - good sound definition to them includes good looking mixers and adding post-processing effects to audio like 3d sound so dont even bother reading those topics on ubuntu/debian/arch forums.
 
I've fought with pulse audio, alsa and even OSS4 to get best sound possible. 
Each of those sound systems has its pros and cons, but quality wise the best one out of the box is OSS4. 
That said, OSS4 will make some applications freak out when set to default in system...
 
But hopefully theres an option to achive even higher sound quality with alsa and jack. Jack in general is the linux alternative to ASIO (fto achive low latency it bypasses kernel mixing just like ASIO on windows) and its has nice server app. After installing JACK You just need to start sound server, set it like this:
 

 
(I've highlighted with red important ones)
 
This setup should output bit-perfect SD audio. (I cant do a null-test with my setup to check if it's 100% bit perfect but my ears feel fine with the reproduction quality :))
 
I recomend Audacious with JACK output plugin or using system wide sound capture to jack and then You can use whatever You like.
 
You can use JACK with ALSA system wide by creating .asoundrc in Your home directory containing:
 
 
# use this as default
pcm.!default {
type plug
slave { pcm "jack" }
}
 
ctl.mixer0 {
type hw
card 1
}
 
# pcm type jack
pcm.jack {
type jack
playback_ports {
0 system:playback_1
1 system:playback_2
}
capture_ports {
0 system:capture_1
1 system:capture_2
}
}
 
Dec 1, 2011 at 8:52 AM Post #8 of 543
Another option is Voyage MPD.
 
It is Debrin based MPD.
The sound is very detailed and clear.
Voyage MPD dosen't require machine power nor more strage size.
 
cheeers
o2smile.gif

 
 
Dec 2, 2011 at 9:06 AM Post #10 of 543


Quote:
Don't even consider ALSA/PulseAudio. 



Do.  ALSA's fine.  Pulse, with the settings you choose, is fine.  Just because you only know how to do it one way, that doesn't mean no-one should do it other ways.
 
Jan 6, 2012 at 8:39 AM Post #14 of 543
The major reason I've not written how I set up MPD is because the documentation is actually quite good. Secondarily if you can learn how to use IRC, their channel usually has a couple people in it that know what they're talking about. 
 
Instead of replicate that knowledge out here, we should push the knowledge back into their documentation.
 
I would emplore people to try out MPD as their player of choice, more and more hifi manufactures are bundling this capability within their playback devices.
 
Jan 6, 2012 at 8:24 PM Post #15 of 543
I know how to do it both ways as any Linux user who is interested in improving/comparing means of audio fidelity should.   

 
Quote:
Do.  ALSA's fine.  Pulse, with the settings you choose, is fine.  Just because you only know how to do it one way, that doesn't mean no-one should do it other ways.



Nothing outside of what I have tested and heard on my own systems. This is with and without mixer compiled out of alsa-lib. Compare the two audio subsystems for yourself and report back with your own results. If need be, you could also compare OSS4 vs. ALSA sonograms off the same audio file(s). Though perhaps I was a bit brash with my statement as the feature set of ALSA is quite complete thanks to active development ( @cladisch: Thanks for the Xonar contributions :) )


Quote:
Can you provide some sort of substantiation to this claim? I find comments like this misleading and destructive.



 
 

Users who are viewing this thread

Back
Top