Linux audio

This may be a bit of off topic.
But after I couldn't start mocp because of conflict between Pulseaudio and Firejail I became curious about how audio system in Linux works.
I thought MOC connects to ALSA (or JACK...) but apparently it's something to do with Pulseaudio. That's first thing.
Another one is where I could find info in plain English how it all works with audio all the way from audio file to speaker?

MOC does connect to ALSA. There is no Pulseaudio plugin yet. But if you have Pulseaudio running, MOC connects to a virtual ALSA device provided by Pulseaudio (if I understand correctly).

As to the documentation, as far as I know there is nothing that detailed on MOC. But roughly it can be described like that: audio file is decoded by plugin, then it is handed over to audio conversion routines which do sample format / sample rate and other conversions, apply softmixer, equalizer. Then it is passed to output plugin, in most cases ALSA.

but apparently it's something to do with Pulseaudio

Not yet, as PulseAudio sound driver is in the works.

Another one is where I could find info in plain English how it all works with audio all the way from audio file to speaker?

Maybe this link will be useful to you?

Maybe this link will be useful to you?

Nice article, gives overview. Thanks.

But if you have Pulseaudio running, MOC connects to a virtual ALSA device provided by Pulseaudio

So in this case if I have Allow24bitOutput = yes in MOC config, Pulseaudio could degrade it to 16?
That would be unfortunate. Possible to make MOC connect to ALSA directly even if Pulseaudio installed?

I don't use PulseAudio so I can't be sure, but I suppose it could. But you can change Pulseaudio settings if you need 24 bits. Note that you can't hear the difference if the downgrading is done properly. See e.g. http://askubuntu.com/questions/376240/what-is-the-default-audacious-bit-depth-for-pulseaudio-output for details. Moreover I recommend this article on audio quality as an antidote for marketing nonsense: http://people.xiph.org/~xiphmont/demo/neil-young.html

if the downgrading is done properly

Yeah I remember libresamplerate among libraries. And I suppose it is different from what is default on many OSes. That's a point of improvement if that library used then system will produce better sound at some degree.
What could be another "points"?

First, which is obvious (just to mention) : to find audio files of better quality.
Second, decoder plugins. I have installed MOC from Ubuntu repositories. Not sure if in this case MOC use libraries proposed at moc.daper.net/links.
Then resampling (I guess). Again it's about *.deb packages. What have been installed as dependencies for MOC, libresamplerate or default one...
Another idea is to get rid of Pulseaudio as a "middle man", which in theory avoid errors caused by it.

So that's my approach, to eliminate weak points in order to have better sound (even if difference is barely perceivable).

So may be somewhere is a sort of check list already exists?

We were talking about changing sample width from 24 to 16 bits, not resampling. Libsamplerate is the only resampling library supported at the moment by MOC (although there is initial support for other in my unofficial fork) - but it is supposed to offer a quality which should be transparent.

Note that not only Pulseaudio, but pure ALSA as well can do resampling. In case of ALSA it is done by component called dmix: http://alsa.opensrc.org/Dmix. By default on many distributions it resamples everything up to 48000 Hz. The quality of algorithm used can be questionable, you can read about it e.g. here https://wiki.archlinux.org/index.php/Advanced_Linux_Sound_Architecture#High_quality_resampling Similar thing could probably be done for Pulseaudio.

In MOC I don't think you can gain any quality by using various decoder plugins and even the choice is not so big. Almost everything can be decoded by ffmpeg and a few other formats (mp3, flac, ogg) have their separate decoders. I didn't see any tests comparing output quality of ffmpeg versus dedicated libraries but I doubt there is much (if any) difference.

Let me add that there are several new plugins in development at the moment, including libao output, opus and mpg123-based decoders, other sample formats and so on. But it will take more time before they are included in a released version.