#!/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 #///////////////////////////////////////////////////////////////////////////////////// setglobal EQ_ENABLED = '0' setglobal SOUNDCARD_CURRENT = '0' setglobal SOUNDCARD_CARD_INDEX = '0' if test -f /etc/asound.conf { setglobal SOUNDCARD_CARD_INDEX = $[cat /etc/asound.conf | grep -m1 'card ' | awk '{print $2}] } # - MPD setglobal OUTPUT_FREQ_CURRENT = '0' setglobal OUTPUT_FREQ_TARGET = '0' setglobal OUTPUT_BITRATE_CURRENT = '0' setglobal OUTPUT_BITRATE_TARGET = '0' setglobal SOXR_ENABLED = '0' setglobal SOXR_QUALITY = '0' setglobal MPD_AUDIO_BUFFER_SIZE = '0' setglobal FP_MPD_CONF = ''/etc/mpd.conf'' setglobal MPD_INSTALLED = '0' if test -f $FP_MPD_CONF { setglobal MPD_INSTALLED = '1' } # - CAVA setglobal CAVA_ENABLED = '1' setglobal CAVA_FRAMERATE = '0' setglobal CAVA_COLOUR_FG = '0' setglobal CAVA_COLOUR_BG = '0' setglobal CAVA_BAR_GRAVITY = '0' setglobal CAVA_BAR_WIDTH = '0' setglobal CAVA_MAINSCREENINUSE_DISPLAYED = '0' setglobal FP_CAVA_CONF = ""$HOME/.config/cava/config"" setglobal CAVA_INSTALLED = '0' if test -f $FP_CAVA_CONF { setglobal CAVA_INSTALLED = '1' } proc Reset_Globals{ #ALSA EQ levels rm "$HOME"/.alsaequal.bin &> /dev/null #MPD setglobal OUTPUT_FREQ_TARGET = '44100' setglobal OUTPUT_BITRATE_TARGET = '16' setglobal SOXR_ENABLED = '0' setglobal SOXR_QUALITY = ''very high'' setglobal EQ_ENABLED = '0' setglobal MPD_AUDIO_BUFFER_SIZE = '2048' # - Reset CAVA config cp /DietPi/dietpi/conf/cava.conf "$HOME"/.config/cava/config setglobal CAVA_ENABLED = '1' setglobal CAVA_FRAMERATE = '30' setglobal CAVA_COLOUR_FG = ''green'' setglobal CAVA_COLOUR_BG = ''black'' setglobal CAVA_BAR_GRAVITY = ''1.75'' setglobal CAVA_BAR_WIDTH = '2' # - Save changes Write_Apply_Globals } proc Read_Globals{ setglobal SOUNDCARD_CURRENT = $[cat /DietPi/dietpi.txt | grep -m1 'CONFIG_SOUNDCARD=' | sed 's/.*=//] setglobal EQ_ENABLED = $[cat /etc/asound.conf | grep -ci -m1 '^pcm.plugequal] #MPD specific if sh-expr ' $MPD_INSTALLED ' { setglobal OUTPUT_FREQ_CURRENT = $[cat $FP_MPD_CONF | grep -m1 '^format' | sed 's/\"//g' | sed 's/:/ /g' | awk '{print $2}] setglobal OUTPUT_FREQ_TARGET = $OUTPUT_FREQ_CURRENT setglobal OUTPUT_BITRATE_CURRENT = $[cat $FP_MPD_CONF | grep -m1 '^format' | sed 's/\"//g' | sed 's/:/ /g' | awk '{print $3}] setglobal OUTPUT_BITRATE_TARGET = $OUTPUT_BITRATE_CURRENT setglobal SOXR_ENABLED = $[cat $FP_MPD_CONF | grep -ci -m1 '^samplerate_converter \"soxr] setglobal 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/ *$//] setglobal MPD_AUDIO_BUFFER_SIZE = $[cat $FP_MPD_CONF | grep -m1 '^audio_buffer_size' | awk '{print $2}' | sed 's/\"//g] } #CAVA specific if sh-expr ' $CAVA_INSTALLED ' { setglobal CAVA_FRAMERATE = $[cat $FP_CAVA_CONF | grep -m1 '^framerate =' | awk '{print $3}] setglobal CAVA_COLOUR_BG = $[cat $FP_CAVA_CONF | grep -m1 '^background =' | awk '{print $3}] setglobal CAVA_COLOUR_FG = $[cat $FP_CAVA_CONF | grep -m1 '^foreground =' | awk '{print $3}] setglobal CAVA_BAR_GRAVITY = $[cat $FP_CAVA_CONF | grep -m1 '^gravity =' | awk '{print $3}] setglobal CAVA_BAR_WIDTH = $[cat $FP_CAVA_CONF | grep -m1 '^bar_width =' | awk '{print $3}] } } proc Write_Apply_Globals{ if sh-expr ' $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 sh-expr ' $MPD_INSTALLED ' { # - Output freq/bit sed -i "/^format \"/c\format \"$OUTPUT_FREQ_TARGET:$OUTPUT_BITRATE_TARGET:2\"" $FP_MPD_CONF if sh-expr ' $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 sh-expr ' $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 sh-expr ' $CAVA_ENABLED ' { if test $[tty] = "/dev/tty1" { # - display this warning once only if sh-expr ' ! $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 setglobal 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 #///////////////////////////////////////////////////////////////////////////////////// setglobal PROGRAM_NAME = '"DietPi-JustBoom'" setglobal WHIP_QUESTION = '0' setglobal WHIP_TITLE = '0' setglobal CHOICE = '0' setglobal TARGETMENUID = '0' setglobal 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 setglobal CHOICE = $Status if sh-expr ' $CHOICE == 0 ' { #exit setglobal TARGETMENUID = '-1' } else { #Return to Main Menu setglobal TARGETMENUID = '0' } } #TARGETMENUID=0 proc Menu_Main{ Read_Globals local eq_enabled_text='Disabled' if sh-expr ' $EQ_ENABLED ' { setglobal eq_enabled_text = ''Enabled'' } local soxr_enabled_text='Disabled' if sh-expr ' $SOXR_ENABLED ' { setglobal soxr_enabled_text = ''Enabled'' } local whiptail_menu_array=() setglobal whiptail_menu_array = ''("" "──── Global Options ──────────────────────────") setglobal whiptail_menu_array = ''("ALSA Mixer" ": Launches ALSA Mixer, tweak sound card settings") setglobal whiptail_menu_array = ''("ALSA Output Info" ": View info on current ALSA playback stream") setglobal whiptail_menu_array = ''("EQ Enable" ": $eq_enabled_text | Select to toggle EQ") if sh-expr ' $EQ_ENABLED ' { setglobal whiptail_menu_array = ''("EQ Configure" ": Launches AlsaMixer to configure EQ settings") } setglobal whiptail_menu_array = ''("Reset" ": Reset all options to defaults") #Allo Piano 2.1 specials if sh-expr ' $(echo -e "$SOUNDCARD_CURRENT" | grep -ci -m1 'piano-dac-plus') ' { setglobal whiptail_menu_array = ''("" "──── Allo Piano 2.1 ──────────────────────────") local dsp_filter=$[amixer -c $SOUNDCARD_CARD_INDEX sget "'DSP Program'" | grep 'Item0:' | sed 's/.*Item0: //] setglobal 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: //] setglobal whiptail_menu_array = ''("Master Volume" ": $digital_volume_int ($digital_volume_db)") setglobal whiptail_menu_array = ''("Dual Output Mode" ": $dualoutput_mode") setglobal whiptail_menu_array = ''("Subwoofer Mode" ": $subwoofer_mode") setglobal whiptail_menu_array = ''("Subwoofer Volume" ": $subwoofer_volume_int ($subwoofer_volume_db)") # - only active with subwoofer 2.1+ modes if test $subwoofer_mode != '2.0' { setglobal whiptail_menu_array = ''("Subwoofer Crossover" ": $subwoofer_crossover_frequency Hz") } } #MPD specific if sh-expr ' $MPD_INSTALLED ' { setglobal whiptail_menu_array = ''("" "──── MPD Specific ────────────────────────────") setglobal whiptail_menu_array = ''("Output Frequency" ": $OUTPUT_FREQ_CURRENT Hz | Select to change") setglobal whiptail_menu_array = ''("Output BitRate" ": $OUTPUT_BITRATE_CURRENT Bit | Select to change") setglobal whiptail_menu_array = ''("Audio Buffer" ": $MPD_AUDIO_BUFFER_SIZE Bytes | Select to change") setglobal whiptail_menu_array = ''("SOXR Enable" ": $soxr_enabled_text | Select to toggle SOXR resampling") if sh-expr ' $SOXR_ENABLED ' { setglobal whiptail_menu_array = ''("SOXR Quality" ": $SOXR_QUALITY | Select SOXR quality level") } } #CAVA specific if sh-expr ' $CAVA_INSTALLED ' { setglobal whiptail_menu_array = ''("" "──── CAVA Specific ───────────────────────────") setglobal whiptail_menu_array = ''("Cava Start/Restart" ": Launch Cava on main screen") if sh-expr ' $(ps aux | grep -ci -m1 '[c]ava') ' { setglobal whiptail_menu_array = ''("Cava Stop" ": Stop Cava") } setglobal whiptail_menu_array = ''("Cava Framerate" ": $CAVA_FRAMERATE fps | Select to change") setglobal whiptail_menu_array = ''("Cava FG Colour" ": $CAVA_COLOUR_FG | Select to change") setglobal whiptail_menu_array = ''("Cava BG Colour" ": $CAVA_COLOUR_BG | Select to change") setglobal whiptail_menu_array = ''("Cava Bar Width" ": $CAVA_BAR_WIDTH | Select to change") setglobal whiptail_menu_array = ''("Cava Bar Gravity" ": $CAVA_BAR_GRAVITY | Select to change") } setglobal WHIP_QUESTION = ''Tweak your High-End Audiophile JustBoom (and others) sound card:'' setglobal 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] setglobal CHOICE = $Status unset whiptail_menu_array if sh-expr ' $CHOICE == 0 ' { setglobal 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=() setglobal whiptail_menu_array = ''('2.0' ': Disables Subwoofer output') setglobal whiptail_menu_array = ''('2.1' ': Enables Subwoofer output (mono)') setglobal whiptail_menu_array = ''('2.2' ': Enables Subwoofer output (stereo)') setglobal WHIP_QUESTION = ''Please select a channel mode for Subwoofer output:'' setglobal 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] setglobal CHOICE = $Status unset whiptail_menu_array if sh-expr ' $CHOICE == 0 ' { amixer -c $SOUNDCARD_CARD_INDEX sset 'Subwoofer mode' $OPTION } } elif test $OPTION = "Dual Output Mode" { local whiptail_menu_array=() setglobal whiptail_menu_array = ''('Dual-Mono' ': Enables Dual output (mono)') setglobal whiptail_menu_array = ''('Dual-Stereo' ': Enables Dual output (stereo)') setglobal WHIP_QUESTION = ''Please select a channel mode for Subwoofer output:'' setglobal 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] setglobal CHOICE = $Status unset whiptail_menu_array if sh-expr ' $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 setglobal WHIP_QUESTION = ''Please select a volume level for Master output:'' setglobal 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] setglobal CHOICE = $Status unset whiptail_menu_array if sh-expr ' $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 setglobal WHIP_QUESTION = ''Please select a volume level for Subwoofer output:'' setglobal 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] setglobal CHOICE = $Status unset whiptail_menu_array if sh-expr ' $CHOICE == 0 ' { amixer -c $SOUNDCARD_CARD_INDEX sset 'Subwoofer' ''$OPTION'' } } elif test $OPTION = "Subwoofer Crossover" { local whiptail_menu_array=() setglobal whiptail_menu_array = ''('60' 'Hz') setglobal whiptail_menu_array = ''('70' 'Hz') setglobal whiptail_menu_array = ''('80' 'Hz') setglobal whiptail_menu_array = ''('90' 'Hz (Default)') setglobal whiptail_menu_array = ''('100' 'Hz') setglobal whiptail_menu_array = ''('110' 'Hz') setglobal whiptail_menu_array = ''('120' 'Hz') setglobal whiptail_menu_array = ''('130' 'Hz') setglobal whiptail_menu_array = ''('140' 'Hz') setglobal whiptail_menu_array = ''('150' 'Hz') setglobal whiptail_menu_array = ''('160' 'Hz') setglobal whiptail_menu_array = ''('170' 'Hz') setglobal whiptail_menu_array = ''('180' 'Hz') setglobal whiptail_menu_array = ''('190' 'Hz') setglobal whiptail_menu_array = ''('200' 'Hz') setglobal 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.'' setglobal 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] setglobal CHOICE = $Status unset whiptail_menu_array if sh-expr ' $CHOICE == 0 ' { amixer -c $SOUNDCARD_CARD_INDEX sset 'Lowpass' $OPTION } } elif test $OPTION = "DSP Filter" { local whiptail_menu_array=() setglobal whiptail_menu_array = ''('FIR interpolation with de-emphasis' '(Default)') setglobal whiptail_menu_array = ''('Low latency IIR with de-emphasis' '') setglobal whiptail_menu_array = ''('High attenuation with de-emphasis' '') setglobal whiptail_menu_array = ''('Fixed process flow' '') setglobal whiptail_menu_array = ''('Ringing-less low latency FIR' '') setglobal WHIP_QUESTION = ''Please select a DSP Filter:'' setglobal 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] setglobal CHOICE = $Status unset whiptail_menu_array if sh-expr ' $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=() setglobal whiptail_menu_array = ''("10" ": Lowest CPU usage") setglobal whiptail_menu_array = ''("20" "") setglobal whiptail_menu_array = ''("30" ": Default") setglobal whiptail_menu_array = ''("40" "") setglobal whiptail_menu_array = ''("50" "") setglobal whiptail_menu_array = ''("60" "") setglobal whiptail_menu_array = ''("80" "") setglobal whiptail_menu_array = ''("100" "") setglobal whiptail_menu_array = ''("120" ": Highest CPU usage") setglobal WHIP_QUESTION = ''Please select a framerate:'' setglobal 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] setglobal CHOICE = $Status unset whiptail_menu_array if sh-expr ' $CHOICE == 0 ' { setglobal CAVA_FRAMERATE = $OPTION Write_Apply_Globals } } elif test $OPTION = "Cava Bar Width" { local whiptail_menu_array=() setglobal whiptail_menu_array = ''("1" ": Thin (Increases total bar count)") setglobal whiptail_menu_array = ''("2" ": Default") setglobal whiptail_menu_array = ''("3" "") setglobal whiptail_menu_array = ''("4" "") setglobal whiptail_menu_array = ''("5" "") setglobal whiptail_menu_array = ''("6" "") setglobal whiptail_menu_array = ''("8" ": Thick (Lowers total bar count)") setglobal WHIP_QUESTION = ''Please select a bar width:\n - The size of the bars affects how many are displayed'' setglobal 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] setglobal CHOICE = $Status unset whiptail_menu_array if sh-expr ' $CHOICE == 0 ' { setglobal 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" { setglobal apply_fg_colour = '1' setglobal default_item = $CAVA_COLOUR_FG } local whiptail_menu_array=() setglobal whiptail_menu_array = ''("green" "") setglobal whiptail_menu_array = ''("red" "") setglobal whiptail_menu_array = ''("yellow" "") setglobal whiptail_menu_array = ''("magenta" "") setglobal whiptail_menu_array = ''("cyan" "") setglobal whiptail_menu_array = ''("white" "") setglobal whiptail_menu_array = ''("blue" "") setglobal whiptail_menu_array = ''("black" "") setglobal WHIP_QUESTION = ''Please select a colour:'' setglobal 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] setglobal CHOICE = $Status unset whiptail_menu_array if sh-expr ' $CHOICE == 0 ' { if sh-expr ' $apply_fg_colour ' { setglobal CAVA_COLOUR_FG = $OPTION } else { setglobal CAVA_COLOUR_BG = $OPTION } Write_Apply_Globals } } elif test $OPTION = "Cava Bar Gravity" { local whiptail_menu_array=() setglobal whiptail_menu_array = ''("0.1" ": Slow drop off speed") setglobal whiptail_menu_array = ''("0.25" "") setglobal whiptail_menu_array = ''("0.5" "") setglobal whiptail_menu_array = ''("0.75" "") setglobal whiptail_menu_array = ''("1" "") setglobal whiptail_menu_array = ''("1.25" "") setglobal whiptail_menu_array = ''("1.5" "") setglobal whiptail_menu_array = ''("1.75" ": Default") setglobal whiptail_menu_array = ''("2" ": High drop off speed") setglobal WHIP_QUESTION = ''Please select a gravity level (drop off speed) for the bars:\n - Higher values means bars will drop faster.'' setglobal 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] setglobal CHOICE = $Status unset whiptail_menu_array if sh-expr ' $CHOICE == 0 ' { setglobal CAVA_BAR_GRAVITY = $OPTION Write_Apply_Globals } } elif test $OPTION = "EQ Configure" { if sh-expr ' $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" { sh-expr 'EQ_ENABLED++' if sh-expr ' $EQ_ENABLED > 1 ' { setglobal EQ_ENABLED = '0' } Write_Apply_Globals } elif test $OPTION = "SOXR Enable" { sh-expr 'SOXR_ENABLED++' if sh-expr ' $SOXR_ENABLED > 1 ' { setglobal SOXR_ENABLED = '0' } Write_Apply_Globals } elif test $OPTION = "SOXR Quality" { local whiptail_menu_array=() setglobal whiptail_menu_array = ''("very high" ": Highest quality, highest CPU usage") setglobal whiptail_menu_array = ''("high" ": Default quality, medium CPU usage") setglobal whiptail_menu_array = ''("low" ": Lowest quality, minimal CPU usage") setglobal WHIP_QUESTION = ''Select a SOXR Quality level:'' setglobal 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] setglobal CHOICE = $Status unset whiptail_menu_array if sh-expr ' $CHOICE == 0 ' { setglobal SOXR_QUALITY = $OPTION Write_Apply_Globals } } elif test $OPTION = "Audio Buffer" { local whiptail_menu_array=() setglobal whiptail_menu_array = ''("128" ": Lowest latency (may cause buffer under/overruns)") setglobal whiptail_menu_array = ''("192" ":") setglobal whiptail_menu_array = ''("256" ":") setglobal whiptail_menu_array = ''("384" ":") setglobal whiptail_menu_array = ''("512" ":") setglobal whiptail_menu_array = ''("1024" ":") setglobal whiptail_menu_array = ''("2048" ": Default") setglobal whiptail_menu_array = ''("4096" ": Highest latency") setglobal WHIP_QUESTION = ''Select an Audio buffer size (bytes):'' setglobal 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] setglobal CHOICE = $Status unset whiptail_menu_array if sh-expr ' $CHOICE == 0 ' { setglobal MPD_AUDIO_BUFFER_SIZE = $OPTION Write_Apply_Globals } } elif test $OPTION = "Output Frequency" { local whiptail_menu_array=() setglobal whiptail_menu_array = ''("384000" ": 384kHz (highest quality)") setglobal whiptail_menu_array = ''("352800" ": 352kHz") setglobal whiptail_menu_array = ''("192000" ": 192kHz") setglobal whiptail_menu_array = ''("96000" ": 96kHz") setglobal whiptail_menu_array = ''("88200" ": 88.2kHz") setglobal whiptail_menu_array = ''("64000" ": 64kHz") setglobal whiptail_menu_array = ''("48000" ": 48kHz (HDMI standard)") setglobal whiptail_menu_array = ''("44100" ": 44.1kHz (music standard)") setglobal WHIP_QUESTION = ''Select an Output Frequency:'' setglobal 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] setglobal CHOICE = $Status unset whiptail_menu_array if sh-expr ' $CHOICE == 0 ' { setglobal OUTPUT_FREQ_TARGET = $OPTION Write_Apply_Globals } } elif test $OPTION = "Output BitRate" { local whiptail_menu_array=() setglobal whiptail_menu_array = ''("32" ": (highest quality, recommended)") setglobal whiptail_menu_array = ''("24" ": ") setglobal whiptail_menu_array = ''("16" ": (CD audio quality)") setglobal WHIP_QUESTION = ''Select an Output BitRate:'' setglobal 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] setglobal CHOICE = $Status unset whiptail_menu_array if sh-expr ' $CHOICE == 0 ' { setglobal OUTPUT_BITRATE_TARGET = $OPTION Write_Apply_Globals } } elif test $OPTION = "Reset" { Reset_Globals } } else { Menu_Exit } } #///////////////////////////////////////////////////////////////////////////////////// # Main Loop #///////////////////////////////////////////////////////////////////////////////////// #----------------------------------------------------------------------------------- Read_Globals #----------------------------------------------------------------------------------- while (( $TARGETMENUID >= 0 )) { if sh-expr ' $TARGETMENUID == 0 ' { Menu_Main } } #----------------------------------------------------------------------------------- exit #----------------------------------------------------------------------------------- }