0

folks. I have an external USB sound card witch may, or may not present in the system depending on my actual location. Previously I used this card as default, so configuration like the following worked just fine:

defaults.ctl.card 1 defaults.pcm.card 1 defaults.pcm.dmix.rate 176400 defaults.pcm.dmix.format S32_LE defaults.timer.card 1 

But since it is possible not to have this card at all, defining it as default is not working anymore, while I still need to redefine pcm.dmix.rate and pcm.dmix.format for that particular card living system defaults (whatever they are) for builtin card 0.

I did a brief search, but found only examples on defining virtual pcms witch is not what I'm looking for.

aplay -l output:

card 0: PCH [HDA Intel PCH], device 0: Generic Analog [Generic Analog] Subdevices: 0/1 Subdevice #0: subdevice #0 card 0: PCH [HDA Intel PCH], device 3: HDMI 0 [HDMI 0] Subdevices: 1/1 Subdevice #0: subdevice #0 card 0: PCH [HDA Intel PCH], device 7: HDMI 1 [HDMI 1] Subdevices: 1/1 Subdevice #0: subdevice #0 card 0: PCH [HDA Intel PCH], device 8: HDMI 2 [HDMI 2] Subdevices: 1/1 Subdevice #0: subdevice #0 card 1: Pro [DX3 Pro], device 0: USB Audio [USB Audio] <- optional card of interest Subdevices: 0/1 Subdevice #0: subdevice #0 

Then here is my external card configured as fully working dmix "device" with a correct sampling rate and format:

pcm.dx3proDM { type dmix ipc_key_add_uid true ipc_key 2048 # mandatory, mast be unique ipc_perm 0660 ipc_gid audio slave { pcm "hw:1" rate 176400 format "S32_LE" channels 2 period_time 0 period_size 1024 buffer_size 8192 # mandatory parameter } bindings { 0 0 1 1 } } 

The problem is that dx3proDM is not usable by the system (I can't select ii as an an output device in Audacous for instance).

I still need to redefine default to point to it:

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

Makeing it default again - exactly opposite to what I'm trying to do.

Any ideas here?

4
  • Having a sound card which may or may not be present sounds like a desktop situation. Is there any particular reason you cannot use Pulseaudio for this (which is the default on the desktop nowadays, anyway), because Pulseaudio will handle that out of the box? In pure ALSA I'd probably do some scripting and change .asoundrc depending on the cards present, but it's a bit of a pain to do... Commented Mar 15, 2021 at 21:59
  • @dirkt The reason for not having PA is.. there is no reason for it. It simply gives me nothing extra that ALSA does not. Commented Mar 16, 2021 at 5:55
  • Well, in that case it would give you something extra ... but if you don't want to do it the easy way, you need to do it the hard way: write udev rules that trigger if you remove or plug in the soundcard, write a script to change asoundrc. I don't see a way to do it with a static asoundrc - default needs to point to something known. That will take a few days to make it work properly. Installing Pulseaudio takes a couple of minutes. Commented Mar 16, 2021 at 7:04
  • There is some misunderstanding. My default card is snd-hda-intel (index=0), it always present in the system and needs no any specific configuration (work perfect with no asound.conf). What I need is to configure 'pcm.dmix.rate' and 'pcm.dmix.format' of an optional external card (card 1, index=1), not the default one. This external card is a dedicated DAC + headphone amp that I use only for listening to the music (no system/any other disturbing sounds are allowed) and can easily switch the output to in Audacious just for the listening session. Commented Mar 16, 2021 at 9:26

1 Answer 1

0

Maybe I still don't understand the problem, but I configure my webcam like this:

pcm.webcam { type plug slave { pcm "front:U0x46d0x809" rate 48000 format "S16_LE" } } 

Is there any reason why cannot configure your optional external card also like this, using the name you get e.g. with aplay -L, and setting whatever parameters you need (on the plug as well) this way, and not using defaults?

Because if you make your configuration card specific, and manually select the webcam plugin when needed as output, there's no reason to use defaults.


The problem is that dx3proDM is not usable by the system (I can't select ii as an an output device in Audacous for instance).

It's perfectly usable (try something like aplay -D dx3proDM some_file.wav), it's just that some applications don't list the plugins, and don't allow you to enter a device name. Which is a limitation of the application, not of ALSA.

I still need to redefine default to point to it [...]

And then we are back to (1) either use a udev script to make that change, or (2) use Pulseaudio, and have it work out of the box.

15
  • I have updated my question. The reason defining card as a slave like I did for dx3proDM as it is not available from the system. Commented Mar 18, 2021 at 21:22
  • Audacious does not see this output, not even alsamixed or aplay -l do. Commented Mar 19, 2021 at 8:08
  • 1
    Basically every player that let's you enter a device name, instead of presenting you with a list. mplayer -ao alsa:noblock:device=dx3proDM will probably work (but I didn't try). If Audacious would let you enter a name, that would be enough. (And I don't expect they'll implement that for you...). Commented Mar 19, 2021 at 22:29
  • 1
    Well.. this happen time to time. The "way to go" emerged just absolutely accidentally while I was searching through the Net for some other ALSA-related thing. The problem wasn't with Audacious, but with ALSA itself. defaults.namehint.showall on make my DAC appear in Audacious output list and became perfectly usable. Commented Mar 23, 2021 at 21:11
  • 1
    Well, dmix doesn't do any conversion, so it won't affect sound quality. It only allows multiple applications to use the same output. The plug does the conversions. Commented Mar 25, 2021 at 8:35

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.