Gentoo Forums
Gentoo Forums
Gentoo Forums
Quick Search: in
Forcing alsa dmix to 24 bit 96 kHz with softvol [SOLVED]
View unanswered posts
View posts from last 24 hours

 
Reply to topic    Gentoo Forums Forum Index Multimedia
View previous topic :: View next topic  
Author Message
selig
Guru
Guru


Joined: 31 Jul 2005
Posts: 425
Location: Prague, Czech Republic

PostPosted: Wed Sep 05, 2012 7:51 pm    Post subject: Forcing alsa dmix to 24 bit 96 kHz with softvol [SOLVED] Reply with quote

I have bought a Creative Sound Blaster X-Fi Surround 5.1 Pro USB. There are several problems with this card:

1) it cannot mix several streams simultaneously
2) it cannot set volume (via snd-usb-audio)

It works out of the box and I was able to add a volume control using the Alsa softvol plugin:
.asoundrc:
Code:

pcm.!default {
    type            plug
    slave.pcm       "softvol"   #make use of softvol
}

pcm.softvol {
    type            softvol
    slave {
        pcm        "dmix"      #redirect the output to dmix (instead of "hw:0,0")
    }
    control {
        name        "Master"       #override the PCM slider to set the softvol volume level globally
        card        0
    }
}


The problem is that with dmix, everything gets downsampled to 48 kHz and 16 bit. I was able to force conversion to 24bit this using this .asoundrc (:
Code:

pcm_slave.slave_format_s24le {
  pcm "plug:front"
  format "S24_3LE"
}

pcm.front24 {
  @args [ CARD DEV ]
  @args.CARD {
    type string
  }
  type plug
  slave slave_format_s24le
  hint {
    show {
      @func refer
      name defaults.namehint.basic
    }
    description "Front speakers, converted to S24_3LE"
    device 0
  }
}

pcm.!default front24


But then I am unable to use softvol volume control. Similarly, I can disable dmix and get a native sample rate (for example 96 kHz):
Code:

pcm.!default {
type plug
slave.pcm hw
}


But I have no idea how to combine these three configurations so that I get softvol volume control, 24 bit and 96 kHz output (the soundcard can do either 16 or 24 bit and 48 or 96 kHz). Could anyone help me, please?


Last edited by selig on Thu Sep 06, 2012 7:25 pm; edited 1 time in total
Back to top
View user's profile Send private message
PaulBredbury
Watchman
Watchman


Joined: 14 Jul 2005
Posts: 7310

PostPosted: Wed Sep 05, 2012 8:35 pm    Post subject: Reply with quote

Take a look at my ~/.asoundrc

Change the format and rate within pcm.dmixed

Add softvol into the middle - hopefully you can figure that out, from the examples and notes.
Back to top
View user's profile Send private message
selig
Guru
Guru


Joined: 31 Jul 2005
Posts: 425
Location: Prague, Czech Republic

PostPosted: Thu Sep 06, 2012 7:24 pm    Post subject: Reply with quote

Thanks a lot! That asoundrc really saved me. :) The relevant sections from my asoundrc are here, if anyone needs them:

Code:

pcm.softvol {
    type            softvol
    slave.pcm "dmixed"      #redirect the output to dmix (instead of "hw:0,0")

    control {
        name        "Master"       #override the PCM slider to set the softvol volume level globally
        card        0
    }
}



pcm.dmixed {
        type asym
        playback.pcm {
                # See plugin:dmix at http://www.alsa-project.org/alsa-doc/alsa-lib/pcm_plugins.html
                type dmix
                ipc_key 5678293
                ipc_perm 0660
                ipc_gid audio
                slave {
                        channels 2
                        pcm {
                                format S24_3LE
                                rate 96000

                                type hw
                                card 0
                                device 0
                                subdevice 0
                        }

                        period_size 1024
                         buffer_size 8192
                }

                bindings {
                        0 0
                        1 1
                }
        }
        capture.pcm "hw:0"
}


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



Now I am just not sure what kind of sample rate converter dmix uses. Can this be configured or do I need to put a resampler before dmix and specify converter "samplerate_medium" in it?
Back to top
View user's profile Send private message
PaulBredbury
Watchman
Watchman


Joined: 14 Jul 2005
Posts: 7310

PostPosted: Thu Sep 06, 2012 11:18 pm    Post subject: Reply with quote

Look at my pcm.headphones entry, as an example:
Code:
pcm.headphones {
    type rate
    slave {
        pcm "plug:bs2b"
        #rate 44100
        rate 48000
    }
    # Choices: samplerate_best samplerate_medium samplerate samplerate_order samplerate_linear
    converter "samplerate_medium"

    hint {
        show on
        description "Headphones"
    }
}


Or the easier way, at the top of my ~/.asoundrc:
Code:
defaults.pcm.rate_converter "samplerate_medium"

But don't worry about the samplerate - I've never noticed the slightest difference, on anything expect a single demonstration file (from Ubuntu bug) consisting of crazy audio tones, which was created solely to illustrate the difference in the algorithms.

Edit: Added link to wav file.


Last edited by PaulBredbury on Fri Sep 07, 2012 8:41 am; edited 1 time in total
Back to top
View user's profile Send private message
aCOSwt
Bodhisattva
Bodhisattva


Joined: 19 Oct 2007
Posts: 2537
Location: Hilbert space

PostPosted: Fri Sep 07, 2012 8:19 am    Post subject: Reply with quote

PaulBredbury wrote:
But don't worry about the samplerate - I've never noticed the slightest difference, on anything expect a single demonstration file consisting of crazy audio tones, which was created solely to illustrate the difference in the algorithms.

I'd word this differently : If you can notice the difference, then, you should not use an Alsa plugin for resampling. :wink:
_________________
Back to top
View user's profile Send private message
Display posts from previous:   
Reply to topic    Gentoo Forums Forum Index Multimedia All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum