As you mentioned, the device number for your audio card will change between runs. You’ll definitely want to make sure to choose the correct device in QJackCtrl. aplay -l
should list the available devices in a way that will let you handle them through script.
To answer your second question, there are PulseAudio modules that enable you to use Jack as the handler for Pulse sound. Take a look at pulseaudio-module-jack
for Ubuntu/Debian (it may be available for your distro; this only mentions how to do it on Debian-based systems, and as I run Ubuntu I can’t immediately check on anything else). In my case, I needed to choose it in the Ubuntu Sound Settings as well for it to work (as far as I can tell). You might also take a look at http://jackaudio.org/pulseaudio_and_jack for more on using Pulse and Jack together.
Also, a free bonus snippet of messy Bash script:
get_alsa_device ()
{
# USAGE:
# In Bash:
# var="$(get_alsa_device "card_name" "device_name")"
# DESCRIPTION:
# Parses aplay's output to find the device specified by card and device
# ARGUMENTS:
# card_name The name of the card to be found
# device_name The name of the device to be found
# STDOUT:
# Writes the proper alsa device name (in hd0,0 style) to stdout
# RETURN VALUE:
# 0 Succeeded in generating output value
# 1 Failed to generate output value
aplay --list-devices | grep --fixed-strings "$1" | grep --fixed-strings --max-count 1 "$2" | sed -r 's/^card ([0-9]{1,}): .*, device ([0-9]{1,}): .*$/hw:\1,\2/; T die; q 0; :die; Q 1'
}
That’s from a tool I wrote that could automatically configure Jack to run with whatever card the user desired. This function just finds an ALSA device matching the provided names and returns its name in Jack style (I’m pretty sure…).
solved Jack as primary audio driver? [closed]