How to change default sound card

Internal storage, motherboards, PCI cards, stuff inside the case.

How to change default sound card

Postby OJ » 15 Dec 2009, 09:09

I have three sound cards in this machine and the handbook doesn't appear to address this problem. One card works with one driver and the other two work with another. For now, I have set the single card using /boot/loader.conf and have sound, but I would like to use the other two cards as well.

1. How do I set the default card?
2. How do I switch between them?
OJ
Member
 
Posts: 342
Joined: 04 Dec 2009, 04:09
Location: Coalmont BC, Canada

Postby SirDice » 15 Dec 2009, 09:31

OJ wrote:1. How do I set the default card?

Create a softlink [file]/dev/dsp[/file] pointing at the correct one.

2. How do I switch between them?

Select the proper [file]/dev/dsp[1..9][/file] in your application.
Senior UNIX Engineer at Unix Support Nederland
Experience is something you don't get until just after you need it.
User avatar
SirDice
Old Fart
 
Posts: 16161
Joined: 17 Nov 2008, 16:50
Location: Rotterdam, Netherlands

Postby joel@ » 15 Dec 2009, 10:29

For example, typing the following will change your default audio device from 0 to 1 (as root, of course).
Code: Select all
# sysctl hw.snd.default_unit=1


To view all detected audio devices, do a:
Code: Select all
# cat /dev/sndstat


Output will look something like this:
Code: Select all
# cat /dev/sndstat
FreeBSD Audio Driver (newpcm: 32bit 2009061500/i386)
Installed devices:
pcm0: <AudioPCI ES1371-A> at io 0x2040 irq 16 kld snd_es137x [MPSAFE] (2p:1v/1r:1v channels duplex default)

In this example, I only have one device (pcm0).
User avatar
joel@
Member
 
Posts: 245
Joined: 27 Sep 2007, 06:42
Location: Arentorp, Sweden

Postby OJ » 15 Dec 2009, 11:35

Thanks joel@ sysctl works!
I haven't tested all the outputs yet but I assume there will be all five choices which are listed in /dev/sndstat when I load all drivers.

My next problem will be how to use different cards at once, but I haven't lined up all my programs yet so this is good for now.

@SirDice: your idea is interesting to me, but I don't know how to make links yet. I will have a look at the ln man pages.
OJ
Member
 
Posts: 342
Joined: 04 Dec 2009, 04:09
Location: Coalmont BC, Canada

Postby hedwards » 17 Dec 2009, 00:18

OJ wrote:@SirDice: your idea is interesting to me, but I don't know how to make links yet. I will have a look at the ln man pages.

You don't. That's something that you use devfs for. You can make links, but you'll be doing it each and ever boot, not necessarily bad for testing, but a pain.

I'd take a look at /etc/devfs.conf for examples as well as to actually set it up.
hedwards
Member
 
Posts: 189
Joined: 16 Nov 2008, 18:52

Postby OJ » 17 Dec 2009, 04:51

I'd take a look at /etc/devfs.conf for examples as well as to actually set it up.

I'm not sure how to use that file for this particular purpose, but you mentioning it led me to look at /etc/sysctl.conf which seems to be the place to put sysctl parameters such as joel@ mentioned. Thanks. :)
OJ
Member
 
Posts: 342
Joined: 04 Dec 2009, 04:09
Location: Coalmont BC, Canada

Postby hedwards » 18 Dec 2009, 01:06

OJ wrote:I'm not sure how to use that file for this particular purpose, but you mentioning it led me to look at /etc/sysctl.conf which seems to be the place to put sysctl parameters such as joel@ mentioned. Thanks. :)

Ah, what you'd do is put something like:
Code: Select all
link    dsp1     dsp

into the file and then each time that the devfs is started up the link is created linking dsp1 to dsp.
hedwards
Member
 
Posts: 189
Joined: 16 Nov 2008, 18:52

Postby commx » 30 Jul 2010, 18:59

Based on the sysctl idea, I've built a tiny command line tool which allows you to list available sound devices and set the default one. It may also be used to detect sound devices using the generic audio driver.

Maybe this helps someone.

Available via mercurial or as .tar.bz2 archive.
commx
Junior Member
 
Posts: 5
Joined: 01 May 2010, 00:47

change default soundcard dsp pcm device

Postby Woland » 10 Jan 2011, 19:12

Making a symlink won't work, because chances are that there is alrady a /dev/dsp that was set up at boot time.
This line:
Code: Select all
link    dsp1     dsp
[B]DOES NOT WORK![/B]

so don't do that.

The only way I found to permanantly and effectively change my soundcard, is to add the follwing line to my /etc/sysctl.conf:
Code: Select all
hw.snd.default_unit=1


You may need to replace the "1' with the correct number for the working pcm device. How do you know which is the correct device? do "ls /dev/dsp*" then "cat foo.txt > /dev/dsp$N" , where "foo.txt" is any non-empty file on your system, for each of the dsp devices found.

This problem has buggered me for way too long, considering how simple the solution is. I would represent that this is may be a stumbling block for the novice user, espceially since lots of systems have multiple soundcards these days. Perhaps a small addition to the handbook may be in order?
Woland
Junior Member
 
Posts: 19
Joined: 05 Aug 2010, 23:35
Location: Colorado


Return to System Hardware

Who is online

Users browsing this forum: No registered users and 0 guests