You are not logged in.

#1 2010-05-06 23:10:27

mkscrg
Member
Registered: 2010-05-03
Posts: 3

An Easier Way to Change Sound Cards?

I've got Arch running a Macbook Pro 2.2 with Xfce on top. I have an external (USB) sound card that sits between the computer and my speakers/headphones/etc.

I can make the external card work by changing the value of

defaults.pcm.card

in /usr/share/alsa/alsa.conf and restarting alsa. I have to do this every time I plug the thing in, and I have to change it back whenever I unplug it, or else no sound.

Is there a better way? Is there a way to change the active sound card without changing the default in alsa.conf?

Thanks,
Mike

Last edited by mkscrg (2010-05-06 23:10:48)

Offline

#2 2010-05-06 23:18:54

ngoonee
Forum Fellow
From: Between Thailand and Singapore
Registered: 2009-03-17
Posts: 7,354

Re: An Easier Way to Change Sound Cards?

Pulseaudio allows you to insert the sound-card on-the-fly and move the streams of current programs from one to the other, or have both on (and different apps playing to each one) at the same time.

Of course, you could also set up a script which watches for the device appearing and then modifies your .asoundrc (or copies a different one) but why repeat someone else's work?


Allan-Volunteer on the (topic being discussed) mailn lists. You never get the people who matters attention on the forums.
jasonwryan-Installing Arch is a measure of your literacy. Maintaining Arch is a measure of your diligence. Contributing to Arch is a measure of your competence.
Griemak-Bleeding edge, not bleeding flat. Edge denotes falls will occur from time to time. Bring your own parachute.

Offline

#3 2010-05-11 12:04:53

litemotiv
Forum Fellow
Registered: 2008-08-01
Posts: 5,026

Re: An Easier Way to Change Sound Cards?

ngoonee wrote:

Pulseaudio allows you to insert the sound-card on-the-fly and move the streams of current programs from one to the other, or have both on (and different apps playing to each one) at the same time.

Of course, you could also set up a script which watches for the device appearing and then modifies your .asoundrc (or copies a different one) but why repeat someone else's work?

i don't consider adding another framework/daemon a sane solution for something as simple as changing soundcards.

p.s., OSS4 can do this with a single command, since it's default soundcard is symlinked to /dev/dsp/ (you can force overwrite this with another card). i'm not sure whether it supports the MBP2,2 though, but i believe it does.

Last edited by litemotiv (2010-05-11 12:23:12)


ᶘ ᵒᴥᵒᶅ

Offline

#4 2010-05-11 13:43:36

litemotiv
Forum Fellow
Registered: 2008-08-01
Posts: 5,026

Re: An Easier Way to Change Sound Cards?

here's a nice udev rule for alsa i found online:

# Default to using additional (USB) sound cards when they are available.
KERNEL=="pcmC[D0-9cp]*", ACTION=="add", PROGRAM="/bin/sh -c 'K=%k; K=$${K#pcmC}; K=$${K%%D*}; echo defaults.ctl.card $$K > /etc/asound.conf; echo defaults.pcm.card $$K >>/etc/asound.conf'"
KERNEL=="pcmC[D0-9cp]*", ACTION=="remove", PROGRAM="/bin/sh -c 'echo defaults.ctl.card 0 > /etc/asound.conf; echo defaults.pcm.card 0 >>/etc/asound.conf'"

(source)


ᶘ ᵒᴥᵒᶅ

Offline

#5 2010-05-11 15:15:56

Cdh
Member
Registered: 2009-02-03
Posts: 1,098

Re: An Easier Way to Change Sound Cards?

Since I used ubuntu years ago I use asoundconf. I wonder why it still is not in the official alsa package or even here in the repo. It's in aur.
It doesn't get more simple:

chris@chrispc ~ % asoundconf list
aNames of available sound cards:
NVidia
HDMI
SAA7134
chris@chrispc ~ % asoundconf set-default-card NVidia
chris@chrispc ~ %

It creates a ~/.asoundrc  which includes ~/.asoundrc.asoundcomf which holds the real configuration done by asoundconf.

Programs that output sound while soundcard being changed may need to be restarted, if just restarting the audiostream does not reopen the audio device. With pulseaudio it would indeed work on the fly.

Last edited by Cdh (2010-05-11 15:20:35)


฿ 18PRsqbZCrwPUrVnJe1BZvza7bwSDbpxZz

Offline

#6 2010-05-11 16:47:35

Erathor
Member
Registered: 2008-04-27
Posts: 2

Re: An Easier Way to Change Sound Cards?

There's a graphical interface for asoundconf, listed in the KDE Menu with the name Default-Sound-Card. It's installed at the same time u install the text interface.

Greetings.

Offline

Board footer

Powered by FluxBB