diff --git a/downmix.sh b/downmix.sh index 0f75c13..1f4c4f6 100644 --- a/downmix.sh +++ b/downmix.sh @@ -1,10 +1,15 @@ #!/bin/bash -# Simple script to downmix a 5.1/5.1 (side) flac file to stereo, -# and optionally resample to cd quality -read -p 'Gain db [+3db]: ' GAIN +# ==================================================================== +# Simple script to downmix a 5.0/5.1/5.1 (side) flac file to stereo, +# and optionally resample to cd quality +# +# Dependencies: ffmpeg (built with libsoxr and flac) +# ==================================================================== + +read -p 'Gain db [-6]: ' GAIN if [[ -z "$GAIN" ]]; then - GAIN=3 + GAIN=-6 fi read -p 'Resample to cd quality? [No]: ' RES @@ -13,8 +18,8 @@ mkdir -p down for file in *.flac; do if [[ -z "$RES" ]]; then - ffmpeg -i "$file" -af "pan=stereo| FL < FL + 0.707*FC + 0.707*BL + 0.707*SL + 0.5*LFE | FR < FR + 0.707*FC + 0.707*BR + 0.707*SR + 0.5*LFE,volume=${GAIN}dB" "down/$file" + ffmpeg -i "$file" -af "volume=volume=${GAIN}dB:precision=double,pan=stereo| FL = FL + 0.707*FC + 0.707*BL + 0.707*SL + 0.5*LFE | FR = FR + 0.707*FC + 0.707*BR + 0.707*SR + 0.5*LFE" "down/$file" else - ffmpeg -i "$file" -af "pan=stereo| FL < FL + 0.707*FC + 0.707*BL + 0.707*SL + 0.5*LFE | FR < FR + 0.707*FC + 0.707*BR + 0.707*SR + 0.5*LFE,volume=${GAIN}dB,aresample=resampler=soxr:precision=28" -sample_fmt s16 -ar 44100 -map_metadata -1 "down/${file/%flac/wav}" + ffmpeg -i "$file" -af "volume=volume=${GAIN}dB:precision=double,pan=stereo| FL = FL + 0.707*FC + 0.707*BL + 0.707*SL + 0.5*LFE | FR = FR + 0.707*FC + 0.707*BR + 0.707*SR + 0.5*LFE,aresample=resampler=soxr:precision=33:cutoff=0.96:dither_method=triangular:out_sample_rate=44100:out_sample_fmt=s16" "down/${file/%flac/wav}" fi done diff --git a/flac2opus.sh b/flac2opus.sh index f3fd92e..f640627 100644 --- a/flac2opus.sh +++ b/flac2opus.sh @@ -1,17 +1,17 @@ #!/bin/bash -read -p 'Input bitrate: ' BITRATE +read -p 'Bitrate [192]: ' BITRATE if [[ -z "$BITRATE" ]]; then - BITRATE=160 + BITRATE=192 fi -read -p 'Gain db: ' GAIN +read -p 'Gain db [-1]: ' GAIN if [[ -z "$GAIN" ]]; then - GAIN=-2 + GAIN=-1 fi mkdir -p opus -for file in ./*.flac; do - sox -V "$file" -t flac - gain $GAIN rate -v 48000 | opusenc --bitrate $BITRATE \ - - "./opus/${file/%flac/ogg}" +for file in *.flac; do + sox -V3 -D "$file" -t flac -b 24 - gain "$GAIN" rate -v 48000 | + opusenc --bitrate "$BITRATE" - "./opus/${file/%flac/ogg}" done diff --git a/resampletocdq.sh b/resampletocdq.sh new file mode 100755 index 0000000..b4b80b1 --- /dev/null +++ b/resampletocdq.sh @@ -0,0 +1,26 @@ +#!/bin/bash + +# =============================================================== +# Script for resampling flac/wav files to cd resolution +# +# Dependencies: SoX +# =============================================================== + +read -p 'Gain db [0]: ' GAIN +if [[ -z "$GAIN" ]]; then + GAIN=0 +fi + +read -p 'Format of source is wav? [flac]: ' FORMAT + +mkdir -p resampled + +if [[ -z "$FORMAT" ]]; then + for file in *.flac; do + sox -V3 "$file" -b 16 "resampled/${file/%flac/wav}" gain "$GAIN" rate -v 44100 dither -s + done +else + for file in *.wav; do + sox -V3 "$file" -b 16 "resampled/$file" gain "$GAIN" rate -v 44100 dither -s + done +fi