You are not logged in.

#1 2014-09-09 16:14:07

sauliwx
Member
Registered: 2014-04-14
Posts: 7

[sound] Select audio canal for each application [solved]

Hi all smile

After a long and unsuccessful search on the net I decide to post my question here.

I have a motherboard with the HDA chipset (4 output in the back) and I want to choose for each application the output.

For example : my music on the Master output (plugged to amp),  my video on the Suround output (plugged to a helmet), all the other apps on the Side output (plugged to speakers) ...

I am actually whith ALSA and Pulseaudio, but I am ready to change all to do that (except the ditrib lol )

Thanks in advance wink


(sorry if my english is poor, I am french)

Last edited by sauliwx (2014-09-12 13:43:09)

Offline

#2 2014-09-09 16:32:06

ewaller
Administrator
From: Pasadena, CA
Registered: 2009-07-13
Posts: 20,601

Re: [sound] Select audio canal for each application [solved]

I have only played with it, but you might look into Jack


Nothing is too wonderful to be true, if it be consistent with the laws of nature -- Michael Faraday
The shortest way to ruin a country is to give power to demagogues.— Dionysius of Halicarnassus
---
How to Ask Questions the Smart Way

Offline

#3 2014-09-09 17:02:31

emeres
Member
Registered: 2013-10-08
Posts: 1,570

Re: [sound] Select audio canal for each application [solved]

 @OP You should be able to achieve this using either one pulseaudio or alsa. But jack can be used for a more graphical and convenient way using qjackctl/patchage to set up your desired configuration.

Offline

#4 2014-09-12 13:08:07

sauliwx
Member
Registered: 2014-04-14
Posts: 7

Re: [sound] Select audio canal for each application [solved]

After a long time on ALSA wiki about .asoundrc, I did that :

# 0 - Front Left   - Green L
# 1 - Front Right  - Green R
# 2 - Rear Left    - Black L
# 3 - Rear Right   - Black R
# 4 - Front Center - Orange L
# 5 - LFE          - Orange R
# 6 - Side Left    - Grey L
# 7 - Side Right   - Grey R

pcm.!default {
	type dmix
	ipc_key 1024
	slave {
		pcm "hw:0"
		channels 8
	}
}

pcm.green {
	type route
	slave.pcm default
	ttable.0.0 1
	ttable.1.1 1
	ttable.2.0 1
	ttable.3.1 1
	ttable.4.0 1
	ttable.5.1 1
	ttable.6.1 1
	ttable.7.1 1
}

pcm.black {
	type route
	slave.pcm default
	ttable.0.2 1
	ttable.1.3 1
	ttable.2.2 1
	ttable.3.3 1
	ttable.4.2 1
	ttable.5.3 1
	ttable.6.2 1
	ttable.7.3 1
}

pcm.orange {
	type route
	slave.pcm default
	ttable.0.4 1
	ttable.1.5 1
	ttable.2.4 1
	ttable.3.5 1
	ttable.4.4 1
	ttable.5.5 1
	ttable.6.4 1
	ttable.7.5 1
}

pcm.grey {
	type route
	slave.pcm default
	ttable.0.6 1
	ttable.1.7 1
	ttable.2.6 1
	ttable.3.7 1
	ttable.4.6 1
	ttable.5.7 1
	ttable.6.6 1
	ttable.7.7 1
}

This code allow you to have as much ALSA (stereo) devices as jack on your PC big_smile

After, in many applications config we can choose the output device of our choice.

Last edited by sauliwx (2014-09-12 13:42:30)

Offline

#5 2014-09-12 13:30:57

emeres
Member
Registered: 2013-10-08
Posts: 1,570

Re: [sound] Select audio canal for each application [solved]

 If it works well, you can leave the type route, should there be problems change type route to type plug, it also accepts ttable. The default alsa configuration for pcm.default does not work? What if you comment out the pcm.default definition? I would be interested in the result.
 You use dmix, but with default settings, so sample rate might not be optimal and the format also.

Alsa documentation wrote:

Note that the dmix plugin itself supports only a single configuration. That is, it supports only the fixed rate (default 48000), format (S16), channels (2), and period_time (125000). For using other configuration, you have to set the value explicitly in the slave PCM definition.

 But some values should be referenced from defaults node, like defaults.pcm.dmix.rate.

Offline

#6 2014-09-17 07:43:28

sauliwx
Member
Registered: 2014-04-14
Posts: 7

Re: [sound] Select audio canal for each application [solved]

The default ALSA configuration for pcm.default works, but with it I can not use multiple devices at the same time. That's why I use "type dmix".
But I understood it wasn't a good idea to modify pcm.default so I made a special pcm.dmix44 device to replace my previous pcm.default.

About the type Plug, I'll see it later smile

