Alsa configuration added to settings.

This commit is contained in:
Storm Dragon 2023-12-15 23:39:48 -05:00
parent 109a08225b
commit 11e4a4d183

35
tojam
View File

@ -138,6 +138,41 @@ configure_ninjam() {
dialog --msgbox "Sound driver set to jack." -1 -1
continue
fi
mapfile -t cardList < <(aplay -l | grep -E '^card [0-9]+: [[:alnum:]]+ \[' | cut -f1 -d '[' | uniq)
declare -a soundcards
for i in "${cardList[@]}" ; do
soundcards+=("${i##*: }" "${i}")
done
soundcard="$(dialog --backtitle "Tojam" \
--no-tags \
--menu "Select the sound card Ninjam should use" -1 -1 -1 "${soundcards[@]}" --stdout)"
menuCode=$?
if [ ${menuCode} -eq 1 -o ${menuCode} -eq 255]; then
continue
fi
soundDriver="$(dialog --backtitle "Tojam" --title "Alsa Configuration" \
--form "\nEnter alsa parameters:\n\nUse up and down to move between fields, enter to accept, or escape to cancel.\nSane defaults are used, but if it doesn't work, you will need to consult the documentation for your sound card." 25 60 16 \
"nblock:" 1 1 "16" 1 25 25 50 \
"bsize:" 2 1 "256" 2 25 25 50 \
"bps:" 4 1 "16" 4 25 6 6 \
"srate:" 5 1 "48000" 5 25 6 6 \
"nch:" 6 1 "2" 6 25 6 6 \
"in:" 7 1 "${soundcard}" 7 25 25 25 \
"out:" 8 1 "${soundcard}" 8 25 25 25 --stdout)"
if [ ${menuCode} -eq 1 -o ${menuCode} -eq 255]; then
continue
fi
mapfile -t alsaParameters < <(echo "${soundDriver}")
alsaParameters[0]="nblock ${alsaParameters[0]}"
alsaParameters[1]="bsize ${alsaParameters[1]}"
alsaParameters[2]="bps ${alsaParameters[2]}"
alsaParameters[3]="srate ${alsaParameters[3]}"
alsaParameters[4]="nch ${alsaParameters[4]}"
alsaParameters[5]="in ${alsaParameters[5]}"
alsaParameters[6]="out ${alsaParameters[6]}"
soundDriver="alsaconfig '${alsaParameters[*]}'"
sed -i "s/^soundDriver=.*/soundDriver=\"${soundDriver}\"/" "${config}/config" &&
dialog --msgbox "Sound driver set to alsa." -1 -1
;;
"username")
userName="$(dialog --backtitle "Tojam" \