From 38b9a5de0e4d4953ced53d383be61a3f8fe2e6b4 Mon Sep 17 00:00:00 2001 From: rern Date: Sun, 3 Mar 2024 23:52:11 +0700 Subject: [PATCH] Update status.sh --- srv/http/bash/status.sh | 38 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 38 insertions(+) diff --git a/srv/http/bash/status.sh b/srv/http/bash/status.sh index b0faeb497..6db7f15bd 100644 --- a/srv/http/bash/status.sh +++ b/srv/http/bash/status.sh @@ -16,6 +16,44 @@ outputStatus() { fi [[ $1 != noexit ]] && exit # >>>>>>>>>> } +samplingLine() { + local bitdepth bitrate ext rate samplerate sampling + bitdepth=$1 + samplerate=$2 + bitrate=$3 + ext=$4 + if [[ $bitrate == 0 || ! $bitrate ]]; then + if [[ ${bitdepth//[!0-9]/} ]]; then + bitrate=$(( bitdepth * samplerate * 2 )) + else + bitrate=$( ffprobe \ + -v quiet \ + -show_entries format=bit_rate \ + -of default=noprint_wrappers=1:nokey=1 \ + "/mnt/MPD/$filenoesc" ) + fi + fi + if (( $bitrate < 1000000 )); then + rate="$(( bitrate / 1000 )) kbit/s" + else + [[ $bitdepth == dsd ]] && bitrate=$(( bitrate / 2 )) + rate="$( calc 2 $bitrate/1000000 ) Mbit/s" + fi + + if [[ $bitdepth == dsd ]]; then + sampling="${samplerate^^} • $rate" + else + [[ $bitdepth == 'N/A' && ( $ext == WAV || $ext == AIFF ) ]] && bitdepth=$(( bitrate / samplerate / 2 )) + sample="$( calc 1 $samplerate/1000 ) kHz" + if [[ $bitdepth && ! $ext =~ ^(AAC|MP3|OGG|Radio)$ ]]; then + sampling="$bitdepth bit $sample $rate" + else # lossy has no bitdepth + sampling="$sample $rate" + fi + fi + [[ $ext != Radio ]] && sampling+=" • $ext" + echo $sampling +} if [[ -L $dirmpd && ! -e $dirmpd/counts ]]; then # shared data for i in {1..10}; do