Offline

#7 2014-09-17 08:41:11

emeres
Member
Registered: 2013-10-08
Posts: 1,570

Re: [sound] Select audio canal for each application [solved]

 Then try this for the default dmix, since you use 8 channels it should work without modification. You can add it to your ~/.asoundrc by adding this line:

<~/.asoundrc-dmix>
<$HOME/.asoundrc-dmix>
<.asoundrc-dmix> # Tell me which one works

 The new dmix configuration obviously needs to be stored in ~/.asoundrc-dmix. Of course you can overwrite pcm.default, it would be wise to add dsnoop to the new definition however. Read /usr/share/alsa/pcm/default.conf. You also loose runtime arguments, although apparently most do not use them.

Edit: Wrong link.

Last edited by emeres (2014-09-17 15:11:46)

Offline

#8 2014-09-17 14:31:18

sauliwx
Member
Registered: 2014-04-14
Posts: 7

Re: [sound] Select audio canal for each application [solved]

Are you sure about your link ? There is no relation with ALSA.

Now, my .asoundrc is like :

<.asoundrc-dmix> #This one works

My .asoundrc-dmix is :

pcm.dmix1 {
	type dmix
	ipc_key 1024
	slave {
		pcm "hw:0"
		channels 8
	}
}

pcm.dsnoop1 {
	type dsnoop 
	ipc_key 2048
	slave {
		pcm "hw:0"
		channels 8
	}
}

pcm.green {
	type plug
	slave.pcm "dmix1"
	ttable.0.0 1
	ttable.1.1 1
	ttable.2.0 1
	ttable.3.1 1
	ttable.4.0 1
	ttable.5.1 1
	ttable.6.1 1
	ttable.7.1 1
}

pcm.black {
	type plug
	slave.pcm "dmix1"
	ttable.0.2 1
	ttable.1.3 1
	ttable.2.2 1
	ttable.3.3 1
	ttable.4.2 1
	ttable.5.3 1
	ttable.6.2 1
	ttable.7.3 1
}

pcm.orange {
	type plug
	slave.pcm "dmix1"
	ttable.0.4 1
	ttable.1.5 1
	ttable.2.4 1
	ttable.3.5 1
	ttable.4.4 1
	ttable.5.5 1
	ttable.6.4 1
	ttable.7.5 1
}

pcm.grey {
	type plug
	slave.pcm "dmix1"
	ttable.0.6 1
	ttable.1.7 1
	ttable.2.6 1
	ttable.3.7 1
	ttable.4.6 1
	ttable.5.7 1
	ttable.6.6 1
	ttable.7.7 1
}

Is that good ?


But, I want my pcm.default point on my pcm.green. Should  I do that :

pcm.!default {
	type plug
slave.pcm "green"

Or there is a more elegant way ?

And I don't understand what you said about runtime arguments.

Offline

#9 2014-09-17 15:29:05

emeres
Member
Registered: 2013-10-08
Posts: 1,570

Re: [sound] Select audio canal for each application [solved]

 My bad, clipboard must have been turned off or I simply confused the links. Here the correct one, once again. Runtime arguments allow you to specify a pcm with parameters set upon execution:

speaker-test -c 2 -t wav -D plug:"dmix:{CARD DG DEV 0}"
# CARD D is one argument and DEV 0 the other. The original dmix takes more arguments
# see /usr/share/alsa/pcm/dmix.conf
# The one I proposed takes also channels number as runtime argument like so
speaker-test -c 8 -t wav -D plug:"dmix:{CARD SB DEV 0 SUBDEV -1 FORMAT S32_LE RATE 192000 CHANNELS 8}"

 The more important thing is dsnoop, otherwise you might have problems when recording. This kind of configuration may end up similar to this proposed one. Similar when it comes to logical structure that is. You might want to try build your configuration into the latter one. Instead of this:

		default {
			# use pulse as default
			type pulse
			fallback "sysdefault"
			hint {
				show on
				description "Default ALSA Output (currently PulseAudio Sound Server)"
			}

 try this based on your part:

		default {
			type asym;
			playback.pcm "green";
			capture.pcm "dsnoop1";
			fallback "sysdefault"
			hint {
				show on
				description "Default ALSA Output (currently green)"
			}

 You had no asym type plugin in there.

Edit: "fallback" might not only be unnecessary, it might conflict or cause an error within the configuration. Untested.

Last edited by emeres (2014-09-17 16:13:40)

Offline

#10 2014-09-17 16:09:41

sauliwx
Member
Registered: 2014-04-14
Posts: 7

Re: [sound] Select audio canal for each application [solved]

Ok !
Thank a lot, you enlighten me on the ALSA audio's darknesses wink

Offline

Board footer

Powered by FluxBB