Is Linux "Bit Perfect", and how do you play audio there
Jun 23, 2009 at 4:22 PM Post #31 of 54
Aqualung isn't the most user friendly, but it's perfectly gapless, and if it's bit-perfect to boot, life is good. I'll have to disable Pulseaudio when I get home tonight, and only use ALSA.
 
Jun 23, 2009 at 5:35 PM Post #32 of 54
for those that really really want to be sure (lol) you can run a very minimal linux and run it as a sound server.

meaning, NO desktop stuff (no gnome, no kde, no nuthin). you don't even run Xwindows, you run as a headless console based box. your 'ps' display is less than 1 screen (grin). that kind of setup is what I'm talking about.

then you plug in a usb standard sound dongle and wait for the '/var/log/messages' entry that says hi, I'm a usb soundcard. you can then query it via 'lsusb -v' and see goodies there. do you see native 44.1 mode? look, it should be somewhat human readable and if you see a block of 'stuff' that says 48 and 44 or 44.1 then you can 'feel good' knowing that your card works at those 2 common freq's and that the linux layers also know and will respect this.

then you run mpd, which also needs no gui or screen stuff running. you have to configure mpd and its not trivial but its do-able with some net research and trial/error.

once you get mpd to squirt out some music over your usb device at 44.1 and some other sample you have at 48k (like a typical dvd with its audio track) then you're all set.

pick some mpd-versed client you like and use that, or even just console (ssh/telnet) to that linux box and run the mpd client locally. 'ncurses' mode works fine and even offers some useful color (ansi) modes.

you will get bit perfect sound with such a minimal config. there are no 'shared' sound daemons or mixers or any of that stuff - just the raw /dev/foo device and the mpd talking directly to it. can't get any better than that.

a config like that could probably run on a pentium-3 system, seriously. I have mine on a VIA epia fanless system that is 1ghz but its 1ghz 'VIA' (which is far weaker than amd or intel). my 1ghz VIA miniITX box not only does the mpd sound thing but also DOES run xwindows on a 32" lcd tv I have and I can do things on it in addition to letting it 'serve sound'.

so, I take that back. p3 chip is overkill, perhaps a p2 or old school celery could handle this.

wink.gif
 
