Bit Perfect Audio from Linux
Aug 3, 2012 at 10:00 PM Post #46 of 543
I just visited DeaDBeeF's website and noticed they now have .deb for ubuntu, even for 64 bit. They didn't have those last time I visited. I downloaded it and it installed itself without a scratch. Everything works out of the box. I'm running Kubuntu 12.04 amd_64.
 
Even better, they now have stand alone binaries with all the dependencies and plugins built in! I didn't try it as using the .deb is cleaner, but still. It's a good thing they officially maintain those builds, as it lets anyone just download the player and run it on any Linux distribution without the headache of compiling it.
 
I tried to install the Debian .deb last time, but it didn't work. It was simply not compatible with Ubuntu.
 
Those files seems nice, but not very useful. I'd love one in English and written for Linux audio. I'd really like to know what the size of the buffer and the period does, and if it changes anything to the music stream.
 
Aug 4, 2012 at 3:00 PM Post #47 of 543
About Audacious, the winamp interface isn't it's default UI, normaly it looks like deadbeef or gmusicbrowser with its GTK ui :) 
Take it for a spin :) it's much more advanced than deadbeef.
 
Aug 29, 2012 at 3:24 PM Post #48 of 543
UPDATE 2013-11-05: made commands more robust and applicable to S24_3LE as well as S32_LE formats. Updated the link to the newer and simpler article. 
 
Quote:
What's your DAC? Post the entire output of "cat /proc/asound/card*/stream0" while playing some music. Pay attention to the "Rates:" line, it lists the supported sampling rates of your DAC.
You can have bitperfect output with deadbeef, deadbeef just isn't responsible for it. It depends on your system setup.

 
An easy way to determine which alsa stream to watch is by grepping the desired format recursively in /proc/asound while playing a 24bit file, like this:
 
Code:
 egrep -R 'S(24|32)' /proc/asound/card[0-9]
 
In my case it returns ...
 
Code:
 /proc/asound/card0/stream0:    Format: S32_LE /proc/asound/card0/pcm0p/sub0/hw_params:format: S32_LE
 
... point to the same alsa device (a Pink Faun 2 USB DAC).
 
If you have just one alsa card (capable of playing the specified format) you could combine this in one command:
 
Code:
 hdcard=$(egrep -m 1 -R 'S(24|32)' /proc/asound/card[0-9] | awk '{ print $1}' | sed 's/://') watch -n 1 "cat $hdcard"
 
In the article "How to turn Music Player Daemon (mpd) into an audiophile music player" I wrote this year I have some additional pointers about analyzing your cards capabilities and your alsa configuration.
 
Enjoy!
 
Aug 29, 2012 at 3:37 PM Post #49 of 543
UPDATE: 2011-11-05: Updated link to Pulseaudio bug, which page doesn't exist anymore.
 
Quote:
  Sorry if I'm resurrecting an old thread here, but I have a question:  Why can't you simply change the default sample rate in PulseAudio to 48000 Hz?
