On Thu, 23 Nov 2017 11:14:37 -0500
"David A. De Graaf" <dad(a)datix.us> wrote:
By fine, I mean, for example, that scripts that generate sound can be
invoked by any user, in any environment: In /etc/rc.d/rc.local
during boot by root, in a plain text terminal, in an X window by any
user, including root, in a crontab job run by any user. Here's a
simple example :
*** /usr/local/bin/beep ***
NBEEPS=${1:-10000}
REP=`expr $NBEEPS - 1`
/bin/play /usr/share/sounds/freedesktop/stereo/message-new-instant.oga
\ gain -0 pad 0 .4 reverb repeat $REP 2> /dev/null
Try it. It ought to work in any of the above situations.
But it won't if pulseaudio is in the picture.
Pulseaudio will never work in that situation; that was a design
decision. They felt that that was insecure, since a user's soundstreams
could be listened to by other users. I've never tried this, but if
you have more than one sound device, you might be able to use
pavucontrol to turn off one of them for pulse, leaving it available to
alsa only. Then, in an .asoundrc, make that turned off sound device the
default device for alsa users who aren't you, so that all sounds go
through it. If you set up the other sound device as your default in
pulse, it might then allow you to have private audio through pulse, and
general audio through alsa. Long shot, but that, or some
variation, might work.
Without pulseaudio, I think what you want is the alsa plugin dmix. It
provides a simple mix of sounds if more than one source of sound is
playing at the same time in alsa.
It's been so long since I wrote any .asoundrc that I can't advise you.
But you should be able to find historical .asoundrc samples on the web
that do what you want using dmix.