Easiest way is using Pulseaudio. (You can do it with ALSA, but it will be painful to configure.)
Everything that produces sound is automatically mixed on the current output ("sink" in Pulseaudio terms), so you needn't worry about mixing. You can control volumes with pavucontrol
, and it remembers the last volume by application name. You can use paplay
to play wav files from the commandline, but any other audioplayer will also do.
Converting to mono will be done automatically if your sink is mono. If you can't configure the local RaspPi sink for that (I don't know, I don't own a RaspPi), you can add a "pseudo" sink with
pactl load-module module-null-sink sink_name=whatever
or if it turns out you need to remap in Pulseaudio, module-remap-sink
(see below, haven't tried this myself yet).
This sink or the local RaspPi sink will have an associated .monitor
source which you can use to distribute it to icecast etc.
You can setup a permanent feed of the hw:1 input into your chosen sinks with
pacmd load-module module-loopback source="alsa_input.name_of_hw_1" sink="whatever_or_local_sink"
You can list the available sink names with
pacmd list-sinks | grep name:
As arguments, use the name without the angular brackets.
I think that's the basics. Read about the available Pulseaudio modules, and pacmd help
will tell you what you can do from the commandline, if you don't want to use pavucontrol
.
Edit for ALSA:
First, read about the available plugins. You will need a "virtual soundcard" to route the audio to darkice etc. That's a kernel module, so do something like
sudo modprobe snd-aloop pcm_substreams=2
for testing, and put a file in /etc/modprobe.d
when it works. Say the loopback is hw:3,*,*
.
On the input side of the virtual soundcard, you'll need something like
dmix "main_in" --> plug (slave.channels = 1) --> hw:3,0,0
Then you can aplay -D main_in sound.wav
, and run
alsaloop -C hw:0 -P main_in
to connect it to the audio grabber.
On the output side of the virtual soundcard, something like
hw:3,1,0 --> dsnoop "main_out"
and to monitor it on local audio out, again
alsaloop -C main_out -P local_audio_out
You can then run darkice
and the VU meter directly on main_out
. BTW, arecord -D main_out -d 0 -vv /dev/null
is a nice VU-meter for testing.
Read up details on the syntax in the link above, I'm not going to try this out. The -->
arrows indicate the master/slave relations of the plugin. The latency will probably be horrible, with one loopback through kernel space, and lots of userspace applications.
If Pulseaudio doesn't work for you, an alternative is jack
, but I've no experience configuring it.