Possible to run dual sound cards for different outputs in Linux?

Kaido

Elite Member & Kitchen Overlord
Feb 14, 2004
51,229
7,057
136
I want to run dual sound cards, with one sound card plugged into a headset (speaker/mic) for voice chat and the second sound card plugged into speakers for playing MP3s. Is it possible to run both at the same time and to specify which programs output to which soundcard?
 

bersl2

Golden Member
Aug 2, 2004
1,617
0
0
yes

But it may require some (black, IMO) magic. ALSA's configurables are so damn cryptic and confusing. Maybe one day another abstraction layer will provide a simpler and more unified interface for us sound idiots. :p

What programs are we talking about here?
 

Kaido

Elite Member & Kitchen Overlord
Feb 14, 2004
51,229
7,057
136
Originally posted by: bersl2
yes

But it may require some (black, IMO) magic. ALSA's configurables are so damn cryptic and confusing. Maybe one day another abstraction layer will provide a simpler and more unified interface for us sound idiots. :p

What programs are we talking about here?

basically an intercom/music system for integration with a smart home, just an idea I'm sketching out. there will be a central server along with individual low-powered computers running touchscreen monitors around the house. the panel of each touchscreen will feature a small built-in speaker and microphone as well as a volume control knob for the audio system in that particular room. the first sound card will be routed to a homebuilt amp for the speakers, for playing music as controlled by the touchscreen. the second sound card will be for the small speaker and integrated mic, for the intercom system and listening to security camera audio (webcams). here's the basic panel idea:

http://www.wiredbynature.org/temp/panel3.jpg

this way if an MP3 is selected from the menu, the streaming file will automatically be routed to the second sound card where it will be fed to the amp and then to the in-wall speakers. however, if the intercom system is in use, the audio will instead go to the built-in speaker/mic on the panel via the first sound card. this way there doesn't have to be a switch involved; it's all automatic.
 

Nothinman

Elite Member
Sep 14, 2001
30,672
0
0
Depends on the app, most ALSA apps let you specify the output device (for an example look at the man page for aplay) and if you're using the OSS devices it should be as simple as specifying /dev/dsp or /dev/dsp1.
 

bersl2

Golden Member
Aug 2, 2004
1,617
0
0
Originally posted by: Kaido
Originally posted by: bersl2
yes

But it may require some (black, IMO) magic. ALSA's configurables are so damn cryptic and confusing. Maybe one day another abstraction layer will provide a simpler and more unified interface for us sound idiots. :p

What programs are we talking about here?

basically an intercom/music system for integration with a smart home, just an idea I'm sketching out. there will be a central server along with individual low-powered computers running touchscreen monitors around the house. the panel of each touchscreen will feature a small built-in speaker and microphone as well as a volume control knob for the audio system in that particular room. the first sound card will be routed to a homebuilt amp for the speakers, for playing music as controlled by the touchscreen. the second sound card will be for the small speaker and integrated mic, for the intercom system and listening to security camera audio (webcams). here's the basic panel idea:

http://www.wiredbynature.org/temp/panel3.jpg

this way if an MP3 is selected from the menu, the streaming file will automatically be routed to the second sound card where it will be fed to the amp and then to the in-wall speakers. however, if the intercom system is in use, the audio will instead go to the built-in speaker/mic on the panel via the first sound card. this way there doesn't have to be a switch involved; it's all automatic.

All I can tell you is that you'd better start reading some ALSA documentation. What you're intending to do sounds to me like it will require asoundrc black magic, knowledge of the alsa-lib API, and/or finding the right audio application(s) to use.

EDIT: Oh, yeah, you can also use the much simpler OSS interface. :laugh:
 

Nothinman

Elite Member
Sep 14, 2001
30,672
0
0
All I can tell you is that you'd better start reading some ALSA documentation. What you're intending to do sounds to me like it will require asoundrc black magic, knowledge of the alsa-lib API, and/or finding the right audio application(s) to use.

If the app supports ALSA properly it shouldn't require any more than selecting the appropriate device name.
 

bersl2

Golden Member
Aug 2, 2004
1,617
0
0
Originally posted by: Nothinman
All I can tell you is that you'd better start reading some ALSA documentation. What you're intending to do sounds to me like it will require asoundrc black magic, knowledge of the alsa-lib API, and/or finding the right audio application(s) to use.

If the app supports ALSA properly it shouldn't require any more than selecting the appropriate device name.

