Here's something that potentially may be part of a good general solution:
http://alsa.opensrc.org/Default_device_from_environment_variable
Here's something that potentially may be part of a good general solution:
http:// alsa.opensrc. org/Default_ device_ from_environmen t_variable