1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

How to change default sound card

Discussion in 'System Hardware' started by OJ, Dec 15, 2009.

  1. OJ

    OJ New Member

    Messages:
    361
    Likes Received:
    0
    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?
     
  2. SirDice

    SirDice Moderator Staff Member Moderator

    Messages:
    17,365
    Likes Received:
    0
    Create a softlink /dev/dsp pointing at the correct one.

    Select the proper /dev/dsp[1..9] in your application.
     
  3. joel@

    joel@ New Member Developer

    Messages:
    245
    Likes Received:
    0
    For example, typing the following will change your default audio device from 0 to 1 (as root, of course).
    Code:
    # sysctl hw.snd.default_unit=1
    
    To view all detected audio devices, do a:
    Code:
    # cat /dev/sndstat
    
    Output will look something like this:
    Code:
    # 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).
     
  4. OJ

    OJ New Member

    Messages:
    361
    Likes Received:
    0
    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.
     
  5. hedwards

    hedwards New Member

    Messages:
    189
    Likes Received:
    0
    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.
     
  6. OJ

    OJ New Member

    Messages:
    361
    Likes Received:
    0
    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. :)
     
  7. hedwards

    hedwards New Member

    Messages:
    189
    Likes Received:
    0
    Ah, what you'd do is put something like:
    Code:
    link    dsp1     dsp
    into the file and then each time that the devfs is started up the link is created linking dsp1 to dsp.
     
  8. commx

    commx New Member

    Messages:
    5
    Likes Received:
    0
    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.
     
  9. Woland

    Woland New Member

    Messages:
    19
    Likes Received:
    0
    change default soundcard dsp pcm device

    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:
    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:
    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?