#!/bin/bash do { #//////////////////////////////////// # DietPi JustBoom # #//////////////////////////////////// # Created by Daniel Knight / daniel.knight@dietpi.com / dietpi.com # #//////////////////////////////////// # # Info: # - Tweak your high-end JustBoom soundcard # Usage: # - /DietPi/dietpi/misc/dietpi-justboom #//////////////////////////////////// #Import DietPi-Globals --------------------------------------------------------------- source /DietPi/dietpi/func/dietpi-globals G_CHECK_ROOT_USER G_CHECK_ROOTFS_RW export G_PROGRAM_NAME='DietPi-Justboom' #Import DietPi-Globals --------------------------------------------------------------- #///////////////////////////////////////////////////////////////////////////////////// #Globals #///////////////////////////////////////////////////////////////////////////////////// setvar EQ_ENABLED = '0' setvar SOUNDCARD_CURRENT = '0' setvar SOUNDCARD_CARD_INDEX = '0' if test -f /etc/asound.conf { setvar SOUNDCARD_CARD_INDEX = $(cat /etc/asound.conf | grep -m1 'card ' | awk '{print $2}') } # - MPD setvar OUTPUT_FREQ_CURRENT = '0' setvar OUTPUT_FREQ_TARGET = '0' setvar OUTPUT_BITRATE_CURRENT = '0' setvar OUTPUT_BITRATE_TARGET = '0' setvar SOXR_ENABLED = '0' setvar SOXR_QUALITY = '0' setvar MPD_AUDIO_BUFFER_SIZE = '0' setvar FP_MPD_CONF = ''/etc/mpd.conf'' setvar MPD_INSTALLED = '0' if test -f $FP_MPD_CONF { setvar MPD_INSTALLED = '1' } # - CAVA setvar CAVA_ENABLED = '1' setvar CAVA_FRAMERATE = '0' setvar CAVA_COLOUR_FG = '0' setvar CAVA_COLOUR_BG = '0' setvar CAVA_BAR_GRAVITY = '0' setvar CAVA_BAR_WIDTH = '0' setvar CAVA_MAINSCREENINUSE_DISPLAYED = '0' setvar FP_CAVA_CONF = ""$HOME/.config/cava/config"" setvar CAVA_INSTALLED = '0' if test -f $FP_CAVA_CONF { setvar CAVA_INSTALLED = '1' } proc Reset_Globals { #ALSA EQ levels rm "$HOME"/.alsaequal.bin &> /dev/null #MPD setvar OUTPUT_FREQ_TARGET = '44100' setvar OUTPUT_BITRATE_TARGET = '16' setvar SOXR_ENABLED = '0' setvar SOXR_QUALITY = ''very high'' setvar EQ_ENABLED = '0' setvar MPD_AUDIO_BUFFER_SIZE = '2048' # - Reset CAVA config cp /DietPi/dietpi/conf/cava.conf "$HOME"/.config/cava/config setvar CAVA_ENABLED = '1' setvar CAVA_FRAMERATE = '30' setvar CAVA_COLOUR_FG = ''green'' setvar CAVA_COLOUR_BG = ''black'' setvar CAVA_BAR_GRAVITY = ''1.75'' setvar CAVA_BAR_WIDTH = '2' # - Save changes Write_Apply_Globals } proc Read_Globals { setvar SOUNDCARD_CURRENT = $(cat /DietPi/dietpi.txt | grep -m1 'CONFIG_SOUNDCARD=' | sed 's/.*=//') setvar EQ_ENABLED = $(cat /etc/asound.conf | grep -ci -m1 '^pcm.plugequal') #MPD specific if (( $MPD_INSTALLED )) { setvar OUTPUT_FREQ_CURRENT = $(cat $FP_MPD_CONF | grep -m1 '^format' | sed 's/\"//g' | sed 's/:/ /g' | awk '{print $2}') setvar OUTPUT_FREQ_TARGET = "$OUTPUT_FREQ_CURRENT" setvar OUTPUT_BITRATE_CURRENT = $(cat $FP_MPD_CONF | grep -m1 '^format' | sed 's/\"//g' | sed 's/:/ /g' | awk '{print $3}') setvar OUTPUT_BITRATE_TARGET = "$OUTPUT_BITRATE_CURRENT" setvar SOXR_ENABLED = $(cat $FP_MPD_CONF | grep -ci -m1 '^samplerate_converter \"soxr') setvar SOXR_QUALITY = $(cat $FP_MPD_CONF | grep -m1 'samplerate_converter \"soxr' | sed 's/\"//g' | awk '{for(i=3;i<=NF;i++){printf "%s ", $i}; printf "\n"}' | sed 's/ *$//') setvar MPD_AUDIO_BUFFER_SIZE = $(cat $FP_MPD_CONF | grep -m1 '^audio_buffer_size' | awk '{print $2}' | sed 's/\"//g') } #CAVA specific if (( $CAVA_INSTALLED )) { setvar CAVA_FRAMERATE = $(cat "$FP_CAVA_CONF" | grep -m1 '^framerate =' | awk '{print $3}') setvar CAVA_COLOUR_BG = $(cat "$FP_CAVA_CONF" | grep -m1 '^background =' | awk '{print $3}') setvar CAVA_COLOUR_FG = $(cat "$FP_CAVA_CONF" | grep -m1 '^foreground =' | awk '{print $3}') setvar CAVA_BAR_GRAVITY = $(cat "$FP_CAVA_CONF" | grep -m1 '^gravity =' | awk '{print $3}') setvar CAVA_BAR_WIDTH = $(cat "$FP_CAVA_CONF" | grep -m1 '^bar_width =' | awk '{print $3}') } } proc Write_Apply_Globals { if (( $EQ_ENABLED )) { /DietPi/dietpi/func/dietpi-set_hardware soundcard "$SOUNDCARD_CURRENT"-eq } else { /DietPi/dietpi/func/dietpi-set_hardware soundcard $SOUNDCARD_CURRENT } #MPD specific if (( $MPD_INSTALLED )) { # - Output freq/bit sed -i "/^format \"/c\format \"$OUTPUT_FREQ_TARGET:$OUTPUT_BITRATE_TARGET:2\"" $FP_MPD_CONF if (( $SOXR_ENABLED )) { sed -i "/samplerate_converter \"/c\samplerate_converter \"soxr $SOXR_QUALITY\"" $FP_MPD_CONF sed -i "/audio_output_format \"/c\audio_output_format \"$OUTPUT_FREQ_TARGET:$OUTPUT_BITRATE_TARGET:2\"" $FP_MPD_CONF } else { sed -i "/samplerate_converter \"/c\#samplerate_converter \"soxr $SOXR_QUALITY\"" $FP_MPD_CONF sed -i "/audio_output_format \"/c\#audio_output_format \"$OUTPUT_FREQ_TARGET:$OUTPUT_BITRATE_TARGET:2\"" $FP_MPD_CONF } # - Buffer sed -i "/^audio_buffer_size \"/c\audio_buffer_size \"$MPD_AUDIO_BUFFER_SIZE\"" $FP_MPD_CONF systemctl restart mpd } #CAVA specific if (( $CAVA_INSTALLED )) { sed -i "/^framerate =/c\framerate = $CAVA_FRAMERATE" $FP_CAVA_CONF sed -i "/^background =/c\background = $CAVA_COLOUR_BG" $FP_CAVA_CONF sed -i "/^foreground =/c\foreground = $CAVA_COLOUR_FG" $FP_CAVA_CONF sed -i "/^gravity =/c\gravity = $CAVA_BAR_GRAVITY" $FP_CAVA_CONF sed -i "/^bar_width =/c\bar_width = $CAVA_BAR_WIDTH" $FP_CAVA_CONF Cava_Start } Read_Globals } proc Cava_Start { killall -w cava &> /dev/null # - Running on current screen if (( $CAVA_ENABLED )) { if test $(tty) = "/dev/tty1" { # - display this warning once only if (( ! $CAVA_MAINSCREENINUSE_DISPLAYED )) { whiptail --title "Main screen in use" --msgbox "To launch CAVA on the main screen, please exit $PROGRAM_NAME and run the following command:\n - cava\n\nNB: Press CTRL+C to exit cava." 12 60 setvar CAVA_MAINSCREENINUSE_DISPLAYED = '1' } } else { setterm -blank 0 -powersave off <> /dev/fb2 >&0 2>&1 #Odroid 3.5 inch cava <> /dev/console >&0 2>&1 & } } } #///////////////////////////////////////////////////////////////////////////////////// # Whip #///////////////////////////////////////////////////////////////////////////////////// setvar PROGRAM_NAME = ""DietPi-JustBoom"" setvar WHIP_QUESTION = '0' setvar WHIP_TITLE = '0' setvar CHOICE = '0' setvar TARGETMENUID = '0' setvar LAST_SELECTED_NAME = '0' proc Menu_Exit { whiptail --title "Exit $PROGRAM_NAME?" --yesno "Exit $PROGRAM_NAME?" --backtitle $PROGRAM_NAME --yes-button "Ok" --no-button "Back" --defaultno 9 55 setvar CHOICE = ""$? if (( $CHOICE == 0 )) { #exit setvar TARGETMENUID = '-1' } else { #Return to Main Menu setvar TARGETMENUID = '0' } } #TARGETMENUID=0 proc Menu_Main { Read_Globals local eq_enabled_text='Disabled' if (( $EQ_ENABLED )) { setvar eq_enabled_text = ''Enabled'' } local soxr_enabled_text='Disabled' if (( $SOXR_ENABLED )) { setvar soxr_enabled_text = ''Enabled'' } local whiptail_menu_array=() setvar whiptail_menu_array = ''("" "──── Global Options ──────────────────────────") setvar whiptail_menu_array = ''("ALSA Mixer" ": Launches ALSA Mixer, tweak sound card settings") setvar whiptail_menu_array = ''("ALSA Output Info" ": View info on current ALSA playback stream") setvar whiptail_menu_array = ''("EQ Enable" ": $eq_enabled_text | Select to toggle EQ") if (( $EQ_ENABLED )) { setvar whiptail_menu_array = ''("EQ Configure" ": Launches AlsaMixer to configure EQ settings") } setvar whiptail_menu_array = ''("Reset" ": Reset all options to defaults") #Allo Piano 2.1 specials if (( $(echo -e "$SOUNDCARD_CURRENT" | grep -ci -m1 'piano-dac-plus') )) { setvar whiptail_menu_array = ''("" "──── Allo Piano 2.1 ──────────────────────────") local dsp_filter=$(amixer -c $SOUNDCARD_CARD_INDEX sget "'DSP Program'" | grep 'Item0:' | sed 's/.*Item0: //') setvar whiptail_menu_array = ''("DSP Filter" ": $dsp_filter") local digital_volume_int=$(amixer -c $SOUNDCARD_CARD_INDEX sget "'Digital'" | grep 'Front Left:' | awk '{print $4}') local digital_volume_db=$(amixer -c $SOUNDCARD_CARD_INDEX sget "'Digital'" | grep 'Front Left:' | awk '{print $6}' | tr -d '\[\]') local subwoofer_mode=$(amixer -c $SOUNDCARD_CARD_INDEX sget "'Subwoofer mode'" | grep 'Item0:' | sed 's/.*Item0: //') local subwoofer_volume_int=$(amixer -c $SOUNDCARD_CARD_INDEX sget "'Subwoofer'" | grep 'Front Left:' | awk '{print $4}') local subwoofer_volume_db=$(amixer -c $SOUNDCARD_CARD_INDEX sget "'Subwoofer'" | grep 'Front Left:' | awk '{print $6}' | tr -d '\[\]') local subwoofer_crossover_frequency=$(amixer -c $SOUNDCARD_CARD_INDEX sget "'Lowpass'" | grep 'Item0:' | sed 's/.*Item0: //') local dualoutput_mode=$(amixer -c $SOUNDCARD_CARD_INDEX sget "'Dual Mode'" | grep 'Item0:' | sed 's/.*Item0: //') setvar whiptail_menu_array = ''("Master Volume" ": $digital_volume_int ($digital_volume_db)") setvar whiptail_menu_array = ''("Dual Output Mode" ": $dualoutput_mode") setvar whiptail_menu_array = ''("Subwoofer Mode" ": $subwoofer_mode") setvar whiptail_menu_array = ''("Subwoofer Volume" ": $subwoofer_volume_int ($subwoofer_volume_db)") # - only active with subwoofer 2.1+ modes if test $subwoofer_mode != '2.0' { setvar whiptail_menu_array = ''("Subwoofer Crossover" ": $subwoofer_crossover_frequency Hz") } } #MPD specific if (( $MPD_INSTALLED )) { setvar whiptail_menu_array = ''("" "──── MPD Specific ────────────────────────────") setvar whiptail_menu_array = ''("Output Frequency" ": $OUTPUT_FREQ_CURRENT Hz | Select to change") setvar whiptail_menu_array = ''("Output BitRate" ": $OUTPUT_BITRATE_CURRENT Bit | Select to change") setvar whiptail_menu_array = ''("Audio Buffer" ": $MPD_AUDIO_BUFFER_SIZE Bytes | Select to change") setvar whiptail_menu_array = ''("SOXR Enable" ": $soxr_enabled_text | Select to toggle SOXR resampling") if (( $SOXR_ENABLED )) { setvar whiptail_menu_array = ''("SOXR Quality" ": $SOXR_QUALITY | Select SOXR quality level") } } #CAVA specific if (( $CAVA_INSTALLED )) { setvar whiptail_menu_array = ''("" "──── CAVA Specific ───────────────────────────") setvar whiptail_menu_array = ''("Cava Start/Restart" ": Launch Cava on main screen") if (( $(ps aux | grep -ci -m1 '[c]ava') )) { setvar whiptail_menu_array = ''("Cava Stop" ": Stop Cava") } setvar whiptail_menu_array = ''("Cava Framerate" ": $CAVA_FRAMERATE fps | Select to change") setvar whiptail_menu_array = ''("Cava FG Colour" ": $CAVA_COLOUR_FG | Select to change") setvar whiptail_menu_array = ''("Cava BG Colour" ": $CAVA_COLOUR_BG | Select to change") setvar whiptail_menu_array = ''("Cava Bar Width" ": $CAVA_BAR_WIDTH | Select to change") setvar whiptail_menu_array = ''("Cava Bar Gravity" ": $CAVA_BAR_GRAVITY | Select to change") } setvar WHIP_QUESTION = ''Tweak your High-End Audiophile JustBoom (and others) sound card:'' setvar OPTION = $(whiptail --title "$PROGRAM_NAME" --backtitle "$PROGRAM_NAME" --menu "$WHIP_QUESTION" --cancel-button "Exit" --default-item "$LAST_SELECTED_NAME" 20 75 12 "${whiptail_menu_array[@]}" 3>&1 1>&2 2>&3) setvar CHOICE = ""$? unset whiptail_menu_array if (( $CHOICE == 0 )) { setvar LAST_SELECTED_NAME = "$OPTION" if test $OPTION = "ALSA Output Info" { G_DIETPI-NOTIFY 3 DietPi-JustBoom "ALSA Output Info" local stream_result=$(cat /proc/asound/card*/pcm0p/sub0/hw_params) echo -e $stream_result echo -e "" if test $stream_result = "closed" { G_DIETPI-NOTIFY 1 "Detailed info is only available when audio is being played, play some music first!" } G_DIETPI-NOTIFY 0 "Completed, press any key to exit...\n" read -p "Press any key to exit..." } elif test $OPTION = "Subwoofer Mode" { local whiptail_menu_array=() setvar whiptail_menu_array = ''('2.0' ': Disables Subwoofer output') setvar whiptail_menu_array = ''('2.1' ': Enables Subwoofer output (mono)') setvar whiptail_menu_array = ''('2.2' ': Enables Subwoofer output (stereo)') setvar WHIP_QUESTION = ''Please select a channel mode for Subwoofer output:'' setvar OPTION = $(whiptail --title "$PROGRAM_NAME" --backtitle "$PROGRAM_NAME" --menu "$WHIP_QUESTION" --cancel-button "Exit" --default-item "$subwoofer_mode" 13 65 3 "${whiptail_menu_array[@]}" 3>&1 1>&2 2>&3) setvar CHOICE = ""$? unset whiptail_menu_array if (( $CHOICE == 0 )) { amixer -c $SOUNDCARD_CARD_INDEX sset 'Subwoofer mode' $OPTION } } elif test $OPTION = "Dual Output Mode" { local whiptail_menu_array=() setvar whiptail_menu_array = ''('Dual-Mono' ': Enables Dual output (mono)') setvar whiptail_menu_array = ''('Dual-Stereo' ': Enables Dual output (stereo)') setvar WHIP_QUESTION = ''Please select a channel mode for Subwoofer output:'' setvar OPTION = $(whiptail --title "$PROGRAM_NAME" --backtitle "$PROGRAM_NAME" --menu "$WHIP_QUESTION" --cancel-button "Exit" --default-item "$dualoutput_mode" 13 65 3 "${whiptail_menu_array[@]}" 3>&1 1>&2 2>&3) setvar CHOICE = ""$? unset whiptail_menu_array if (( $CHOICE == 0 )) { amixer -c $SOUNDCARD_CARD_INDEX sset 'Dual Mode' $OPTION } } elif test $OPTION = "Master Volume" { local whiptail_menu_array=() for ((i=206; i>=0; i--)) do if (( $i == 0 )); then whiptail_menu_array+=("$i" 'Mute') elif (( $i == 206 )); then whiptail_menu_array+=("$i" ': Max (-0.50dB)') else whiptail_menu_array+=("$i" '') fi done setvar WHIP_QUESTION = ''Please select a volume level for Master output:'' setvar OPTION = $(whiptail --title "$PROGRAM_NAME" --backtitle "$PROGRAM_NAME" --menu "$WHIP_QUESTION" --cancel-button "Exit" --default-item "$digital_volume_int" 17 65 9 "${whiptail_menu_array[@]}" 3>&1 1>&2 2>&3) setvar CHOICE = ""$? unset whiptail_menu_array if (( $CHOICE == 0 )) { amixer -c $SOUNDCARD_CARD_INDEX sset 'Digital' ''$OPTION'' } } elif test $OPTION = "Subwoofer Volume" { local whiptail_menu_array=() for ((i=206; i>=0; i--)) do if (( $i == 0 )); then whiptail_menu_array+=("$i" 'Mute') elif (( $i == 206 )); then whiptail_menu_array+=("$i" ': Max (-0.50dB)') else whiptail_menu_array+=("$i" '') fi done setvar WHIP_QUESTION = ''Please select a volume level for Subwoofer output:'' setvar OPTION = $(whiptail --title "$PROGRAM_NAME" --backtitle "$PROGRAM_NAME" --menu "$WHIP_QUESTION" --cancel-button "Exit" --default-item "$subwoofer_volume_int" 17 65 9 "${whiptail_menu_array[@]}" 3>&1 1>&2 2>&3) setvar CHOICE = ""$? unset whiptail_menu_array if (( $CHOICE == 0 )) { amixer -c $SOUNDCARD_CARD_INDEX sset 'Subwoofer' ''$OPTION'' } } elif test $OPTION = "Subwoofer Crossover" { local whiptail_menu_array=() setvar whiptail_menu_array = ''('60' 'Hz') setvar whiptail_menu_array = ''('70' 'Hz') setvar whiptail_menu_array = ''('80' 'Hz') setvar whiptail_menu_array = ''('90' 'Hz (Default)') setvar whiptail_menu_array = ''('100' 'Hz') setvar whiptail_menu_array = ''('110' 'Hz') setvar whiptail_menu_array = ''('120' 'Hz') setvar whiptail_menu_array = ''('130' 'Hz') setvar whiptail_menu_array = ''('140' 'Hz') setvar whiptail_menu_array = ''('150' 'Hz') setvar whiptail_menu_array = ''('160' 'Hz') setvar whiptail_menu_array = ''('170' 'Hz') setvar whiptail_menu_array = ''('180' 'Hz') setvar whiptail_menu_array = ''('190' 'Hz') setvar whiptail_menu_array = ''('200' 'Hz') setvar WHIP_QUESTION = ''Please select the lowpass crossover frequency for Subwoofer:\n\nEverything below the selected freq will be output through subwoofer out, when subwoofer mode 2.1/2.2 is selected.'' setvar OPTION = $(whiptail --title "$PROGRAM_NAME" --backtitle "$PROGRAM_NAME" --menu "$WHIP_QUESTION" --cancel-button "Exit" --default-item "$subwoofer_crossover_frequency" 19 65 8 "${whiptail_menu_array[@]}" 3>&1 1>&2 2>&3) setvar CHOICE = ""$? unset whiptail_menu_array if (( $CHOICE == 0 )) { amixer -c $SOUNDCARD_CARD_INDEX sset 'Lowpass' $OPTION } } elif test $OPTION = "DSP Filter" { local whiptail_menu_array=() setvar whiptail_menu_array = ''('FIR interpolation with de-emphasis' '(Default)') setvar whiptail_menu_array = ''('Low latency IIR with de-emphasis' '') setvar whiptail_menu_array = ''('High attenuation with de-emphasis' '') setvar whiptail_menu_array = ''('Fixed process flow' '') setvar whiptail_menu_array = ''('Ringing-less low latency FIR' '') setvar WHIP_QUESTION = ''Please select a DSP Filter:'' setvar OPTION = $(whiptail --title "$PROGRAM_NAME" --backtitle "$PROGRAM_NAME" --menu "$WHIP_QUESTION" --cancel-button "Exit" --default-item "$dsp_filter" 14 65 5 "${whiptail_menu_array[@]}" 3>&1 1>&2 2>&3) setvar CHOICE = ""$? unset whiptail_menu_array if (( $CHOICE == 0 )) { amixer -c $SOUNDCARD_CARD_INDEX sset 'DSP Program' $OPTION } } elif test $OPTION = "Cava Start/Restart" { Cava_Start } elif test $OPTION = "Cava Stop" { killall -w cava } elif test $OPTION = "Cava Framerate" { local whiptail_menu_array=() setvar whiptail_menu_array = ''("10" ": Lowest CPU usage") setvar whiptail_menu_array = ''("20" "") setvar whiptail_menu_array = ''("30" ": Default") setvar whiptail_menu_array = ''("40" "") setvar whiptail_menu_array = ''("50" "") setvar whiptail_menu_array = ''("60" "") setvar whiptail_menu_array = ''("80" "") setvar whiptail_menu_array = ''("100" "") setvar whiptail_menu_array = ''("120" ": Highest CPU usage") setvar WHIP_QUESTION = ''Please select a framerate:'' setvar OPTION = $(whiptail --title "$PROGRAM_NAME" --backtitle "$PROGRAM_NAME" --menu "$WHIP_QUESTION" --cancel-button "Exit" --default-item "$CAVA_FRAMERATE" 17 65 8 "${whiptail_menu_array[@]}" 3>&1 1>&2 2>&3) setvar CHOICE = ""$? unset whiptail_menu_array if (( $CHOICE == 0 )) { setvar CAVA_FRAMERATE = "$OPTION" Write_Apply_Globals } } elif test $OPTION = "Cava Bar Width" { local whiptail_menu_array=() setvar whiptail_menu_array = ''("1" ": Thin (Increases total bar count)") setvar whiptail_menu_array = ''("2" ": Default") setvar whiptail_menu_array = ''("3" "") setvar whiptail_menu_array = ''("4" "") setvar whiptail_menu_array = ''("5" "") setvar whiptail_menu_array = ''("6" "") setvar whiptail_menu_array = ''("8" ": Thick (Lowers total bar count)") setvar WHIP_QUESTION = ''Please select a bar width:\n - The size of the bars affects how many are displayed'' setvar OPTION = $(whiptail --title "$PROGRAM_NAME" --backtitle "$PROGRAM_NAME" --menu "$WHIP_QUESTION" --cancel-button "Exit" --default-item "$CAVA_BAR_WIDTH" 17 65 8 "${whiptail_menu_array[@]}" 3>&1 1>&2 2>&3) setvar CHOICE = ""$? unset whiptail_menu_array if (( $CHOICE == 0 )) { setvar CAVA_BAR_WIDTH = "$OPTION" Write_Apply_Globals } } elif test $OPTION = "Cava FG Colour" || test $OPTION = "Cava BG Colour" { local apply_fg_colour=0 local default_item="$CAVA_COLOUR_BG" if test $OPTION = "Cava FG Colour" { setvar apply_fg_colour = '1' setvar default_item = "$CAVA_COLOUR_FG" } local whiptail_menu_array=() setvar whiptail_menu_array = ''("green" "") setvar whiptail_menu_array = ''("red" "") setvar whiptail_menu_array = ''("yellow" "") setvar whiptail_menu_array = ''("magenta" "") setvar whiptail_menu_array = ''("cyan" "") setvar whiptail_menu_array = ''("white" "") setvar whiptail_menu_array = ''("blue" "") setvar whiptail_menu_array = ''("black" "") setvar WHIP_QUESTION = ''Please select a colour:'' setvar OPTION = $(whiptail --title "$PROGRAM_NAME" --backtitle "$PROGRAM_NAME" --menu "$WHIP_QUESTION" --cancel-button "Exit" --default-item "$default_item" 17 65 8 "${whiptail_menu_array[@]}" 3>&1 1>&2 2>&3) setvar CHOICE = ""$? unset whiptail_menu_array if (( $CHOICE == 0 )) { if (( $apply_fg_colour )) { setvar CAVA_COLOUR_FG = "$OPTION" } else { setvar CAVA_COLOUR_BG = "$OPTION" } Write_Apply_Globals } } elif test $OPTION = "Cava Bar Gravity" { local whiptail_menu_array=() setvar whiptail_menu_array = ''("0.1" ": Slow drop off speed") setvar whiptail_menu_array = ''("0.25" "") setvar whiptail_menu_array = ''("0.5" "") setvar whiptail_menu_array = ''("0.75" "") setvar whiptail_menu_array = ''("1" "") setvar whiptail_menu_array = ''("1.25" "") setvar whiptail_menu_array = ''("1.5" "") setvar whiptail_menu_array = ''("1.75" ": Default") setvar whiptail_menu_array = ''("2" ": High drop off speed") setvar WHIP_QUESTION = ''Please select a gravity level (drop off speed) for the bars:\n - Higher values means bars will drop faster.'' setvar OPTION = $(whiptail --title "$PROGRAM_NAME" --backtitle "$PROGRAM_NAME" --menu "$WHIP_QUESTION" --cancel-button "Exit" --default-item "$CAVA_BAR_GRAVITY" 17 65 8 "${whiptail_menu_array[@]}" 3>&1 1>&2 2>&3) setvar CHOICE = ""$? unset whiptail_menu_array if (( $CHOICE == 0 )) { setvar CAVA_BAR_GRAVITY = "$OPTION" Write_Apply_Globals } } elif test $OPTION = "EQ Configure" { if (( $EQ_ENABLED == 1 )) { whiptail --title "ALSA EQ" --msgbox "The ALSA EQ mixer will now be launched, when finished, press F10 or ESC to exit." 8 60 alsamixer -D eq } } elif test $OPTION = "ALSA Mixer" { whiptail --title "ALSA Mixer" --msgbox "ALSA Mixer will now be launched, when finished, press F10 or ESC to exit." 8 60 alsamixer } elif test $OPTION = "EQ Enable" { ((EQ_ENABLED++)) if (( $EQ_ENABLED > 1 )) { setvar EQ_ENABLED = '0' } Write_Apply_Globals } elif test $OPTION = "SOXR Enable" { ((SOXR_ENABLED++)) if (( $SOXR_ENABLED > 1 )) { setvar SOXR_ENABLED = '0' } Write_Apply_Globals } elif test $OPTION = "SOXR Quality" { local whiptail_menu_array=() setvar whiptail_menu_array = ''("very high" ": Highest quality, highest CPU usage") setvar whiptail_menu_array = ''("high" ": Default quality, medium CPU usage") setvar whiptail_menu_array = ''("low" ": Lowest quality, minimal CPU usage") setvar WHIP_QUESTION = ''Select a SOXR Quality level:'' setvar OPTION = $(whiptail --title "$PROGRAM_NAME" --backtitle "$PROGRAM_NAME" --menu "$WHIP_QUESTION" --cancel-button "Exit" --default-item "$SOXR_QUALITY" 11 70 3 "${whiptail_menu_array[@]}" 3>&1 1>&2 2>&3) setvar CHOICE = ""$? unset whiptail_menu_array if (( $CHOICE == 0 )) { setvar SOXR_QUALITY = "$OPTION" Write_Apply_Globals } } elif test $OPTION = "Audio Buffer" { local whiptail_menu_array=() setvar whiptail_menu_array = ''("128" ": Lowest latency (may cause buffer under/overruns)") setvar whiptail_menu_array = ''("192" ":") setvar whiptail_menu_array = ''("256" ":") setvar whiptail_menu_array = ''("384" ":") setvar whiptail_menu_array = ''("512" ":") setvar whiptail_menu_array = ''("1024" ":") setvar whiptail_menu_array = ''("2048" ": Default") setvar whiptail_menu_array = ''("4096" ": Highest latency") setvar WHIP_QUESTION = ''Select an Audio buffer size (bytes):'' setvar OPTION = $(whiptail --title "$PROGRAM_NAME" --backtitle "$PROGRAM_NAME" --menu "$WHIP_QUESTION" --cancel-button "Exit" --default-item "$MPD_AUDIO_BUFFER_SIZE" 16 70 8 "${whiptail_menu_array[@]}" 3>&1 1>&2 2>&3) setvar CHOICE = ""$? unset whiptail_menu_array if (( $CHOICE == 0 )) { setvar MPD_AUDIO_BUFFER_SIZE = "$OPTION" Write_Apply_Globals } } elif test $OPTION = "Output Frequency" { local whiptail_menu_array=() setvar whiptail_menu_array = ''("384000" ": 384kHz (highest quality)") setvar whiptail_menu_array = ''("352800" ": 352kHz") setvar whiptail_menu_array = ''("192000" ": 192kHz") setvar whiptail_menu_array = ''("96000" ": 96kHz") setvar whiptail_menu_array = ''("88200" ": 88.2kHz") setvar whiptail_menu_array = ''("64000" ": 64kHz") setvar whiptail_menu_array = ''("48000" ": 48kHz (HDMI standard)") setvar whiptail_menu_array = ''("44100" ": 44.1kHz (music standard)") setvar WHIP_QUESTION = ''Select an Output Frequency:'' setvar OPTION = $(whiptail --title "$PROGRAM_NAME" --backtitle "$PROGRAM_NAME" --menu "$WHIP_QUESTION" --cancel-button "Exit" --default-item "$OUTPUT_FREQ_CURRENT" 16 70 8 "${whiptail_menu_array[@]}" 3>&1 1>&2 2>&3) setvar CHOICE = ""$? unset whiptail_menu_array if (( $CHOICE == 0 )) { setvar OUTPUT_FREQ_TARGET = "$OPTION" Write_Apply_Globals } } elif test $OPTION = "Output BitRate" { local whiptail_menu_array=() setvar whiptail_menu_array = ''("32" ": (highest quality, recommended)") setvar whiptail_menu_array = ''("24" ": ") setvar whiptail_menu_array = ''("16" ": (CD audio quality)") setvar WHIP_QUESTION = ''Select an Output BitRate:'' setvar OPTION = $(whiptail --title "$PROGRAM_NAME" --backtitle "$PROGRAM_NAME" --menu "$WHIP_QUESTION" --cancel-button "Exit" --default-item "$OUTPUT_BITRATE_CURRENT" 11 70 3 "${whiptail_menu_array[@]}" 3>&1 1>&2 2>&3) setvar CHOICE = ""$? unset whiptail_menu_array if (( $CHOICE == 0 )) { setvar OUTPUT_BITRATE_TARGET = "$OPTION" Write_Apply_Globals } } elif test $OPTION = "Reset" { Reset_Globals } } else { Menu_Exit } } #///////////////////////////////////////////////////////////////////////////////////// # Main Loop #///////////////////////////////////////////////////////////////////////////////////// #----------------------------------------------------------------------------------- Read_Globals #----------------------------------------------------------------------------------- while (( $TARGETMENUID >= 0 )) { if (( $TARGETMENUID == 0 )) { Menu_Main } } #----------------------------------------------------------------------------------- exit #----------------------------------------------------------------------------------- }