daily pastebin goal
2%
SHARE
TWEET

It's My Own Secret Technique

george23 Dec 12th, 2017 (edited) 351 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. afadd() {
  2. mkdir -p ~/aftemp
  3. for f in *.(flac|mp3|mp4|m4a|wav|ape|wma|ogg|MP3|webm|aiff|dsf|mod|med|wv|xm|aif|WAV|avi)
  4. do
  5.  echo "`readlink -m "$f"`" >> ~/aftemp/aflist
  6. done
  7. echo "Files added to the list, start afcombo to process it. Files can be added or edited when processing run. ;)"
  8. }
  9.  
  10. afcombo() {
  11. sudo renice -n 19 -p $$
  12. sudo ionice -c3 -p$$
  13. mkdir -p ~/hqmp3 ~/hqflac48
  14. trap "stty $(stty -g)" EXIT
  15. stty -echo || exit $?
  16. afblock=6;afpad=1;aflow=22050;afrelative=~/
  17. gvol2=6.020599913279623904274777894489860535363797629242170826208
  18. gvol5=13.97940008672037609572522210551013946463620237075782917379
  19. gvolr48=6.7566528714345975469846810636415487534735150094383205743
  20. while [[ -s ~/aftemp/aflist ]] ; do f=$(head -n 1 ~/aftemp/aflist)
  21.  ffprobe "$f" 2>&1 | grep -e Input -e Stream -e Duration ; [[ ! -f ~/aftemp/sum ]] \
  22.  && { afseco=`echo "1-$(ffmpeg -loglevel 0 -y -i "$f" -vn -acodec pcm_s32le -f sox - \
  23. | sox -p -b32 ~/aftemp/0temp.wav rate -v 44100 reverse sinc -22049 -t 1 reverse sinc -22049 -t 1 stats 2>&1 \
  24. | grep -e Length | cut -b17-20)" | bc -l`; echo $afseco > ~/aftemp/afseco
  25.  mv ~/aftemp/0temp.wav ~/aftemp/3temp.wav; sox ~/aftemp/3temp.wav -V0 -b32 ~/aftemp/0temp.wav pad $(echo "$afpad+$afseco"|bc -l) "$afpad"
  26.  rm -f ~/aftemp/3temp.wav
  27.  for (( i=0; ; i++ )); do counter=`echo "$i*$afblock" | bc -l`; temp=`printf "%09d\n" $(($i+1))`
  28.   sox ~/aftemp/0temp.wav -b32 ~/aftemp/temp"$temp".wav \
  29.    trim "$counter" $(echo "$afpad+$afblock+$afpad" | bc -l) 2>/dev/null
  30.   SIZE=`wc -c <$(echo ~/aftemp/temp"$temp".wav)`
  31.   if ((SIZE<500)) ; then rm -f ~/aftemp/temp"$temp".wav; echo $i > ~/aftemp/sum; break; fi
  32.  done }; sum=`cat ~/aftemp/sum`
  33.  for t in ~/aftemp/temp?????????.wav;do RET=1; until [ $RET -eq 0 ];do
  34.   START=`date +%s.%N`
  35.   afpath="`realpath --relative-to "$afrelative" "$f"`"
  36.   echo -ne `echo "$t" | sed 's:.*/::'` "($sum)" "$afpath "
  37.   afail=`sox -V3 --multi-threaded "$t" -b32 -r 48000 ~/aftemp/22$(echo "$t" | sed 's:.*/::') --temp /dev/shm \
  38.    upsample 2 sinc "-$aflow" reverse sinc "-$aflow" reverse sinc "-$aflow" reverse sinc "-$aflow" reverse \
  39.     sinc "-$aflow" reverse sinc "-$aflow" reverse sinc "-$aflow" reverse sinc "-$aflow" reverse gain "$gvol2" \
  40.    upsample 2 sinc "-$aflow" reverse sinc "-$aflow" reverse gain "$gvol2" \
  41.    upsample 2 sinc "-$aflow" reverse sinc "-$aflow" reverse gain "$gvol2" \
  42.    upsample 2 sinc "-$aflow" reverse sinc "-$aflow" reverse gain "$gvol2" \
  43.    upsample 2 sinc "-$aflow" reverse sinc "-$aflow" reverse gain "$gvol2" \
  44.    upsample 5 sinc "-$aflow" reverse sinc "-$aflow" reverse gain "$gvol5" \
  45.    downsample 147 trim "$afpad" reverse trim "$afpad" reverse 2>&1`
  46.   [[ $afail == *"FAIL"*"error writing"* ]] && echo $afail && sleep 10 || { rm -f "$t" 2>/dev/null
  47.   afdec=`echo $t | sed -e 's/[^0-9]//g' | tail -c 2`
  48.   [[ $afdec -eq 0 ]] && sox -V0 --multi-threaded `for f in ~/aftemp/22temp?????????.wav; do echo "$f "; done` -b32 \
  49.    `echo $(ls ~/aftemp/22temp????????0.wav) | sed 's/2/0/'` && rm -f ~/aftemp/22temp?????????.wav
  50.    aftblock=$(($(date +%s.%N) - $START))
  51.    aftime=`date -u -d @${aftblock} +"%T"`; afremain=$(($sum-$(echo $t | sed -e 's/[^0-9]//g')))
  52.    afeta1=$(($afremain*$aftblock)); afeta=`date -u -d @${afeta1} +"%T"`
  53.    echo "\b\b\b\b\b$aftime ETA:$afeta" $(($aftblock/$afblock))x
  54.   RET=0 }
  55.   done; rm -f ~/aftemp/"$t" 2>/dev/null
  56.  done
  57.  mkdir -p ~/hqmp3/"`dirname "$afpath"`" ~/hqflac48/"`dirname "$afpath"`"; afseco=`cat ~/aftemp/afseco`
  58.  sox --multi-threaded `for f in ~/aftemp/?2temp?????????.wav; do echo "$f "; done` -V3 -b32 \
  59.   ~/aftemp/3temp.wav gain "$gvolr48" trim "$afseco" 2>/dev/null
  60.  sox -V0 --multi-threaded ~/aftemp/3temp.wav -b24 ~/hqflac48/"`echo "$afpath" | sed 's/\.[^.]*$//'`.flac" 2>/dev/null
  61.  lame ~/aftemp/3temp.wav --noreplaygain --preset insane --bitwidth 32 -q 0 -m s --cbr -b 320 \
  62.   ~/hqmp3/"`echo "$afpath" | sed 's/\.[^.]*$//'`.mp3" \
  63.  && rm -f ~/aftemp/*.wav ~/aftemp/sum ~/aftemp/afseco && sed -i -e "1d" ~/aftemp/aflist
  64. done && rm -f ~/aftemp/**
  65. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top