Skip to content

Commit

Permalink
Update status.sh
Browse files Browse the repository at this point in the history
  • Loading branch information
rern committed Mar 3, 2024
1 parent b75a197 commit 38b9a5d
Showing 1 changed file with 38 additions and 0 deletions.
38 changes: 38 additions & 0 deletions srv/http/bash/status.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 38b9a5d

Please sign in to comment.