/
jack_script.sh
executable file
·96 lines (80 loc) · 2.52 KB
/
jack_script.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
#!/bin/bash
# now setup the audio
if [ -f /etc/rpi-issue ]
then
raspberry=1
export SC_JACK_DEFAULT_INPUTS="system"
export SC_JACK_DEFAULT_OUTPUTS="system"
killall jackd
sleep 5
else
raspberry=0
fi
#pulseaudio --kill
# is the ultra attacked
if aplay -l | grep -qi ultra
then
echo ultra
#adjust amplitude
i=0
j=0
for i in $(seq 8); do
for j in $(seq 8); do
if [ "$i" != "$j" ]; then
amixer -c Ultra set "DIn$i - Out$j" 0% > /dev/null
#amixer -c Ultra set "DIn$i - Out$j" 100% > /dev/null
else
amixer -c Ultra set "DIn$i - Out$j" 100% > /dev/null
fi
amixer -c Ultra set "AIn$i - Out$j" 0% > /dev/null
#amixer -c Ultra set "AIn$i - Out$j" 100% > /dev/null
done
done
#for i in $(seq 4); do
# amixer -c Ultra set "Effects return $i" 0% > /dev/null
#done
#start jack
if [ $raspberry -ne 0 ]
then
( jackd -T -d alsa -d hw:Ultra -r 44100 -i 0 -P || ( killall jackd ; sleep 10 ; jackd -T -d alsa -d hw:Ultra -r 44100 -i 0 -P || sudo shutdown -r now ) ) &
sleep 10
fi
if [ $raspberry -eq 0 ]
then
jackd -d alsa -d hw:Ultra -r 44100 &
fi
else
# are there any other USB devices?
if aplay -l | grep -qi usb
then
# get the device name
device=`aplay -l |grep -i USB | sed -n 1p | awk '{print $3}'`
if [ $raspberry -ne 0 ]
then
( jackd -d alsa -d hw:$device -r 44100 -i 0 -P || ( killall jackd ; sleep 10 ; jackd -d alsa -d hw:$device -r 44100 -i 0 -P || sudo shutdown -r now ) ) &
else
#normal computer
jackd -d alsa -d hw:$device -r 44100 -P &
fi
else
#start jack with default hardware
#jackd -d alsa -d hw:0 -r 44100 &
if [ $raspberry -ne 0 ]
then
#amixer cset numid=3 1
#sleep 1
( jackd -T -p 32 -d alsa -d hw:0,0 -r 44100 -p 1024 -n3 -s -i 0 -P || ( killall jackd ; sleep 10 ; jackd -T -p 32 -d alsa -d hw:0,0 -r 44100 -p 1024 -n3 -s -i 0 -P || sudo shutdown -r now )) &
fi
if [ $raspberry -eq 0 ]
then
jackd -p32 -dalsa -dhw:0,0 -p1024 -n3 -s &
fi
fi
fi
sleep 2
# jack control
if [ $raspberry -eq 0 ]
then
qjackctl &
fi
sleep 1