Forums

Skip to content

Advanced search
  • Quick links
    • Unanswered topics
    • Active topics
    • Search
  • FAQ
  • Login
  • Register
  • Board index Assistance Multimedia
  • Search

Forcing alsa dmix to 24 bit 96 kHz with softvol [SOLVED]

Help with creation, editing, or playback of sounds, images, or video. Amarok, audacious, mplayer, grip, cdparanoia and anything else that makes a sound or plays a video.
Post Reply
Advanced search
5 posts • Page 1 of 1
Author
Message
selig
Guru
Guru
User avatar
Posts: 425
Joined: Sun Jul 31, 2005 4:58 pm
Location: Prague, Czech Republic

Forcing alsa dmix to 24 bit 96 kHz with softvol [SOLVED]

  • Quote

Post by selig » Wed Sep 05, 2012 7:51 pm

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: Select all

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: Select all

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: Select all

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.
Top
PaulBredbury
Watchman
Watchman
User avatar
Posts: 7310
Joined: Thu Jul 14, 2005 3:47 pm

  • Quote

Post by PaulBredbury » Wed Sep 05, 2012 8:35 pm

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.
Top
selig
Guru
Guru
User avatar
Posts: 425
Joined: Sun Jul 31, 2005 4:58 pm
Location: Prague, Czech Republic

  • Quote

Post by selig » Thu Sep 06, 2012 7:24 pm

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

Code: Select all

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?
Top
PaulBredbury
Watchman
Watchman
User avatar
Posts: 7310
Joined: Thu Jul 14, 2005 3:47 pm

  • Quote

Post by PaulBredbury » Thu Sep 06, 2012 11:18 pm

Look at my pcm.headphones entry, as an example:

Code: Select all

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: Select all

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.
Top
aCOSwt
Bodhisattva
Bodhisattva
Posts: 2537
Joined: Fri Oct 19, 2007 1:48 pm
Location: Hilbert space

  • Quote

Post by aCOSwt » Fri Sep 07, 2012 8:19 am

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:
Top
Post Reply

5 posts • Page 1 of 1

Return to “Multimedia”

Jump to
  • Assistance
  • ↳   News & Announcements
  • ↳   Frequently Asked Questions
  • ↳   Installing Gentoo
  • ↳   Multimedia
  • ↳   Desktop Environments
  • ↳   Networking & Security
  • ↳   Kernel & Hardware
  • ↳   Portage & Programming
  • ↳   Gamers & Players
  • ↳   Other Things Gentoo
  • ↳   Unsupported Software
  • Discussion & Documentation
  • ↳   Documentation, Tips & Tricks
  • ↳   Gentoo Chat
  • ↳   Gentoo Forums Feedback
  • ↳   Duplicate Threads
  • International Gentoo Users
  • ↳   中文 (Chinese)
  • ↳   Dutch
  • ↳   Finnish
  • ↳   French
  • ↳   Deutsches Forum (German)
  • ↳   Diskussionsforum
  • ↳   Deutsche Dokumentation
  • ↳   Greek
  • ↳   Forum italiano (Italian)
  • ↳   Forum di discussione italiano
  • ↳   Risorse italiane (documentazione e tools)
  • ↳   Polskie forum (Polish)
  • ↳   Instalacja i sprzęt
  • ↳   Polish OTW
  • ↳   Portuguese
  • ↳   Documentação, Ferramentas e Dicas
  • ↳   Russian
  • ↳   Scandinavian
  • ↳   Spanish
  • ↳   Other Languages
  • Architectures & Platforms
  • ↳   Gentoo on ARM
  • ↳   Gentoo on PPC
  • ↳   Gentoo on Sparc
  • ↳   Gentoo on Alternative Architectures
  • ↳   Gentoo on AMD64
  • ↳   Gentoo for Mac OS X (Portage for Mac OS X)
  • Board index
  • All times are UTC
  • Delete cookies

© 2001–2026 Gentoo Foundation, Inc.

Powered by phpBB® Forum Software © phpBB Limited

Privacy Policy

 

 

magic