📜 ⬆️ ⬇️

Linux: use 2 sound cards

It so happened that I have headphones with a built-in sound card and USB connection. By installing Gentoo , it became necessary to streamline the use of the sound I need in a particular program. It turned out that a thoughtful dialogue with Google is needed.
What is interesting, there is a place to be full of different configuration settings for different programs and the non-obviousness of settings for the OS.

Next, I will give my file " /etc/modprobe.d/alsa.conf " as well as ways to set the desired sound in mplayer, mpg321, amarok and skype.
As they say, welcome to our menagerie.
So, we register both sound cards and we explicitly give them indices. By default, we put the headphones.

alias char-major-116 snd
alias char-major-14 soundcore
#
alias /dev/mixer snd-mixer-oss
alias /dev/dsp snd-pcm-oss
alias /dev/midi snd-seq-oss

## --- ALSACONF version 1.0.14rc1 ---
## card 1
alias snd-card-0 snd-usb-audio
alias sound-slot-0 snd-card-0

## card2
alias snd-card-1 snd-atiixp
alias sound-slot-1 snd-card-1

alias sound-service-1-0 snd-mixer-oss
alias sound-service-1-3 snd-pcm-oss
alias sound-service-1-12 snd-pcm-oss

options snd-usb-audio index=0 #
options snd-atiixp index=1 #

options snd cards_limit=3

After rebooting the modules (update-modules -f) and sound (/etc/init.d/alsasound restart) should work according to the idea. Headphones are defined by the index 0 and the built-in card is index 1. For example, to adjust the sound level, dial “alsamixer -c1” for the built-in sound card. For headphones, you can without additional parameters.
')
Next, you need to ask the program which sound card to use. By default, all programs will select a headset with my config. To output the sound to the speaker, set the sound as follows:

mplayer -ao alsa:device=hw=1.0 filename

Bad, the fact that this parameter is clearly not given in the manual and googling is also unimportant.

It would seem that we now know how to set the sound for mpg321. But not really! For mpg321 a little bit different:

mpg321 -a hw:1,0 filename

As you can see, the syntax is somehow different. Okay, remember. Now let's try doing the same thing in amarok , xine or kaffein . The search string is now completely different! In the right place in the settings window, enter:

plughw=1.0

And with what, in fact, such a discord? Is it really impossible to work out a uniform format for these very settings, an xml file there, or something else?
Well, finally, good words addressed to Skype. From version 1.4 it seems that there the sound card is selected by name from the settings window.
I hope to save time for those who are in my situation, although now the wiki engines are much more complete than 4 years ago and are well indexed.
Beyond the mini-review, it’s left to know how to bind hotkeys to programs and WM-s. I'll try to write about it another time.

Source: https://habr.com/ru/post/76501/


All Articles