A little tip / trick that can be useful to some
For those who use jack all the time (like me) and do not wish to use pulseaudio or other forms of non jack layers but still would like to redirect non jack apps to jack, I found a trick by using the snd-aloop ALSA module. I was experimenting for something different when it came to me that this could definitely work out, and it did (there are a few caveats though) :
- get the snd-aloop module. It may not be readily available in your kernel install. To make sure, type:
Code: Select all
sudo modinfo snd-aloop
Code: Select all
./configure --with-cards=loopback
make
Code: Select all
sudo cp ./modules/snd-aloop.ko /lib/modules/`uname -r`/kernel/sound/drivers/
sudo depmod -a
----------
OK, snd-aloop can now be loaded
Code: Select all
sudo modprobe snd-aloop
check in /proc/asound/cards that it is listed
The loopback "card" is a couple of device, each device divided in 8 subdevices
So you can refer to hw:Loopback or hw:Loopback,0 (device 0), or hw:Loopback,1,5 (device 1, subdevice 5).
So, once you have that, you can make an .asoundrc file. I used a minimalist dmix based asoundrc:
Code: Select all
pcm.dmix0 {
type dmix
ipc_key 219345 # any unique number here
slave {
pcm "hw:Loopback,0"
period_time 0
buffer_time 0
period_size 2048 # jm: much smoother than 1024/8192!
buffer_size 32768
rate 96000
}
bindings {
0 0 # from 0 => to 0
1 1 # from 1 => to 1
}
}
# this makes native ALSA apps default to using dmix
pcm.!default {
type plug
slave.pcm "dmix0"
}
ctl.!default {
type hw
card Loopback
}
You see that I chose to make this dmix stuff the default ALSA soundcard. That is completely OK since I use jack specifically on hw:DSP (RME card) and this is completely independent.
Now the jack part. Fire up jack as usual and type this:
alsa_in -j Loop -d hw:Loopback,1
this will create a jack client called "Loop" and collects stuff coming to loopback device 1 (I used 0 for the dmix).
Now is the goodie: since it is a loopback device, the output is redirected to the input so all ALSA apps using the default device (dmix based on Loopback) will have their audio collected by the second Loopback device which alsa_in listens to. Now you can plug our Loop client to your usual jack system outputs and voila
You can fire up an non jack app like smasher (the beat crusher ) and have its audio in the jack graph.
===========
Caveats: some ALSA apps don't like to be started after alsa_in because they try to initialize the Loopback device ('mplayer -ao alsa' is an example, if you start mplayer like this prior to alsa_in, then it will work as soon as you start alsa_in a little after mplayer). An app like skype is even worse, it will sometimes output garbage, sometimes not.
But apps like smasher, mpg123 (not jackified at all), etc, are playing nicely along.
Anyway, not the most useful trick but in my jack environment, it can be useful