Are you a spammer

Please note, that the first 3 posts you make, will need to be approved by a forum Administrator or Moderator before they are publicly viewable.
Each application to join this forum is checked at the Stop Forum Spam website. If the email or IP address appears there when checked, you will not be allowed to join this forum.
If you get past this check and post spam on this forum, your posts will be immediately deleted and your account inactivated.You will then be banned and your IP will be submitted to your ISP, notifying them of your spamming. So your spam links will only be seen for an hour or two at most. In other words, don't waste your time and ours.

This forum is for the use and enjoyment of the members and visitors looking to learn about and share information regarding the topics listed. It is not a free-for-all advertising venue. Your time would be better spent pursuing legitimate avenues of promoting your websites.

Automatic USB Sound Device

Post your How to's here


Automatic USB Sound Device

Postby slingshotsuicide » Thu Jun 11, 2009 1:53 am

Sorry, Epic fail it worked a little longer than it took to write this how to, and I'm back to trial and error. I'll be back to rewrite it when I'm sure I have it right. Again, my apologies for the inconvience.

I finally got this working on my system after several months of on and off trial, error, and web searching. My application is specifically a pair of Micro Innovations USB speakers attached to my Ultimate Edition laptop, but should be effective for USB headsets and sound cards as well. Firstly, you'll need to know what sound devices are available to your current user. To do this, we'll open a terninal and:

asoundconf list

This will show the sound devices alsa sees as available to you. If none of them are the one you're looking for, make sure your device is connected, if it is, make sure that you have permission to use the one you're looking for.

Then, we'll use:

asoundconf set-default-card name_you_think_is_right

I tested this by mousing onto an mp3 file and listening to where the sound came from. Repeat this command and test for the name you think is your internal. Remember that if you decide to use a program to play the file you're using to test with, it will have to be restarted after each asoundconf set-default-card that you run. Now you can switch from one to the other.

I can hear it already, "That's great slingshot, but I don't want to open a terminal to switch," you say. No problem, I'm lazy too. All we need now is a udev rule to handle that tedious CLI stuff, and here's how to do it.

Remove your USB sound device, open a terminal, and:

ls /dev

Plug in your sound device, and ls /dev again. Look for the new entry. It's probably dsp1. If it is, then:

udevadm info -a -p $(udevadm info -q path -n/dev/dsp1)

This will output a list of udev matching keys for your device and all it's parent devices. If you're not familiar with udev rule writing, this may be of help http://www.reactivated.net/writing_udev_rules.html Choose at least one key from the device itelf, another one from either the device, or one, and only one, of it's parent devices. I chose the serial number to make my rule specific. Open your favorite text editor as root, and copy these lines into it:

[match_key], [match-key], ACTION=="add", RUN+="/usr/bin/asoundconf [external_device]"
[match_key], [match-key], ACTION=="add", RUN+="/usr/bin/asoundconf [internal_device]"

These are the lines from mine as an example. If you need to know more help, http://www.reactivated.net/writing_udev_rules.html

KERNEL=="dsp1", ATTRS{serial}=="0000:00:1d.2", ACTION=="add", RUN+="/usr/bin/asoundconf default"
KERNEL=="dsp1", ATTRS{serial}=="0000:00:1d.2", ACTION=="remove", RUN+="/usr/bin/asoundconf ICH6"

Once you've entered your match keys, and device names, save this file as /etc/udev/rules.d/10-USB-Sound.rules. Now, when you plug in your device, udev will tell alsa to use it, and when you unplug it, udev will tell alsa to use the internal.
The glass is neither half empty nor half full. It is functioning 100% effectively @ 50% capacity. It is approximately 75% efficient. I suggest fitting a lid of some sort.
Mine: MSI L725
Intel M740 1.73GH
nVidia Go 6600
2GB
160G pata Seagate
Intel ProWireless2200
Hers: HP dv 6000
AMD
3G
250Gb
Vista Office 2k7Ultimate (forced to play nice together with Blackboard OMFG!! Thank Moz for Firefox Don't f&*%ing ask)
Ours
HP C6280 Networked
Linksys WRT110
User avatar
slingshotsuicide
U.E. Knowledgable
U.E. Knowledgable
 
Posts: 42
Joined: Fri Nov 21, 2008 11:07 am
Location: Saginaw, MI
Age: 51
Operating System: Ultimate Edition 3.2 32 BIT

Return to How To's (Do not post questions please)

Who is online

Users browsing this forum: No registered users and 20 guests