Forums

Skip to content

Advanced search
  • Quick links
    • Unanswered topics
    • Active topics
    • Search
  • FAQ
  • Login
  • Register
  • Board index Discussion & Documentation Documentation, Tips & Tricks
  • Search

[HOWTO]clone sound output to 2 devices using alsa

Unofficial documentation for various parts of Gentoo Linux. Note: This is not a support forum.
Post Reply
Advanced search
4 posts • Page 1 of 1
Author
Message
chainsawbike
Tux's lil' helper
Tux's lil' helper
Posts: 78
Joined: Thu Dec 27, 2007 5:08 am
Location: the great new zealand

[HOWTO]clone sound output to 2 devices using alsa

  • Quote

Post by chainsawbike » Mon Nov 21, 2011 12:45 am

this sets alsa to output stereo sound to 2 hardware devices ( a usb headset "Headset" and an onboard chip "SB" )

/etc/asound.conf:

Code: Select all

# sets default "volume control" device to the headset
ctl.!default {
	type hw
	#see notes at bottom under the control section about this setting
	card "Headset"
}

# sets the default output device to the "pcm.both" device
pcm.!default both

# the fun begins...
pcm.both {
	#add the software volume control plugin to the chain first - creates a volume control for "everything" fed into the default alsa device
	type softvol
	slave {
		pcm {
			# add the plug plugin, the "Automatic conversion plugin" - allows a 2 channel source to feed what is technically a 4 channel plugin
			type plug
			slave {
				pcm {
				# add the route plugin - used to rearrange the channels
					type route
					slave {
						pcm {
							# add the multi plugin - used to merge the 2 sound cards together
							type multi;
							slaves.a.pcm{
								# add the dmix plugin - needed for multiple input into one hardware card if the card does not support hardware mixing
								type dmix
								# if i mess with this it doesn't work (and yes i made it up)?!
								ipc_key 2589455
								#needed for multiple users accessing the sound card at the same time
								ipc_perm 0666
								slave {
									pcm {
										# add the "SB" card - change to suit your sound card #1
										type hw
										card SB
										device 0
									}
								buffer_size 4096
								channels 2
								}
							}
							slaves.b.pcm{
								type dmix
								ipc_key 4855689
								ipc_perm 0666
								slave {
										pcm {
											#add the "Headset"sound card - change to suit your sound card #2
											type hw
											card Headset
											device 0
										}
								buffer_size 4096
								channels 2
								}
							}
							# this creates a 4 channel stream using 2 inputs from each card
							slaves.a.channels 2;
							slaves.b.channels 2;
							bindings.0.slave a;
							bindings.0.channel 0;
							bindings.1.slave a;
							bindings.1.channel 1;
							bindings.2.slave b;
							bindings.2.channel 0;
							bindings.3.slave b;
							bindings.3.channel 1;
							}
						}
					#this merges channel 2 and 3 into 0 and 1 respectively
					ttable.0.0 1;
					ttable.1.1 1;
					ttable.0.2 1;
					ttable.1.3 1;
				}
			}
		}
	}
	control{
		# define volume control name - i used master on Headset as my Headset did not create one and most ( of my ) apps try to change "Master" by default
		# if you already have a "Master" volume control you will need to name it something else
		name Master
		# the card used to add the software control to - used for accessing the control does not affect the output of that card directly ( ie it changes the output of both devices just shows up in the one selected )
		# you also will need to change the device set in the first block (ctl.!default) to the same card to ensure it is chosen as the default
		card Headset
	}
}
[EDIT] added/rearranged stuff and added a "master" volume control
Last edited by chainsawbike on Tue Nov 22, 2011 7:49 am, edited 1 time in total.
Top
VinzC
Watchman
Watchman
User avatar
Posts: 5100
Joined: Sat Apr 17, 2004 1:51 pm
Location: Dark side of the mood

  • Quote

Post by VinzC » Mon Nov 21, 2011 12:41 pm

Sounds ( :D ) interesting but mind explaining what all those cryptic symbols actually do? I for one had no idea that could be done with ALSA. Least I could say is that I never touch ALSA configuration; understand what is done is one thing, improvise and start doing something with it is quite different...
Gentoo addict: tomorrow I quit, I promise!... Just one more emerge...
1739!
Top
chainsawbike
Tux's lil' helper
Tux's lil' helper
Posts: 78
Joined: Thu Dec 27, 2007 5:08 am
Location: the great new zealand

  • Quote

Post by chainsawbike » Tue Nov 22, 2011 7:53 am

ive attempted to explain it better - not one of my greatest skills though :P
Top
VinzC
Watchman
Watchman
User avatar
Posts: 5100
Joined: Sat Apr 17, 2004 1:51 pm
Location: Dark side of the mood

  • Quote

Post by VinzC » Fri Nov 25, 2011 2:50 pm

Great! Thanks a lot! 8)
Gentoo addict: tomorrow I quit, I promise!... Just one more emerge...
1739!
Top
Post Reply

4 posts • Page 1 of 1

Return to “Documentation, Tips & Tricks”

Jump to
  • Assistance
  • ↳   News & Announcements
  • ↳   Frequently Asked Questions
  • ↳   Installing Gentoo
  • ↳   Multimedia
  • ↳   Desktop Environments
  • ↳   Networking & Security
  • ↳   Kernel & Hardware
  • ↳   Portage & Programming
  • ↳   Gamers & Players
  • ↳   Other Things Gentoo
  • ↳   Unsupported Software
  • Discussion & Documentation
  • ↳   Documentation, Tips & Tricks
  • ↳   Gentoo Chat
  • ↳   Gentoo Forums Feedback
  • ↳   Duplicate Threads
  • International Gentoo Users
  • ↳   中文 (Chinese)
  • ↳   Dutch
  • ↳   Finnish
  • ↳   French
  • ↳   Deutsches Forum (German)
  • ↳   Diskussionsforum
  • ↳   Deutsche Dokumentation
  • ↳   Greek
  • ↳   Forum italiano (Italian)
  • ↳   Forum di discussione italiano
  • ↳   Risorse italiane (documentazione e tools)
  • ↳   Polskie forum (Polish)
  • ↳   Instalacja i sprzęt
  • ↳   Polish OTW
  • ↳   Portuguese
  • ↳   Documentação, Ferramentas e Dicas
  • ↳   Russian
  • ↳   Scandinavian
  • ↳   Spanish
  • ↳   Other Languages
  • Architectures & Platforms
  • ↳   Gentoo on ARM
  • ↳   Gentoo on PPC
  • ↳   Gentoo on Sparc
  • ↳   Gentoo on Alternative Architectures
  • ↳   Gentoo on AMD64
  • ↳   Gentoo for Mac OS X (Portage for Mac OS X)
  • Board index
  • All times are UTC
  • Delete cookies

© 2001–2026 Gentoo Foundation, Inc.

Powered by phpBB® Forum Software © phpBB Limited

Privacy Policy

 

 

magic