2023-04-26 09:23:56 +02:00
|
|
|
#!/usr/bin/env bash
|
|
|
|
|
2019-10-24 02:20:38 +02:00
|
|
|
set -e
|
|
|
|
|
|
|
|
defaultDevice=PCH
|
|
|
|
|
2023-04-26 09:23:56 +02:00
|
|
|
start_jack() {
|
2019-10-24 02:20:38 +02:00
|
|
|
|
|
|
|
internal_device_number=-1
|
|
|
|
komplete_device_number=$(aplay -l | grep Vestax | cut -d":" -f1 | cut -d" " -f2)
|
|
|
|
babyface_device_number=$(aplay -l | grep Babyface | cut -d":" -f1 | cut -d" " -f2)
|
|
|
|
cmedia_device_number=$(aplay -l | grep C-Media | cut -d":" -f1 | cut -d" " -f2)
|
|
|
|
h2n_device_number=$(aplay -l | grep H2n | cut -d":" -f1 | cut -d" " -f2)
|
|
|
|
|
|
|
|
# this should be more readable some day
|
|
|
|
if [[ $babyface_device_number == "" ]]; then
|
|
|
|
if [[ $komplete_device_number == "" ]]; then
|
|
|
|
if [[ $cmedia_device_number == "" ]]; then
|
|
|
|
if [[ $h2n_device_number == "" ]]; then
|
|
|
|
echo "use : default device"
|
|
|
|
device_number=$internal_device_number
|
|
|
|
else
|
|
|
|
echo "use : h2n"
|
|
|
|
device_number=$h2n_device_number
|
|
|
|
fi
|
|
|
|
else
|
|
|
|
echo "use : c-media"
|
|
|
|
device_number=$cmedia_device_number
|
|
|
|
fi
|
|
|
|
else
|
|
|
|
echo "use : komplete"
|
|
|
|
device_number=$komplete_device_number
|
|
|
|
fi
|
|
|
|
else
|
|
|
|
echo "use : babyface"
|
|
|
|
device_number=$babyface_device_number
|
|
|
|
fi
|
|
|
|
|
|
|
|
# device parameter configuration
|
|
|
|
# ==============================
|
|
|
|
#
|
|
|
|
# to find configuration options do
|
|
|
|
# jack_control dp
|
2023-04-26 09:23:56 +02:00
|
|
|
if [[ $device_number -eq -1 ]]; then
|
2019-10-24 02:20:38 +02:00
|
|
|
# we use alsa in reality, but pulse opens up all the pulse
|
|
|
|
# sink and source stuff
|
|
|
|
# jack_control ds pulse # not working for some reason
|
|
|
|
jack_control ds alsa
|
|
|
|
jack_control dps device hw:$defaultDevice
|
|
|
|
else
|
2023-04-26 09:23:56 +02:00
|
|
|
jack_control ds alsa
|
|
|
|
jack_control dps device "hw:$device_number" # use usb card
|
2019-10-24 02:20:38 +02:00
|
|
|
fi
|
|
|
|
|
2023-04-26 09:23:56 +02:00
|
|
|
jack_control dps duplex True # record and playback ports
|
|
|
|
jack_control dps hwmon False # no hardware monitoring
|
|
|
|
jack_control dps rate 48000 # use cd sample rate
|
2019-10-24 02:20:38 +02:00
|
|
|
|
|
|
|
# nperiods are the splitup of the
|
|
|
|
# sound-ring-buffer. 2 are ok for internal cards
|
|
|
|
# but for usb you should use 3 because
|
|
|
|
# you can have to write in junks to the card
|
|
|
|
# so there is one backup slice in the middle
|
2023-04-26 09:23:56 +02:00
|
|
|
if [[ $internal_device_number -ne -1 ]]; then
|
2019-10-24 02:20:38 +02:00
|
|
|
jack_control dps nperiods 3
|
|
|
|
fi
|
|
|
|
|
|
|
|
# engine parameter configuration
|
|
|
|
# ==============================
|
|
|
|
#
|
|
|
|
# to find configuration options do
|
|
|
|
# jack_control ep
|
|
|
|
jack_control eps sync True
|
|
|
|
|
|
|
|
# realtime kernel
|
|
|
|
# set True for using a realtime kernel
|
|
|
|
jack_control eps realtime False
|
|
|
|
# set priority if realtime kernel is set True
|
|
|
|
# jack_control eps realtime-priority 10
|
|
|
|
|
|
|
|
jack_control start
|
|
|
|
}
|
|
|
|
|
2023-04-26 09:23:56 +02:00
|
|
|
stop_jack() {
|
2019-10-24 02:20:38 +02:00
|
|
|
jack_control exit
|
|
|
|
}
|
|
|
|
|
|
|
|
status_jack() {
|
|
|
|
jack_control dp
|
|
|
|
jack_control ep
|
|
|
|
jack_control status
|
|
|
|
}
|
|
|
|
|
|
|
|
case $1 in
|
2023-04-26 09:23:56 +02:00
|
|
|
start)
|
|
|
|
start_jack
|
|
|
|
;;
|
|
|
|
stop)
|
|
|
|
stop_jack
|
|
|
|
;;
|
|
|
|
restart)
|
|
|
|
stop_jack
|
|
|
|
start_jack
|
|
|
|
;;
|
|
|
|
*)
|
|
|
|
status_jack
|
|
|
|
;;
|
2019-10-24 02:20:38 +02:00
|
|
|
esac
|