Hence option 3. Probably some scripting logic too, but that kinda goes without saying.
 

drag

Elite Member
Jul 4, 2002
8,708
0
0
Alsa isn't as bad as some people try to make it out to be. It's just a bit confusing.

I use 2 cards on my desktop.

You can't realy syncronise them... like taking two similar cards and combining their outputs to make one big sound card. That is difficult and unless it's something that is supported by your card (some professional stuff can do that) you have to hack at hardware to make them sync correctly. (what one card things is 4100 hz isn't nessicarially what another card thinks.)

If you want to get fancy with alsa, like have multiple sound cards and control which sound output goes to which individual speakers and such things then you can get complicated.
If you need to set it up so that you use software mixing (your hardware can only handle one sound at a time) then that can get kinda complicated.

Fancy is hard, simple is easy.

The normal GUI utilities is inadiquate for dealing with this stuff. They are designed for lowest common denominator. The exception is the tools that come from the actual alsa project. There are a few that are specific for individual cards that are very fancy.. For instance my Audiophile 24/96 is a 'prosumer' style card that has features that normal cards don't have and lack features that normal cards do have. It has (and similar cards) have it's own Envy24 Control.

But generally speaking...

But the easy thing to do is open up the command line and go:
cat /proc/asound/cards

Then that will show what hardware you have aviabile and their numbers.
This is what I get:
cat /proc/asound/cards
0 [M2496 ]: ICE1712 - M Audio Audiophile 24/96
M Audio Audiophile 24/96 at 0xb800, irq 22
1 [Intel ]: HDA-Intel - HDA Intel
HDA Intel at 0xcfcf8000 irq 19


So then to get to the mixer controls you use alsamixer or alsamixergui like such:
alsamixer -c 0
or
alsamixer -c 1
depending on what card you want.

Then to play to one or the other card is different for each app. Also the app must be alsa-aware.. lots of applications only support OSS which causes problems with this sort of thing. Most apps are configurable one way or another.

For instance to play to the Intel-HD I would go:
mplayer -ao alsa:device=hw=1 song.mp3

Usually what I do is have one application configured to play music for me on one sound card while I send all the other sound stuff to the other one.

To make things convient or for some sound cards that are limited you have to setup a ~/.asoundrc file. It's a bit of a trial or error setting one of up if you never did it before and a bit of a headache, but it's not to hard if you follow some examples you can find on the web.
 

Kaido

Elite Member & Kitchen Overlord
Feb 14, 2004
51,229
7,057
136
Originally posted by: drag
Usually what I do is have one application configured to play music for me on one sound card while I send all the other sound stuff to the other one.

To make things convient or for some sound cards that are limited you have to setup a ~/.asoundrc file. It's a bit of a trial or error setting one of up if you never did it before and a bit of a headache, but it's not to hard if you follow some examples you can find on the web.

Hmm...how reliable would you say a dual-card setup is? I am planning on purchasing my first home within the next 5 years (hopefully sooner) and I am basically scratch-building this project using my own software and hardware, so I have a ton of flexibility as far as the design goes. The current plan as far as the audio goes is to have a central server with a network switch running the show - it will be connected to the sprinklers, network webcams, the panels, electronic door locks, and so on. The music will be stored in MP3 format on the server. Each panel will be comprised of an inexpensive, all-in-one fanless Mini-ITX computer running a custom Linux OS designed to display a Flash client. The Flash client will the GUI as seen in the above mockup and will be controlled via touch input from the touchscreen panel. It will then send commands to the server to create actions such as turning lights on, controlling HVAC, playing music, and so on.

Getting back to the topic at hand, the panel box will contain the mini-itx motherboard and a custom diy stereo amp. The Flash client will contain a streaming player and a menu so that you can call up the music and playlists you want off the server. It will also contain a Linux voice chat application such as TeamSpeak for doing a digital intercom. When an MP3 is selected, the Flash interface pipes it to the streaming audio player, then it is sent to the first sound card, which is connected to the custom amp and then to the room speakers. The voice chat app will be directed to the second sound card for the small speaker and mic. Another option I have is to plug in a pre-amp/splitter into the server and then run speaker connection wires to the amps in each room; that way I would only have to have one sound card. Having dual sound cards would eliminate the need for that, lessen my wiring requirements, and overall be easier to maintain. However if it works like crap then it just won't do ;)