Jan 20, 2010 at 2:00 AM Post #33 of 54
To revive this thing from the depths (and linuxworks, I like you're last post), I recently installed gentoo and really like it. Anywho, I'm still a little shaky on how to best get bit-perfect out of linux on a desktop machine, i.e. I am running gnome and will have other apps that need to access the sound card as well (though not necessarily at the same time that I'm playing my bit-perfect music). Also, I'm not even sure if I NEED to take all the effort.

My current setup on on-board soundcard (Lenovo Thinkpad T60p) via s/pdif to an Audio-GD Compass. I use pulseaudio (came with gnome) and Audacious as my sound player. I've got the "bypass" thing checked in Audacious, but I'm not entirely sure if this is doing much. I'm pretty happy with my setup! But I'm always open to making it better if possible.

Ah, and I use mainly my woodied Denon D2000's with this setup.
 
Jan 20, 2010 at 3:19 AM Post #34 of 54
I'm bit perfect - whenever I get a bit, I loudly exclaim 'Perfect !' ....

Ahem, on a more serious note I have had great results with Linux on a netbook into the Topaz - as long as what comes from the headphone out sounds good, I dont get too hung up over minutiae - YMMV.
 
Aug 17, 2011 at 7:34 PM Post #35 of 54

 
Quote:
Quote:

Originally Posted by progo /img/forum/go_quote.gif

And yes, a mixer (dmix for instance) will wreck the state of bit perfectness.



this is not strictly correct.

a mixer at full gain (100%) will not touch the bits in any 'bad' way. no SRC happens in linux unless your card doesn't support the native SR being played. if you have a 44.1 able card you will never be resampled.

the gain will not change either, thru the mixer, if its left at 100%.

so, you can run 'no harm' mode even thru linux mixers. they're not 'forced src' boxes like windows often is.

I use mpd as the backend and usb audio as the 'driver'.


 
Sorry for bringing up this old thread but I thought I had to clarify this statement. It can still be found in search and would offer erroneous information.
 
I am a Linux user that's been using Linux (and only Linux) for years. Recently I dug into the sound system of my Linux machine (Kubuntu 10.04 LTS) and found some very disturbing messes. First of, let me say that ALSA's built in mixer, dmix, is needed for playing more than one audio source at once. There are other mixers, but I stopped exploring them when I tried Jack (this thing rocks). By default, dmix resamples everything as 48khz. This is hard-coded into dmix. It's the work around the coders came up with for mixing together sources that have different sample rates (i.e.: voice chat + watching a DVD). To make things worse, ALSA resamples using a very cheap, cpu-light resampling algorithm. 
 
For more information: http://www.hydrogenaudio.org/forums/index.php?showtopic=47591
 
So if you want real bit-perfect playback in Linux, you have to send the audio from your player directly to the hardware (playback to hw:0 or hw:1, if you have multiple cards). The draw-back is you can't have any other audio playback when your player is sending data to the hardware. The exception to this rule is if your sounds card supports hardware mixing, which is very rare under Linux.
 
On my machine, to know what is sent to my on-board sound card, I use this command:
Code:
 cat /proc/asound/card0/pcm0p/sub0/hw_params
 
Playing 44.1khz flac trough Amarok on my onboard card gives me this:
Code:
 access: MMAP_INTERLEAVED format: S32_LE subformat: STD channels: 2 rate: 48000 (48000/1) period_size: 1024 buffer_size: 16384
 
From this information I know that the output is 32bit (SE32_LE), stereo, 48khz and I get to see the period and buffer sizes. I configured Xine, Amarok's default backend, to send to hw:0 but the data still gets resampled. I am guessing Xine doesn't actually bypass the software mixer, or it resamples by itself. I'll have to try other backends and see if they are any better. I know my card can play from 22khz to 192khz, so it's not a question of compatibility.
 
Playing the same file through Aqualung, sent directly to the hardware without sound mixing:
Code:
 access: RW_INTERLEAVED format: S32_LE subformat: STD channels: 2 rate: 44100 (44100/1) period_size: 512 buffer_size: 16384
 
Playing a 96khz file through Aqualung:
Code:
 access: RW_INTERLEAVED format: S32_LE subformat: STD channels: 2 rate: 96000 (96000/1) period_size: 512 buffer_size: 16384
 
So Xine and dmix resample everything and won't let you chose the output sample rate. Aqualung will let you chose the output sample rate, the problem is Aqualung was hard-coded to output the given sample rate. I can't find any way to by-pass the resampler. This means if you have a playlist with 44.1, 48 and 96, Aqualung won't adjust the output sample rate to match the file's. Given this, I'm unsure if Aqualung gives me a bit-perfect playback, even if I set it to output the same rate as the files it is playing.
 
Sound in Linux is still a mess, even if there's good progress on it. The problem is not hardware compatibility, but software that limits the hardware's capabilities.
 
I will keep on tuning and trying software until I find something that fixes these issues. MPD is my next option.
 
p.s: I just found http://mpd.wikia.com/wiki/Tuning which seems interesting and confirms what I said here. I'll try it out and come back with the results.
 
 
 

 
Dec 2, 2011 at 10:07 PM Post #36 of 54
Firstly, I'm glad there are people out there that know their stuff when it comes to linux and audio, thanks :)
 
Quote:
To get bit-perfect non-resampled playback in Linux, you need to use ALSA and bypass the software mixer called Dmix.

To do so you need to disable PulseAudio if your distribution uses that, here is a guide:

ALSA instead of Pulseaudio for Ubuntu 8.10 Intrepid – a Non-Destructive way. « Tux’s idyllic life.

This guide is for Ubuntu 8.10, I don't know if it's valid for other dists.

To bypass the software mixer you need to use hw:X,0 as you output device (X being device number, hw:0,0 if you only have one audio device)

To confirm your playback mode use this command (card0 assuming you want to see info on audio device number 0):

sudo cat /proc/asound/card0/pcm0p/sub0/hw_params

Happy tinkering :)

Edit: to see your playback mode you have to have audio playing of cause.
Edit2: This is only valid for Ubuntu and variants there of, fx. Linux Mint, Xubuntu, Kubuntu.



Secondly, I did the above steps, and got the following output:
 
root@INTERWEBS:/proc/asound/card0/pcm0p/sub0# cat hw_params
access: MMAP_INTERLEAVED
format: S16_LE
subformat: STD
channels: 6
rate: 44100 (44100/1)
period_size: 1024
buffer_size: 16384
 
I am assuming that because my audio card kind of sucks, that I am getting only 16 bit output and 44,100 Hz rate, but then I saw that "access" is MMAP_INTERLEAVED and I'm not sure what that means, but it looks like something that would involve a mixer. I'm using Slackware, and am wondering if there are any other steps I should take to tweak things or look at things and the like.. The audio I was playing at the time was 24 bit and 96,000 Hz.
 
Thanks!
 
Dec 2, 2011 at 10:14 PM Post #37 of 54
Just had the idea to check my built in sound card, instead of using the Creative Xmod, and it produced different results..
 
root@INTERWEBS:/home/brianw# cat /proc/asound/card1/pcm0p/sub0/hw_params
access: MMAP_INTERLEAVED
format: S32_LE
subformat: STD
channels: 2
rate: 48000 (48000/1)
period_size: 1024
buffer_size: 8192
 
So clearly this is a problem with the Creative Xmod sucking. Or the drivers for it are optimal, but I'm siding with the prior hypothesis because it's one of the crappier Creative sound cards you can buy.
 
Still, very glad I found this forum, and am still interested into whether or not "MMAP_INTERLEAVED" means that I'm going through a mixer that I don't need.. Thanks!
 
Dec 4, 2011 at 6:50 PM Post #39 of 54


Quote:
You can detect a mixer only by the fact that all input gets resampled to a common rate (usually 48 kHz).
 
The "access" field has nothing to do with this.



Cool, and since I'm seeing different rates with different (albeit crappy) audio cards, I think there is no mixer being used, which is swell.
 
Dec 23, 2011 at 2:46 PM Post #40 of 54


Quote:
Just had the idea to check my built in sound card, instead of using the Creative Xmod, and it produced different results..
 
root@INTERWEBS:/home/brianw# cat /proc/asound/card1/pcm0p/sub0/hw_params
access: MMAP_INTERLEAVED
format: S32_LE
subformat: STD
channels: 2
rate: 48000 (48000/1)
period_size: 1024
buffer_size: 8192
 
So clearly this is a problem with the Creative Xmod sucking. Or the drivers for it are optimal, but I'm siding with the prior hypothesis because it's one of the crappier Creative sound cards you can buy.
 
Still, very glad I found this forum, and am still interested into whether or not "MMAP_INTERLEAVED" means that I'm going through a mixer that I don't need.. Thanks!


What music player are you using? You might want to try a few different players before blaming your hardware. After all, this is Linux, which often means the problem is software not hardware. It might be that your player does not bypass Dmix. Did you set it to output on the hw channels?
 
Another way of finding out if your music player outputs directly to the hardware is to launch another music/audio player and see if you can listen to both at the same time. Since most cards don't do hardware mixing, you can only use one audio source at a time. This is what Dmix is for. For this test, I usually go on a random Youtube video and verify if it has sound.
 
Dec 24, 2011 at 2:01 AM Post #41 of 54
The laptop I was using recently died, so I've since setup my netbook with fedora for bit perfect audio.. When I try to play youtube videos they don't have any sound if I'm playing music in Deadbeef, so I think i set it up right. When I do that command in the terminal, it shows that the rate is upwards of 192 KHz, for music files that are that high of a rate, so I think it's set :D
 
The audio card in my netbook probably isn't the greatest, but it will work for now, thanks again for everyone's help, I've learned a thing or two which is swell
 
Dec 25, 2011 at 9:42 PM Post #42 of 54
You can be sure dmix is not being used by compiling it out of alsa-lib with the '--disable-mixer option and not including dmix in the '--with-pcm-plugins' array. My preference is OSS4 w/ vmix compiled out and 'cooked_enable=0' set in '/usr/lib/oss/conf/osscore.conf' through deadbeef-git (OSS4 exclusive mode enabled). I have another system running ALSA with dmix removed from alsa-lib and resampling done via SRC (when required) through deadbeef-git. I would venture to guess that either 'ossplay -R foo.wav' and/or 'aplay -D hw:0,0 bar.wav' are as bit-perfect as the OSS4 and ALSA subsystems are capable of. 
 
Feb 25, 2012 at 10:16 PM Post #43 of 54
I just made an exciting discovery... 
 
My main OS is Ubuntu 10.04 and I always used Xine as my back end since I find it more polished than Gstreamer. A few posts back, I said that there was no way to make Amarok play music directly to the hw:0,0 ALSA plug. This made Amarok's music go trough Dmix which resampled everything to 48 kHz. It turns out this is not Amarok nor Phonon's fault. It was actually a limitation of the back-end I was using, Xine.
 
I installed Fedora 16 a few weeks ago to play around with it and see how much different it is from Ubuntu. The main difference is that Fedora is a transparent distribution that works with up-stream projects and distributes the most up to date versions available. It's a change from Ubuntu 10.04, which is running old versions of pretty much everything. Fedora being up to date, it doesn't have Xine as a Phonon back end. I knew that, but out of curiosity I launched Amarok and went to Configure Phonon to see what back end was installed. It was quite a surprise to see hw:0,0 as one of the available output devices!  I immediately pushed the hw:0,0 plug at the top, making it the default output device for music. I then added a few tracks from my external disc (all my music is on my Ubuntu partition, which is encrypted and can't be accessed from Fedora 
frown.gif
 ) to Amarok's playlist and hit play. Amarok skipped the MP3s, saying it was missing a plugin, then crashed on the first FLAC file. Indeed I see Gstreamer has not changed. I had to install a bunch of gstreamer plugins packages, restart Amarok, and after a few trial and error it was working (more on that later).  Using cat /proc/asound/card0/pcm0p/sub0/hw_params I was able to confirm that all the files were played using their original sample rate and that Amarok changed sample rate as it was playing different tracks, in the same playlist, with different sample rates. Woot!
 
So I rebooted on Ubuntu 10.04, installed Gstreamer, the Gstreamer Phonon back-end and the necessary plugin files. Everything works just like on Fedora.
 

 
Now that Amarok monopolizes the hardware, I have no mixing. That means that while Amarok is playing, even on pause, no other audio can be played. I can't pause Amarok to watch a youtube video, for exemple. On another hand, now I'm sure that no other sound can disturb my listening. 
k701smile.gif

 
 
I also learned something regarding the Gstreamer plugin sets. Anyone who installed those noticed that there are 3 groups, called "good", "bad" and "ugly". When asking about which to install, people often just tell you to install them all, without saying much more. well I finally learned what is the difference between those packages, here it is.
 
The "good" plugins are well maintained plugins. They have good code and are reviewed, tested and kept up to date. On top of that, they are published under the LGPL. This set can't play MP3, as mpeg is patented and can't be published freely. It is enough to play OGG and FLAC, because those are open formats.
 
The "bad" plugins are not as well maintained as the good plugins. They might lack proper testing and aren't as well kept up to date. They are published under a public license, probably the LGPL too.
 
the "ugly" plugins are actually good plugins. They are well written, maintained and kept up to date. The reason why they are called "Ugly" is simply because they are not open source or use elements that might be protected by patents and legal stuff. Their legality is therefor debated. This set can play MP3s.
 
Ubuntu says the "ugly" plugins might "might pose distribution problems". I suppose it's their way of keeping themselves clear of legal drama. Either way, I don't believe you need to install the 3 sets. You can start with the "good" ones and see if that works for your files. If you have MP3s, all you have to install is the gstreamer ffmpeg package. For me, playback of MP3 files works with ffmpeg, but I can't seek the track in Amarok. I had to install the "ugly" set to get proper support of MP3.
 
Feb 25, 2012 at 11:31 PM Post #44 of 54
I play music from a USB DAC using VLC and Xubuntu.
 
Mar 27, 2012 at 9:07 PM Post #45 of 54
Over the weekend I discovered a 10 year old Echo Indigo PCMCIA card and popped it into one of my Ubuntu 10.10 laptops.  Now, I know this card has big limitations but it managed to get me to this forum so I'm grateful for the introduction.
 
Anyway, I was following the Linux-related info and did a little research.  Thanks to you, I was able to get the card working on a Debian laptop as well.  Debian wouldn't recognize the card until I added firmware, but it actually works better in the Debian environment.
 
Since I'm pretty much a Gnome user in whatever Linux flavor I use, I did some testing of various alternatives to KDE Amarok and came up with Audacious and Audacity as good alternatives.  Also found something called DeadBeef music player.  Just wondered if anyone has tried it?
 
Now that I've been bitten, yet again, by the audio bug, I'm looking at new equipment.  How well does the Matrix M-Stage compare with the Yulong D100 and what do you recommend for a DAC with the M-Stage?
 
Thanks
 

Users who are viewing this thread

Back
Top