From e034c518ee3c31b51ded6d62d0dc98988603b9ab Mon Sep 17 00:00:00 2001 From: Storm Dragon Date: Sat, 16 Dec 2023 00:07:56 -0500 Subject: [PATCH] Fixed a bug with connecting with alsa. --- tojam | 22 ++++++++++++++-------- 1 file changed, 14 insertions(+), 8 deletions(-) diff --git a/tojam b/tojam index d220fd3..f92a8da 100755 --- a/tojam +++ b/tojam @@ -147,7 +147,7 @@ configure_ninjam() { --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 + if [ ${menuCode} -eq 1 -o ${menuCode} -eq 255 ]; then continue fi soundDriver="$(dialog --backtitle "Tojam" --title "Alsa Configuration" \ @@ -159,7 +159,7 @@ configure_ninjam() { "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 + if [ ${menuCode} -eq 1 -o ${menuCode} -eq 255 ]; then continue fi mapfile -t alsaParameters < <(echo "${soundDriver}") @@ -168,10 +168,11 @@ configure_ninjam() { 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" && + alsaParameters[5]="in hw:${alsaParameters[5]}" + alsaParameters[6]="out hw:${alsaParameters[6]}" + soundDriver="alsa" + alsaParameters="${alsaParameters[*]}" + sed -i -e "s/^soundDriver=.*/soundDriver=\"${soundDriver}\"/" -e "s/^alsaParameters=.*/alsaParameters=\"${alsaParameters}\"/" "${config}/config" && dialog --msgbox "Sound driver set to alsa." -1 -1 ;; "username") @@ -195,7 +196,8 @@ mkdir -p "${config}" if ! [[ -r "${config}/config" ]]; then # Write initial config file - { echo 'anonymous="true"'; + { echo 'alsaParameters=""'; + echo 'anonymous="true"'; echo 'saveSourceFiles="false"'; echo 'soundDriver="jack"'; echo "userName='Tojam$(date '+%S')'"; } >> "${config}/config" @@ -276,4 +278,8 @@ esac ninjam="$(command -v cninjam 2> /dev/null)" [[ ${#ninjam} -le 3 ]] && { echo "Could not find cninjam."; exit 1; } -$ninjam "${server}" -user "${userName}" -${soundDriver} -sessiondir "${sessiondir}" ${saveSourceFiles} +if [[ "${soundDriver}" == "jack" ]]; then +$ninjam "${server}" -user "${userName}" -jack -sessiondir "${sessiondir}" ${saveSourceFiles} +else +$ninjam "${server}" -user "${userName}" -alsaconfig "${alsaParameters}" -sessiondir "${sessiondir}" ${saveSourceFiles} +fi