.... I realize that Pulse works on top of ALSA, so perhaps the answer is that ALSA does something to the audio stream itself?  A little more edumacation would be greatly appreciated.

 
Default pulseaudio with alsa configurations perform on the fly bit depth and sample rate conversion for ensuring a pop and crackle free “plug-n-play” experience (see pulseaudio ticket #930: Media players report 96khz, proc reports 44khz)
 
When you force Pulseaudio to a certain (fixed) bitrate, pulseaudio actually tells alsa to do cheap and dirty sample rate conversion. Technically speaking, pulseaudio uses the software interface to alsa (`hwplug:x,y`) instead of the bare hardware interface (`hw:x,y`).
 
The only way to get bit perfect audio is to disable pulseaudio and configure your music player to use the alsa hardware interface (`hw:x,y`). Of course only the first application to use this interface has exclusive access to it.
 
Cheers,
Ronald
 
Aug 29, 2012 at 4:52 PM Post #50 of 543
The first thing I do when I install a fresh Linux OS is purge PulseAudio. I then configure my music players to use the direct hardware devices. I add a line in .asoundrc to tell Alsa to use the best sample rate converter when conversion is needed. I leave the "default" audio device to my sound card. The nice thing about this setup, is that you can have music playing trough your external DAC, but other audio will still play trough your sound card. So I can use my speakers to play music while watching a Youtube video and having the Youtube audio going out my laptop's speakers.
 
I was quite impressed when I learned that Alsa could handle two different audio streams without mixing them together.
 
How do you know if the bit depth (and overall format) is kept the same from the audio file to the DAC? I never figured how to even tell which format a .flac or .mp3 is formatted as.
 
Aug 31, 2012 at 3:15 AM Post #51 of 543
UPDATE 2013-11-05: replaced `file' command with `soxi' command
 
Quote:
  The first thing I do when I install a fresh Linux OS is purge PulseAudio.


Purging Pulseaudio on a modern Linux system can cause all kinds of troubles; my advice is to disable it using the config files.
 
I then configure my music players to use the direct hardware devices. I add a line in .asoundrc to tell Alsa to use the best sample rate converter when conversion is needed. I leave the "default" audio device to my sound card. The nice thing about this setup, is that you can have music playing trough your external DAC ...

 
My goal was to bypass any conversion done in software. You could achieve that by specifying a `hw:x,y` interface for your (music playing) external USB DAC and point your music playing software to that hardware interface.
 
Then configure a `hwplug:x,y` interface for a second sound card, for example the one embedded on your motherboard. Stack pulseaudio on this second alsa interface and point your desktop managers sound configuration to that.
 
This way you combine a dedicated high quality hardware interface for your beloved music and a 'normal' plug-n-play experience for all other sound.
 
 
How do you know if the bit depth (and overall format) is kept the same from the audio file to the DAC?

 
See  my previous reply in this thread on how to watch `/proc/asound`; it tells you what alsa sends to your sound card (USB DAC).
 
 
I never figured how to even tell which format a .flac or .mp3 is formatted as.

 
The easiest way is to use the `soxi' command in a terminal (part of the `sox' package), like this:
 
Code:
 $ soxi Wayne\ Shorter\ -\ Speak\ No\ Evil/01\ Witch\ Hunt.flac Input File     : 'Wayne Shorter - Speak No Evil/01 Witch Hunt.flac' Channels       : 2 Sample Rate    : 96000 Precision      : 24-bit Duration       : 00:08:09.68 = 47009525 samples ~ 36726.2 CDDA sectors File Size      : 189M Bit Rate       : 3.09M Sample Encoding: 24-bit FLAC Comments ...
 
 
Another obvious way is to use your file manager. In Ubuntu Precise when you right click on a music file and choose 'Properties' nautilus displays a 'Audio' tab with the details of the music file.
 
Cheers,
Ronald
 
Sep 28, 2012 at 1:07 PM Post #53 of 543
Quote:
thanks for a nice guide:
 
When i add the hw:0,1 to gmusicplayer, i get an error when trying to play files. (line 135)
 
Any ideas why?
 
i'm using a USB dac

First, have you made sure, using the command: aplay -l     that hw:0,1 is the correct setting for the sound device you are trying to use? If you can't playing anything, then I'm guessing you have the wrong setting. If it plays some tracks and then randomly stops then read on.
 
I have 3 sound devices on my system: onboard sound (BIOS disabled); Xonar STX (hw:0,1) and a USB to Spdif Audiophilleo 2 (hw:2,0). My primary sound device, the Audiophilleo 2, gives me the same occasional error (the error message is a little more verbose than just "135", but right now I can't recall the exact wording). I believe this is a bug in gmusicbrowser.  Usually, for me, just clicking through the error message starts the next track playing. I posted this bug on the gmusicbrowser forum quite some time ago. As I recall, the author of gmusicbrowser (a very nice and helpful individual) had no idea why it happens and felt it was a gstreamer error. I tend to disagree, since no other player I use exhibits a similar problem (Quod Libet or Deadbeef). It also seems that the error only happens when you enable gmusicbrowser's gstreamer "Advanced settings" > ALSA device = hw:x,x.
 
If you are using a recent version of Ubuntu or Mint, the error should not prevent you from using gmusicbrowser, provided you are not trying to play another audio stream at the same time. For example, trying to play a YouTube audio/video file while gmusicbrowser is in "Play" or "Pause" mode. "Stop" would be OK, as this mode temporarilly releases the exclusive ALSA hardware connection between gmusicbrowser and ALSA freeing you to temporarilly play another stream in your browser. I do this occasionally when surfing the web. However, I've found that it can also lead to the error you encountered when resuming gmusicbrowser audio playback (pressing "play" after a "stop").
 
If the error is causing you too much grief, I suggest removing the ALSA direct hardware setting (hw:x,x) and using gmusicbrowser via PulseAudio. Or, you can switch to Quod Libet for similar functionality and not get the error. Same for Deadbeef.
 
Sep 28, 2012 at 4:02 PM Post #54 of 543
Thank you for your swift response!
 
First of all, here's the full error message:
 
Playing error : Configured audiosink alsa is not working. at /usr/bin/../share/gmusicbrowser/gmusicbrowser_gstreamer-0.10.pm line 135.
 
adding the hw:0,1, does change the configuration shown in aplay -l (as you described it should):
 
 
**** List of PLAYBACK Hardware Devices ****
card 0: Intel [HDA Intel], device 0: STAC92xx Analog [STAC92xx Analog]
  Subdevices: 1/1
  Subdevice #0: subdevice #0
card 1: Audio [NAD USB Audio], device 0: USB Audio [USB Audio]
  Subdevices: 1/1
  Subdevice #0: subdevice #0
 
 
It's the same problem for every single track and persists with or without youtube or any other programs open.
 
The NAD DAC should be capable of up to 24/96.
 
Sep 28, 2012 at 4:38 PM Post #55 of 543
If you want to use "NAD USB Audio", you have to use hw:1,0 which is card 1, device 0.
 
Sep 28, 2012 at 4:59 PM Post #56 of 543
Quote:
If you want to use "NAD USB Audio", you have to use hw:1,0 which is card 1, device 0.

 
Doing that gives,
 
 
**** List of PLAYBACK Hardware Devices ****
card 0: Intel [HDA Intel], device 0: STAC92xx Analog [STAC92xx Analog]
  Subdevices: 1/1
  Subdevice #0: subdevice #0
card 1: Audio [NAD USB Audio], device 0: USB Audio [USB Audio]
  Subdevices: 0/1
  Subdevice #0: subdevice #0
 
Is it correctly configured? Sound is coming out the speakers!
 
Sep 28, 2012 at 6:08 PM Post #57 of 543
You haven't mentioned what Linux distro you are using, so I am assuming it's Ubuntu or a derivative.
You have confirmed your USB sound device is hw:1,0 and NOT hw:0,1 as you originally thought and that, now, you do get sound out of the speakers. From you last post it's not clear (at least to me) whether the sound is (a) music playing from gmusicbrowser and (b) whether the error message persists. If the answers to a and b are yes, then:
 
1. Have you tried what I suggested before: setting up the Quod Libet player with "alsasink device=hw:1,0"?  I outline how to do it in the 3rd post in this thread. It should work without any errors and confirm that you can get bit perfect audio output to your USB dac.
 
2. Have you tried downloading and installing the latest development version of gmusicbrowser (1.1.9 deb for debian/ubuntu): http://gmusicbrowser.org/devel.html
 
Version 1.1.9 fixes several issues which may be contributing to your problem. If you're not using a Debian distro, then download one of the other packages on the page applicable to your distro.
 
3. You should also double check that any unneeded motherboard audio chip is disabled in your BIOS.
 
Sep 29, 2012 at 3:51 AM Post #58 of 543
For me now the easy way in my Kubuntu 12.04 is to use Clementine and select Audio sink (ALSA) and use in my case hw:2,0 for the output device.
Unselect Cross Fade when changing tracks manually to avoid errors and reduce the buffer duration to 1200 ms.
 
This is the result with my iBasso D7 :
cat /proc/asound/card2/stream0
XMOS XMOS USB Audio 2.0 at usb-0000:00:0b.1-2.3, high speed : USB Audio
Playback:
  Status: Running
    Interface = 1
    Altset = 1
    URBs = 2 [ 46 46 ]
    Packet Size = 1024
    Momentary freq = 192011 Hz (0x18.0058)
    Feedback Format = 16.16
  Interface 1
    Altset 1
    Format: S32_LE
    Channels: 2
    Endpoint: 1 OUT (ASYNC)
    Rates: 44100, 48000, 88200, 96000, 176400, 192000
    Data packet interval: 125 us
 
To find the hardware audio card, if you have more than one device, use alsa mixer in a terminal :

 
Oct 5, 2012 at 11:10 AM Post #59 of 543
 
 
Quote:
In deadbeef, go to Edit > Preferences. Under the Sound tab, select Alsa output plugin. Then select the right output, either Digital for SPDIF or "front speaker" of the correct DAC if USB. Then go to the DSP tab. Select the Resampler, then hit Remove. Restart Deadbeef and retest

 
 
I was using Deadbeef for while now and thought I did it to Bit Perfect settings. Using Alsa / USB CODEC USB AUDIO IEC956 S/PDIF output to my DAC. I also set the Alsa plugin to not use ALSA resampling. I never worried about the DSP tab. Now after reading the post from Kim Laroux quoted above, I removed the Resampler (Secret Rabbit Code) and restarted. Unfortunately all my HD 24kbit 88200Hz music files play now half velocity. So this means what got out before was not Bit Perfect, because it had to go through the Resampler. Well, I am confused. Can anyone help?
 
Oct 5, 2012 at 2:04 PM Post #60 of 543
Quote:
 
 
 
 
I was using Deadbeef for while now and thought I did it to Bit Perfect settings. Using Alsa / USB CODEC USB AUDIO IEC956 S/PDIF output to my DAC. I also set the Alsa plugin to not use ALSA resampling. I never worried about the DSP tab. Now after reading the post from Kim Laroux quoted above, I removed the Resampler (Secret Rabbit Code) and restarted. Unfortunately all my HD 24kbit 88200Hz music files play now half velocity. So this means what got out before was not Bit Perfect, because it had to go through the Resampler. Well, I am confused. Can anyone help?

I just ran a test. By default deadbeef includes "SuperEQ" and the "Secret Rabbit Code Resampler" in the DSP list, but if you don't use them, I don't believe they have any effect on the output. They certainly didn't for me. When I removed them (for the test) from the DSP list, and played 16/44.1 and 24/96 files back to back, my W4S DAC-2 automatically switched from 44.1 to 96 without missing a beat. I'm wondering, did you activate Resampling or EQ before you deleted them as per the post you referred to above from Kim Laroux? If you did, perhaps a setting in some deadbeef config file was changed which is causing the problem, now that you have removed Resampling and EQ. Also, I'm not sure what you mean by writing that your files now play back at "half velocity". I suspect you mean that the sampling rate is no longer 88.2k but 44.1k on playback?
 
Your specific USB device should be listed in the list of output devices seen by deadbeef. For example, my Audiophileo 2 has several possible choices. The one highlighted in blue is my active selection. You may have to experiment to find the right selection. Perhaps that's your only problem. Unfortunately, deadbeef is a little light on helpful documentation.
 

 

Users who are viewing this thread

Back
Top