So, recently I've been listening to some music via Audinst USB HUD mini audiocard and Sennheiser HD25 headphones. I've noticed, that all 16-bit flac files I've been listening, have unusual noise. It's very low amplitude, however is noticeable.
First thing to blame was my sound card — cheap (~100$) device from unknown Korean vendor... What would you expect? But just of curiosity, I converted those flac files to 24 bit and noise gone. That's interesting! Then I tried converting to mp3. No noise. Ogg? — Nope. Wav? — Nope.
I started experimenting. It appeared, that parasite noise was only present for 16-bit flac files, and only if there was some signal (flac file with all samples == 0 sounded silent as it should). Noise was a bit different depending on the content of the file, and I assumed that it depends on the signal being played.
I checked other players, specifically moc, and couldn't reproduce that noise.
Obviously, mpd was one to blame. I filed a bug to mpd bug-tracker, which naturally was closed due to lack of evidence (and you can't blame mpd developers for that. I too wouldn't believe in such non-sense from a stranger).
So I started thinking about getting an evidence to what I've been hearing.
Luckily, mpd provides fifo output. To my understanding, decoded data (raw pcm) is streamed to that fifo for other apps to read. Perfect!
So I got my sample flac file (about 1 sec long), its decoded wav version, and played each of them dumping fifo output to a file like this
$ dd if=/tmp/mpd.fifo of=$output_file
Results are more confusing then I expected.
At first: lengths of these samples appeared to be different.
|Reference wav and flac files||44453|
|Dump of the flac file via mpd fifo||44416|
|Dump of the wav file via mpd fifo||40960|
Second, obviously: sample data was different too.
I asked for some comments from developers about that on mpd bug tracker issue (also, sample files can be downloaded there), and still waiting for developers response.
For years I've been believing, that ALSA and mpd can deliver bit-perfect playback, but apparently that's not the case. I do hope, that everything will be sorted out and (if needed) fixed.