[gen_metatrack] Rewrote to better manage life as a metatrack dude

This commit is contained in:
ayakael 2018-07-19 08:14:53 -08:00
parent c5da64790b
commit 0d4fc50e52
No known key found for this signature in database
GPG key ID: 575626A4AE5F4026

View file

@ -17,27 +17,28 @@ gen_metatrack() {
FLAC="${2}"
CUE="${3}"
gen_tracks "${WRK_DIR}" "${FLAC}" "${CUE}"
gen_tracks "${WRK_DIR}" "${FLAC}" "${CUE}" >/dev/null 2>&1
local TOTALTRACKS="$(grep -e "TRACK [0-9][0-9] AUDIO" "${CUE}" | wc -l)"
local COUNT=1
while [[ ${COUNT} -le ${TOTALTRACKS} ]]; do
local fileList[${COUNT}]=$(printf "\'${WRK_DIR}/split-track%02d.flac\'\t" ${COUNT})
local COUNT=0
while [[ ${COUNT} -lt ${TOTALTRACKS} ]]; do
local fileList[${COUNT}]=$(printf "${WRK_DIR}/split-track%02d.flac\t" $(( ${COUNT} + 1 )))
local COUNT=$(( ${COUNT} + 1 ))
done
local replaygainList=($(metaflac --scan-replay-gain ${fileList[@]} | awk 'BEGIN{FS=":"}{print $2}'))
local REPLAYGAIN_ALBUM_GAIN=${replaygainList[1]}
local REPLAYGAIN_ALBUM_PEAK=${replaygainList[2]}
local replaygainList=($(metaflac --scan-replay-gain ${fileList[@]} | awk 'BEGIN{ORS=" ";FS=":"}{print $2}' | tr ' ' '\t'))
local REPLAYGAIN_ALBUM_GAIN=${replaygainList[0]}
local REPLAYGAIN_ALBUM_PEAK=${replaygainList[1]}
local trackidList=($(metaflac --list --block-number=0 ${fileList[@]} | awk 'BEGIN{FS=": "}{if($2==" MD5 signature") {print $3}}'))
local durationList=($(soxi -D ${fileList[@]}))
printf "%s;" ${REPLAYGAIN_ALBUM_GAIN} ${REPLAYGAIN_ALBUM_PEAK}
for file in ${fileList[@]}; do
local TRACKID="$(metaflac --list --block-number=0 ${file} ${COUNT}) | awk 'BEGIN{FS=": "}{if($1==" MD5 signature") {print $2}}')"
local DURATION="$(soxi -D ${file} ${COUNT}))"
local REPLAYGAIN_TRACK_GAIN=${replaygainList[$(( $(( ${COUNT} * 4 )) - 1 ))]}
local REPLAYGAIN_TRACK_PEAK=${replaygainList[$(( ${COUNT} * 4 ))]}
printf "%s;" ${TRACKID} ${DURATION} ${REPLAYGAIN_TRACK_GAIN} ${REPLAYGAIN_TRACK_PEAK}
rm ${file}
local COUNT=0
while [[ ${COUNT} -lt ${TOTALTRACKS} ]]; do
local TRACKID=${trackidList[${COUNT}]}
local DURATION=${durationList[${COUNT}]}
local REPLAYGAIN_TRACK_GAIN=${replaygainList[$(( $(( ${COUNT} * 4 )) + 2 ))]}
local REPLAYGAIN_TRACK_PEAK=${replaygainList[$(( $(( ${COUNT} * 4 )) + 3 ))]}
echo "TRACKID=${TRACKID};DURATION=${DURATION};REPLAYGAIN_ALBUM_GAIN=${REPLAYGAIN_ALBUM_GAIN};REPLAYGAIN_ALBUM_PEAK=${REPLAYGAIN_ALBUM_PEAK};REPLAYGAIN_TRACK_GAIN=${REPLAYGAIN_TRACK_GAIN};REPLAYGAIN_TRACK_PEAK=${REPLAYGAIN_TRACK_PEAK};"
local COUNT=$(( ${COUNT} + 1 ))
done
}