5

I'm a Computer Audiophile, I've used Windows (with ASIO4ALL)and OSX for Audio. Now I'm making Ubuntu 13 my HTPC/Stereo Audio. To begin with I disabled Pulse audio and using GooMusicplayer with ALSA.

My DAC is capable of 24bit 96khz. I can't seem to find a configuration for ALSA to set output sampling rate. How can I configure it?

5

The device's sample rate is by default what the application has configured for it, i.e., the sample rate of the original file.

| improve this answer | |
  • 1
    Nope, might be a year too late here, but my favorite media player right now, audacious. That one can mix up to any number of khz if I remember correctly. – Cestarian Feb 21 '15 at 12:54
6

Alsa by default uses the same sampling rate and format as the source. It is however possible to force the sample rate up (or down).

Here is one way you could do it. (in /etc/asound.conf or ~/.asoundrc)

pcm.device{
        format S24_LE
        rate 96000
        type hw
        card 0
        device 0
}

Then just make that pcm a slave to another one, like your default(stereo) pcm (warning: the 24 bit format won't work unless you have a compatible card, I normally use S32_LE which works on most cards.)

pcm.!default{
    type plug
    slave.pcm "device"
}

the above will however only work for stereo sources (so if you play from a 5.1 source that will by default use the surround51 pcm, things get a bit more complicated)

The one way I know (and personally use) about how to force the sample rate of non-stereo sources is taking parts from this asound.conf/asoundrc and modifying them. (Note: I did not write that file myself)

(You can find my asound.conf in this question and just copy that directly instead of going through the hassle of manually modifying it below below)

First copy the "dmixed" pcm, and modify it's hardware section to the desired sample rate and format.

Then copy the !default, surround40 and surround51 pcms from it as they are. This will effectively dmix all output and upconvert the sample rate of all 2.0, 4.0 and 5.1 sources to the sample rate that was set in the dmixed pcm.

In that configuration file you may also find the "upmix20_51" pcm interesting as it is an effictive way to upmix 2.0 sources to 5.1 by selectively duplicating the sounds to the other channels. If you want to use it you will have to change the type of it from "plug" to "route" and then set it as a slave to the default pcm.

pcm.!default{
    type plug
    slave.pcm "upmix20_51"
}

As "surround51" which that pcm uses uses "dmixed" as a slave, the forced sample rate will apply to this pcm as well.

Sadly with the way things are now, mono sources will only output from the left speaker, but that is hardly a problem as mono sound sources are rare these dadys. The example I just gave would be exactly how I have my own asound.conf configured, enjoy if you have a 5.1 speaker setup and want to force 96khz sample rates.

In theory I would think that forcing up the sample rate won't achieve anything for you (as it is an absurd thought that it would improve the quality of the audio from it's source which had a lower sample rate) as such you will be a lot better off configuring the application to use 96khz output.

But for me I had some problems with crackling sounds (in specific games, like Xcom: Enemy Unknown) if I didn't force either 96khz or 44.1khz frequency. Seeing as I don't lose anything at all from forcing 96khz (it neither increases nor decreses quality of 44.1/48khz sources) it was a perfect solution.

| improve this answer | |
2

The other answers are somewhat correct.

Most sound cards don't have multi-channeling by default.If you have one of those cards that does have multi-channel mixer in them - you probably don't need to read here. ALSA does mixing of multiple sounds in software.

Generally speaking 2 options are possible:

  1. Bypass mixing software output all together and you may enjoy larger range of sound.(higher sample rate and bit rate for example, channeling to 6 or more speakers).

    Only one program is allowed to work with sound card!

  2. Enable software mixing, and loose some quality which you will probably not notice anyway.(Asus Xonair DX with Sennheiser HD598 tested, didn't notice difference whatsoever, used 96 khz 6 channel sample rate flacs and 192 khz 2 channel ones).

    More than one program can work that way! I'm not an audiophile, mind you, not yet anyways.

Second option is enabled by default if your hardware does not support mixing of several streams at the same time.

NOTE: There is also third option. ALSA can be configured with re-sampling in software, but from my experience, while it is possible to adjust all apps to be re-sampled to max highest sample rate and bit rate - it introduced noticeable lag in FPS games, which is NOT OK for a gamer.(third of a second or so, when i shot the bullets from gun, which annoyed hell out of me).

Be advised, that the third option is probably not practical for a few reasons:

  1. I did not test it well, but I guess some apps may still have issues with it.
  2. Most audio collections are in 44.1/44 khz sample rate with 16 bit rate, unless you use a lot of FLAC, but even then, FLAC has to have higher sample rate in it.
  3. up-sampling does NOT provide better quality of sound (theoretically it does, but if you use cheap headphones - you won't notice it, I'm 99% sure).
  4. lag in games is very real, unless I did something wrong in my .asoundrc file.

To make things more confusing it may get even worse in a good way. You can create "devices" with different settings(channels/rate/sample rate/physical output and input configuration). And some apps can use devices you manually create, some not. It annoys the hell out of me.

Most notorious and problematic ones: flash player.

This answer is true for someone who is not using USB connected earphones. They have their own built in sound cards and I have limited knowledge on that, probably it's more true to those with built in motherboard sound cards. May still be applied to USB headsets, but take whole thing with grain of salt. I am guessing probably around if not lee 10% of all produced sound cards would be using hardware mixing anyway as hardware would lack it as an option. Optical output is one big exception. AFAIK optical output does not need mixer. De-multiplexing is going on in "receiver", where it's done is hardware. Don't take my word for it.

| improve this answer | |
1

Think, that it is not true. Had same issue. Alsamixer is always resampling all streams to default 44,1 kHz. I cannot imagine other way how to mix streams with different sampling rate than resample them to one common. Proper file for change this is ~/.asoundrc

http://www.alsa-project.org/main/index.php/Asoundrc

You can check result here: cat /proc/asound/card0/pcm0p/sub0/hw_params (or card1 if you have 2 cards)

| improve this answer | |
  • 1
    Please add an explanation of what your link contains. – Joseph R. Jul 13 '13 at 21:07
0

Thanks for the info above @Cestarian. This should help me get the usb semi-pro audio interface to go to the sampling rate that is standardized with my recoding (96K). I find this very insightful setting up that machine for the studio.

To help you out, since you helped me, I'll answer these questions:

" In theory I would think that forcing up the sample rate won't achieve anything for you (as it is an absurd thought that it would improve the quality of the audio from it's source which had a lower sample rate) as such you will be a lot better off configuring the application to use 96khz output.

But for me I had some problems with crackling sounds (in specific games, like Xcom: Enemy Unknown) if I didn't force either 96khz or 44.1khz frequency. Seeing as I don't lose anything at all from forcing 96khz (it neither increases nor decreses quality of 44.1/48khz sources) it was a perfect solution."

There is one application that you would take a digital signal, and convert it to a multiplier higher than its original: Digital Jitter reduction. It would be interesting to find out the precision of a computer against an external sample rate converter box used in mastering studios for this purpose.

on the second: I image there has to be a processing frame that has to happen when the sampling rate is undefined. Logically, it would have to sense the incoming data from the hard drive and then format it (if its not correct) into the data stream instead of just outputting to the data stream. Sound uses real time processing and not cpu. But since you are up sampling too, you could be fixing the sources sampling rate jitter on the game's sound file.

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.