You are not logged in.

#1 2011-12-13 17:50:50

Shark
Member
From: /dev/zero
Registered: 2011-02-28
Posts: 686

Per application volume control with alsa?

Hi

I have alsa sound platform and i am wondering if it is possible to control the volume of each application? I know it is possible with pulseaudio and OSS.


If you have built castles in the air, your work need not be lost; that is where they should be. Now put foundations under them.
Henry David Thoreau

Registered Linux User: #559057

Offline

#2 2011-12-14 08:25:20

mrhmouse
Member
From: South Eastern US
Registered: 2011-09-09
Posts: 36

Re: Per application volume control with alsa?

I think this is possible through ALSA's "dmix", but I'm not entirely certain. (http://alsa.opensrc.org/Dmix#Default_PCM_device)

You're probably better off handling per-application volume through another sound platform such as the two you mentioned, JACK, aRTS, or something.

Offline

#3 2011-12-14 08:36:08

Pajaro
Member
Registered: 2004-04-21
Posts: 884

Re: Per application volume control with alsa?

arts was used in kde3. Now the standard is pulseaudio. Pulseaudio does what you look for. With jack you can achieve that, but since jack is intended for professional audio, it is going to be a tedious task.

Offline

#4 2011-12-14 09:03:03

Shark
Member
From: /dev/zero
Registered: 2011-02-28
Posts: 686

Re: Per application volume control with alsa?

Thanks. I just thought that there is some way to handle it. Maybe i will try it.


If you have built castles in the air, your work need not be lost; that is where they should be. Now put foundations under them.
Henry David Thoreau

Registered Linux User: #559057

Offline

#5 2011-12-14 10:46:02

drslmr
Member
Registered: 2011-05-14
Posts: 29

Re: Per application volume control with alsa?

I think it should work with the plug softvol if you can have your application send the audio to different plugs with different softvol.

Offline

#6 2011-12-14 11:37:02

Shark
Member
From: /dev/zero
Registered: 2011-02-28
Posts: 686

Re: Per application volume control with alsa?

drslmr wrote:

I think it should work with the plug softvol if you can have your application send the audio to different plugs with different softvol.

What plugin or app should i use then, if any?


If you have built castles in the air, your work need not be lost; that is where they should be. Now put foundations under them.
Henry David Thoreau

Registered Linux User: #559057

Offline

#7 2011-12-15 07:58:23

drslmr
Member
Registered: 2011-05-14
Posts: 29

Re: Per application volume control with alsa?

Hi,

below I dump .asoundrc I used some time ago. It allows to play
e.g. two audio streams at the same time with different volume:

aplay -D tnsrch1 someaudio.wav
aplay -D magnet1 otheraudio.wav

The .asoundrc has been created for a sound card with 4 capture and 4 playback channels.

pcm.!default pcm.channel1

pcm.snd_card0 {
    type hw
    card 0
    device 0
}
ctl.snd_card0 {
    type hw
    card 0
    device 0
}

pcm.dmix0 {
    type dmix
    ipc_key 1024
    ipc_key_add_uid true
    slave.pcm "snd_card0"
    slave {
	period_time 0
	period_size 1024
	buffer_size 4096
	rate 48000
	channels 4
	format S32_LE
    }
    bindings {
	0 0
	1 1
	2 2
	3 3
    }
}
ctl.dmix0 {
    type hw
    card 0
    device 0
}

pcm.dsnoop0 {
    type dsnoop
    ipc_key 2048
    ipc_key_add_uid true
    slave.pcm "snd_card0"
    slave {
	period_time 0
	period_size 1024
	buffer_size 4096
	rate 48000
	channels 4
    }
    bindings {
	0 0
	1 1
	2 2
	3 3
    }
}
ctl.dsnoop0 {
    type hw
    card 0
    device 0
}

pcm.channel1 {
    type asym
    playback.pcm {
	type plug
	slave.pcm "dmix0"
	ttable.0.0 1
    }
    capture.pcm {
	type plug
	slave.pcm "dsnoop0"
	ttable.0.0 1
    }
}


ctl.channel1 {
    type hw
    card 0
    device 0
}

pcm.channel2 {
    type asym
    playback.pcm {
	type plug
	slave.pcm "dmix0"
	ttable.0.1 1
    }
    capture.pcm {
	type plug
	slave.pcm "dsnoop0"
	ttable.0.1 1
    }
}
ctl.channel2 {
    type hw
    card 0
    device 0
}

pcm.channel3 {
    type asym
    playback.pcm {
	type plug
	slave.pcm "dmix0"
	ttable.0.2 1
    }
    capture.pcm {
	type plug
	slave.pcm "dsnoop0"
	ttable.0.2 1
    }
}
ctl.channel3 {
    type hw
    card 0
    device 0
}

pcm.channel4 {
    type asym
    playback.pcm {
	type plug
	slave.pcm "dmix0"
	ttable.0.3 1
    }
    capture.pcm {
	type plug
	slave.pcm "dsnoop0"
	ttable.0.3 1
    }
}
ctl.channel4 {
    type hw
    card 0
    device 0
}

############################################################################
# Rufen port 2110
############################################################################

pcm.rufen {
    type plug
    slave.pcm "dmix0"
    ttable.0.0 1
    ttable.0.1 1
    ttable.0.2 1
    ttable.0.3 1
}

############################################################################
# Beam-Warnungen port 2001
############################################################################

pcm.beam {
    type plug
    slave.pcm "dmix0"
    ttable.0.0 1
    ttable.0.1 1
    ttable.0.2 1
    ttable.0.3 1
}
############################################################################
# Magnet-Warnungen port 2003
# Magnet-Warnung channel, with software controls for each channel
# channel "magnet" should be the destination for magnet currentannopuncements
# "Magnet<N>" should be used to switch a channel on or off by setting the
# volume e.g.:  amixer set Magnet1 80%
############################################################################
pcm.magnet1 {
	type softvol
	slave.pcm "channel1"
	control {
		name "Magnet1"
		card 0
	}
}
pcm.magnet2 {
	type softvol
	slave.pcm "channel2"
	control {
		name "Magnet2"
		card 0
	}
}
pcm.magnet3 {
	type softvol
	slave.pcm "channel3"
	control {
		name "Magnet3"
		card 0
	}
}

pcm.magnet_multi {
    type multi
    
    slaves.a.pcm "magnet1"
    slaves.a.channels 1
    slaves.b.pcm "magnet2"
    slaves.b.channels 1
    slaves.c.pcm "magnet3"
    slaves.c.channels 1

    bindings.0.slave a
    bindings.0.channel 0
    bindings.1.slave b
    bindings.1.channel 0
    bindings.2.slave c
    bindings.2.channel 0
}

pcm.magnet {
    type plug
    slave.pcm "magnet_multi"
    ttable.0.0 1
    ttable.0.1 1
    ttable.0.2 1
}

############################################################################
# Tunnel search port 2010
# Tunnes search channel, with software controls for each channel
# channel "tnsrch" should be the destination for tunnel search annopuncements
# "Tnsrch<N>" should be used to switch a channel on or offf by setting the
# volume e.g.: amixer set Tnsrch1 0%
############################################################################

pcm.tnsrch1 {
	type softvol
	slave.pcm "channel1"
	control {
		name "Tnsrch1"
		card 0
	}
}
pcm.tnsrch2 {
	type softvol
	slave.pcm "channel2"
	control {
		name "Tnsrch2"
		card 0
	}
}
pcm.tnsrch3 {
	type softvol
	slave.pcm "channel3"
	control {
		name "Tnsrch3"
		card 0
	}
}

pcm.tnsrch_multi {
    type multi
    
    slaves.a.pcm "tnsrch1"
    slaves.a.channels 1
    slaves.b.pcm "tnsrch2"
    slaves.b.channels 1
    slaves.c.pcm "tnsrch3"
    slaves.c.channels 1

    bindings.0.slave a
    bindings.0.channel 0
    bindings.1.slave b
    bindings.1.channel 0
    bindings.2.slave c
    bindings.2.channel 0
}

pcm.tnsrch {
    type plug
    slave.pcm "tnsrch_multi"
    ttable.0.0 1
    ttable.0.1 1
    ttable.0.2 1
}

Offline

#8 2011-12-15 16:25:02

brebs
Member
Registered: 2007-04-03
Posts: 3,742

Re: Per application volume control with alsa?

Shark wrote:

control the volume of each application

Each app is supposed to contain its own volume control. If not, if the app allows you to specify the output PCM, then you can set up the PCM in ~/.asoundrc

Softvol can be convenient, but is not necessary - the ttable lines can control volume.

Offline

Board footer

Powered by FluxBB