From 16922d1b9e2677a6e30b2428708991ad687631bf Mon Sep 17 00:00:00 2001 From: Storm Dragon Date: Sat, 16 Dec 2023 12:03:49 -0500 Subject: [PATCH] Added mixdown options. --- tojam | 52 ++++++++++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 50 insertions(+), 2 deletions(-) diff --git a/tojam b/tojam index 32d5004..5acd9a4 100755 --- a/tojam +++ b/tojam @@ -104,6 +104,7 @@ configure_ninjam() { while [[ $menuCode -ne 1 ]]; do settings=( "anonymous" "Login in anonymously: ($anonymous)" + "save mixdown" "Save Mixdown: (${saveMixdown})" "save source files" "Save Source Files: (${saveSourceFiles/-nosavesourcefiles/false recommended})" "sound driver" "Sound Driver: (${soundDriver%% *})" "username" "Set User Name: (${userName#*anonymous:})" @@ -126,6 +127,41 @@ configure_ninjam() { sed -i "s/^anonymous=.*/anonymous=\"${anonymous}\"/" "${config}/config" && dialog --msgbox "Anonymous login set to ${anonymous}." -1 -1 ;; + "save mixdown") + saveMixdown="$(dialog --yes-label "disabled" \ + --extra-button \ + --extra-label "ogg" \ + --no-label "wav" \ + --yesno "Select a Mixdown Format" -1 -1 --stdout)" + saveMixdown=$? + [[ ${saveMixdown} -eq 255 ]] && continue + saveMixdown="${saveMixdown/0/disabled}" + saveMixdown="${saveMixdown/1/wav}" + saveMixdown="${saveMixdown/3/ogg}" + if [[ "${saveMixdown}" == "disabled" ]] || [[ "${saveMixdown}" == "wav" ]]; then + sed -i "s/^saveMixdown=.*/saveMixdown=\"${saveMixdown}\"/" "${config}/config" && + dialog --msgbox "Save mixdown: ${saveMixdown}" -1 -1 + continue + fi + local bitrates=( + "64" "64" "off" + "96" "96" "off" + "128" "128" "on" + "160" "160" "off" + "192" "192" "off" + "224" "224" "off" + "256" "256" "off" + ) + oggBitrate="$(dialog --backtitle "Tojam" \ + --no-tags \ + --radiolist "Select Bitrate" -1 -1 -1 "${bitrates[@]}" --stdout)" + menuCode=$? + if [ ${menuCode} -eq 1 -o ${menuCode} -eq 255 ]; then + exit 0 + fi + sed -i -e "s/^saveMixdown=.*/saveMixdown=\"${saveMixdown}\"/" -e "s/^oggBitrate=.*/oggBitrate=\"${oggBitrate}\"/" "${config}/config" && + dialog --msgbox "Save mixdown: ${saveMixdown}" -1 -1 + ;; "sound driver") soundDriver="$(dialog --yes-label "alsa" \ --no-label "jack" \ @@ -190,6 +226,16 @@ configure_ninjam() { exit 0 } +save_files() { + if [[ "${saveMixdown}" == "disabled" ]]; then + return + elif [[ "${saveMixdown}" == "wav" ]]; then + echo "-writewav" + else + echo "-writeogg ${oggBitrate}" + fi +} + # Configuration stuff config="${XDG_CONFIG_HOME:-${HOME}/.config}/tojam" @@ -200,6 +246,8 @@ if ! [[ -r "${config}/config" ]]; then # Write initial config file { echo 'alsaParameters=""'; echo 'anonymous="true"'; + echo 'oggBitrate="128"'; + echo 'saveMixdown="disabled"'; echo 'saveSourceFiles="false"'; echo 'soundDriver="jack"'; echo "userName='Tojam$(date '+%S')'"; } >> "${config}/config" @@ -281,7 +329,7 @@ esac ninjam="$(command -v cninjam 2> /dev/null)" [[ ${#ninjam} -le 3 ]] && { echo "Could not find cninjam."; exit 1; } if [[ "${soundDriver}" == "jack" ]]; then -$ninjam "${server}" -user "${userName}" -jack -sessiondir "${sessiondir}" ${saveSourceFiles} +$ninjam "${server}" -user "${userName}" -jack -sessiondir "${sessiondir}" ${saveSourceFiles} $(save_files) else -$ninjam "${server}" -user "${userName}" -alsaconfig "${alsaParameters}" -sessiondir "${sessiondir}" ${saveSourceFiles} +$ninjam "${server}" -user "${userName}" -alsaconfig "${alsaParameters}" -sessiondir "${sessiondir}" ${saveSourceFiles} $(save_files) fi