Advertisement
Guest User

Untitled

a guest
Jul 20th, 2017
62
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Winbatch 10.49 KB | None | 0 0
  1. @echo off
  2. :: header text
  3. echo -----------------------------------------------------------
  4. echo lFLC.bat for lFLCDrop v1.0.0.7                    by JesseG
  5. echo -----------------------------------------------------------
  6. echo.
  7.  
  8. :: ********************************************
  9. :: *** CUSTOM SETTINGS CAN BE TWEAKED BELOW ***
  10.  
  11. :: encoding settings
  12. SET enc_cust_lossyWAVpreset_char=2
  13. SET enc_cust_createcorrectionfile_bool=1
  14. SET enc_cust_signalnoiseratio_int=21
  15. SET enc_cust_noisethresholdshift_float=0.0
  16. SET enc_cust_noclips_bool=0
  17. SET enc_cust_flacquality_int=5
  18. SET enc_cust_flacoptions_string=-b 512 --keep-foreign-metadata -f
  19.  
  20. :: decoding settings (effects ALL frontend presets)
  21. SET dec_cust_decodecorrectionfile_bool=1
  22. SET dec_cust_mergecorrectionfile_bool=1
  23. SET dec_cust_deleteunmergedwavs_bool=1
  24.  
  25. :: *** CUSTOM SETTINGS CAN BE TWEAKED ABOVE ***
  26. :: ********************************************
  27. :: NOTES:
  28. :: lossyWAV presets: 1 1a 1b 2 2a 2b 2c 3 3a 3b 3c 4 4a 4b 4c 5 5a 5b 5c 6 6a 6b 6c 7 7a 7b 7c
  29. :: ********************************************
  30.  
  31.  
  32.  
  33.  
  34.  
  35.  
  36. :: *************************************************
  37. :: *** DO NOT MESS WITH ANYTHING BELOW THIS LINE ***
  38. :: *** UNLESS YOU REALLY KNOW WHAT YOU ARE DOING ***
  39. :: *************************************************
  40.  
  41. :: check for needed files & folders
  42. IF NOT EXIST .\temp\ MKDIR .\temp
  43. IF NOT EXIST .\lossyWAV.exe GOTO err_mis1
  44. IF NOT EXIST .\flac.exe GOTO err_mis2
  45.  
  46. :: commandline variable error detection
  47. IF '%1'=='' GOTO err_par1
  48. IF '%2'=='' GOTO err_par1
  49. IF '%3'=='' GOTO err_par1
  50. IF '%4'=='' GOTO err_par1
  51.  
  52. :: import commandline variables
  53. SET qualitypreset=%1
  54. SET outputflag=%2
  55. SET loc_output=%3
  56. SET loc_input=%4
  57. SET loc_encode_flac_inputlossy_fromtemp=".\temp\%~n4.lossy%~x4"
  58. SET loc_encode_flac_inputlwcdf_fromtemp=".\temp\%~n4.lwcdf%~x4"
  59. SET loc_encode_flac_outputlossy_fullpathfile="%~dpn3.lossy%~x3"
  60. SET loc_encode_flac_outputlwcdf_fullpathfile="%~dpn3.lwcdf%~x3"
  61. SET loc_decode_flac_display_nameextension="%~nx4"
  62. SET loc_decode_destination_fullpath="%~dp3"
  63. SET loc_decode_lwcdf_fullpathfile_FLAC="%loc_output:~1,-11%.lwcdf.flac"
  64. SET loc_decode_lwcdf_fullpathfile_WAV="%loc_output:~1,-11%.lwcdf.wav"
  65. SET loc_decode_lossy_fullpathfile_WAV="%loc_output:~1,-11%.lossy.wav"
  66.  
  67. :: encode/decode
  68. IF '%qualitypreset%'=='-d' GOTO decode
  69. GOTO encode
  70.  
  71. :: error handlers
  72. :err_par1
  73. echo Error: unable to parse the correct command line variables.
  74. pause
  75. GOTO exit
  76. :err_mis1
  77. echo Error: lossyWAV.exe not found.  Check readme.txt for instructions.
  78. pause
  79. GOTO exit
  80. :err_mis2
  81. echo Error: flac.exe not found.  Check readme.txt for instructions.
  82. pause
  83. GOTO exit
  84. :err_e1hc
  85. echo Warning: lossyWAV does not process files that are already lossy.
  86. echo          Your lossy WAV file will now be encoded to FLAC anyways,
  87. echo          but a correction file cannot be generated.
  88. echo.
  89. GOTO enc_flac
  90. :err_e1lw
  91. echo Warning: lFLC.bat has a saftey feature to prevent processing of
  92. echo          files that have ".lossy.wav" extensions even when they
  93. echo          do not have lossyWAV metadata.  This is to prevent the
  94. echo          double-processing of legacy lossyWAV files.
  95. echo.
  96. echo          Your WAV file will now be encoded to FLAC anyways,
  97. echo          but a correction file will not be generated.
  98. echo.
  99. GOTO enc_flac
  100. :err_d_n1
  101. echo Error while attempting to merge lossyWAV:
  102. echo Correction file does not exist.
  103. echo Set "dec_cust_decodecorrectionfile_bool" to 1 in lFLC.bat or
  104. echo set "dec_cust_mergecorrectionfile_bool" to 0 in lFLC.bat
  105. echo.
  106. GOTO dec_end
  107. :err_d_n2
  108. echo Error while attempting to merge legacy lossyWAV:
  109. echo Correction file does not exist.
  110. echo.
  111. GOTO dec_end
  112.  
  113. :decode
  114. echo Decoding:
  115. echo %loc_decode_flac_display_nameextension%
  116. echo.
  117. flac -d -f --keep-foreign-metadata --decode-through-errors --totally-silent %loc_input%
  118. IF ERRORLEVEL==1 GOTO dec_nomd
  119. lossyWAV %loc_output% -check -quiet -nowarn
  120. IF NOT ERRORLEVEL 16 GOTO dec_nolw
  121. IF %dec_cust_decodecorrectionfile_bool%==1 (
  122.     IF EXIST %loc_decode_lwcdf_fullpathfile_FLAC% (
  123.         flac -d -f --keep-foreign-metadata --decode-through-errors --totally-silent %loc_decode_lwcdf_fullpathfile_FLAC%
  124.     )
  125. )
  126. IF %dec_cust_mergecorrectionfile_bool%==1 (
  127.     IF EXIST %loc_decode_lwcdf_fullpathfile_WAV% (
  128.         lossyWAV %loc_output% -merge -o %loc_decode_destination_fullpath%
  129.     ) ELSE GOTO err_d_n1
  130.     IF "%dec_cust_deleteunmergedwavs_bool%"=="1" (
  131.         DEL /F /Q %loc_decode_lossy_fullpathfile_WAV%
  132.         DEL /F /Q %loc_decode_lwcdf_fullpathfile_WAV%
  133.     )
  134. )
  135. GOTO dec_end
  136. :dec_nomd
  137. flac -d -f --decode-through-errors --totally-silent %loc_input%
  138. :dec_nolw
  139. IF %dec_cust_decodecorrectionfile_bool%==1 (
  140.     IF EXIST %loc_decode_lwcdf_fullpathfile_FLAC% (
  141.         flac -d -f --keep-foreign-metadata --decode-through-errors --totally-silent %loc_decode_lwcdf_fullpathfile_FLAC%
  142.         IF ERRORLEVEL==1 GOTO dec_cnmd
  143.     )
  144. )
  145. GOTO dec_cmrg
  146. :dec_cnmd
  147. flac -d -f --decode-through-errors --totally-silent %loc_decode_lwcdf_fullpathfile_FLAC%
  148. :dec_cmrg
  149. SET loc_temp1="%loc_input:~-11%"
  150. IF NOT "%loc_temp1:~1,-2%"==".lossy.flac" GOTO dec_end
  151. IF %dec_cust_mergecorrectionfile_bool%==1 (
  152.     IF EXIST %loc_decode_lwcdf_fullpathfile_WAV% (
  153.         lossyWAV %loc_output% -merge -o %loc_decode_destination_fullpath%
  154.     ) ELSE GOTO err_d_n2
  155.     IF "%dec_cust_deleteunmergedwavs_bool%"=="1" (
  156.         DEL /F /Q %loc_decode_lossy_fullpathfile_WAV%
  157.         DEL /F /Q %loc_decode_lwcdf_fullpathfile_WAV%
  158.     )
  159. )
  160. GOTO dec_end
  161. :dec_end
  162. GOTO exit
  163.  
  164. :encode
  165. IF EXIST .\temp\*.wav DEL /F /Q .\temp\*.wav
  166. IF '%qualitypreset%'=='-1' GOTO encode_1
  167. IF '%qualitypreset%'=='-2' GOTO encode_1
  168. IF '%qualitypreset%'=='-3' GOTO encode_1
  169. IF '%qualitypreset%'=='-4' GOTO encode_1
  170. IF '%qualitypreset%'=='-5' GOTO encode_1
  171. IF '%qualitypreset%'=='-6' GOTO encode_1
  172. IF '%qualitypreset%'=='-7' GOTO encode_1
  173. IF '%qualitypreset%'=='-8' GOTO enc_cust
  174. GOTO err_par1
  175.  
  176. :encode_1
  177. lossyWAV %loc_input% -check -quiet -nowarn
  178. IF ERRORLEVEL 16 IF NOT ERRORLEVEL 17 GOTO err_e1hc
  179. SET loc_temp1="%loc_input:~-11%"
  180. IF "%loc_temp1:~1,-2%"==".lossy.wav" GOTO err_e1lw
  181. lossyWAV %loc_input% %qualitypreset% -o ".\temp\" -below -nowarn -force -correction
  182. flac -5 -o %loc_encode_flac_outputlossy_fullpathfile% -f -b 512 --keep-foreign-metadata %loc_encode_flac_inputlossy_fromtemp%
  183. flac -5 -o %loc_encode_flac_outputlwcdf_fullpathfile% -f -b 512 --keep-foreign-metadata %loc_encode_flac_inputlwcdf_fromtemp%
  184. IF EXIST .\temp\*.wav DEL /F /Q .\temp\*.wav
  185. GOTO exit
  186.  
  187. :enc_flac
  188. SET loc_temp1="%loc_input:~-11%"
  189. IF "%loc_temp1:~1,-2%"==".lossy.wav" (
  190.     SET loc_encode_flac_outputalreadylossy_fullpathfile="%~dpnx3"
  191.     SET loc_encode_flac_inputlwcdf_fromsource_fullpathfile="%loc_input:~1,-11%.lwcdf.wav"
  192.     SET loc_encode_flac_outputlwcdf_fullpathfile="%loc_output:~1,-12%.lwcdf.flac"
  193. ) ELSE (
  194.     SET loc_encode_flac_outputalreadylossy_fullpathfile="%~dpn3.lossy%~x3"
  195.     SET loc_encode_flac_inputlwcdf_fromsource_fullpathfile="%~dpn4.lwcdf%~x4"
  196. )
  197. flac -5 -o %loc_encode_flac_outputalreadylossy_fullpathfile% -f -b 512 --keep-foreign-metadata %loc_input%
  198. IF EXIST %loc_encode_flac_inputlwcdf_fromsource_fullpathfile% (
  199.     flac -5 -o %loc_encode_flac_outputlwcdf_fullpathfile% -f -b 512 --keep-foreign-metadata %loc_encode_flac_inputlwcdf_fromsource_fullpathfile%
  200. )
  201. IF EXIST .\temp\*.wav DEL /F /Q .\temp\*.wav
  202. GOTO exit
  203.  
  204. :enc_cust
  205. :: ***********************************
  206. :: ***   CUSTOM ENCODING SECTION   ***
  207. :: ***********************************
  208. lossyWAV %loc_input% -check -quiet -nowarn
  209. IF ERRORLEVEL 16 IF NOT ERRORLEVEL 17 GOTO enc_c_hc
  210. SET loc_temp1="%loc_input:~-11%"
  211. IF "%loc_temp1:~1,-2%"==".lossy.wav" GOTO enc_c_il
  212. IF %enc_cust_createcorrectionfile_bool%==1 (
  213.     IF %enc_cust_noclips_bool%==1 (
  214.         lossyWAV %loc_input% -%enc_cust_lossyWAVpreset_char% -o ".\temp\" -below -nowarn -force -snr %enc_cust_signalnoiseratio_int% -nts %enc_cust_noisethresholdshift_float% -noclips -correction
  215.     ) ELSE (
  216.         lossyWAV %loc_input% -%enc_cust_lossyWAVpreset_char% -o ".\temp\" -below -nowarn -force -snr %enc_cust_signalnoiseratio_int% -nts %enc_cust_noisethresholdshift_float% -correction
  217.     )
  218. ) ELSE (
  219.     IF %enc_cust_noclips_bool%==1 (
  220.         lossyWAV %loc_input% -%enc_cust_lossyWAVpreset_char% -o ".\temp\" -below -nowarn -force -snr %enc_cust_signalnoiseratio_int% -nts %enc_cust_noisethresholdshift_float% -noclips
  221.     ) ELSE (
  222.         lossyWAV %loc_input% -%enc_cust_lossyWAVpreset_char% -o ".\temp\" -below -nowarn -force -snr %enc_cust_signalnoiseratio_int% -nts %enc_cust_noisethresholdshift_float%
  223.     )
  224. )
  225. flac -%enc_cust_flacquality_int% -o %loc_encode_flac_outputlossy_fullpathfile% %enc_cust_flacoptions_string% %loc_encode_flac_inputlossy_fromtemp%
  226. IF %enc_cust_createcorrectionfile_bool%==1 flac -%enc_cust_flacquality_int% -o %loc_encode_flac_outputlwcdf_fullpathfile% %enc_cust_flacoptions_string% %loc_encode_flac_inputlwcdf_fromtemp%
  227. IF EXIST .\temp\*.wav DEL /F /Q .\temp\*.wav
  228. GOTO exit
  229. :enc_c_il
  230. echo Warning: lFLC.bat has a saftey feature to prevent processing of
  231. echo          files that have ".lossy.wav" extensions even when they
  232. echo          do not have lossyWAV metadata.  This is to prevent the
  233. echo          double-processing of legacy lossyWAV files.
  234. echo.
  235. echo          Your WAV file will now be encoded to FLAC anyways,
  236. echo          but a correction file will not be generated.
  237. echo.
  238. GOTO enc_c_fl
  239. :enc_c_hc
  240. IF %enc_cust_createcorrectionfile_bool%==1 (
  241.     echo Warning: lossyWAV does not process files that are already lossy.
  242.     echo          Your lossy WAV file will now be encoded to FLAC anyways,
  243.     echo          but a correction file cannot be generated.
  244.     echo.
  245. ) ELSE (
  246.     echo Warning: lossyWAV does not process files that are already lossy.
  247.     echo          Your lossy WAV file will now be encoded to FLAC anyways.
  248.     echo.
  249. )
  250. :enc_c_fl
  251. SET loc_temp1="%loc_input:~-11%"
  252. IF "%loc_temp1:~1,-2%"==".lossy.wav" (
  253.     SET loc_encode_flac_outputalreadylossy_fullpathfile="%~dpnx3"
  254.     SET loc_encode_flac_inputlwcdf_fromsource_fullpathfile="%loc_input:~1,-11%.lwcdf.wav"
  255.     SET loc_encode_flac_outputlwcdf_fullpathfile="%loc_output:~1,-12%.lwcdf.flac"
  256. ) ELSE (
  257.     SET loc_encode_flac_outputalreadylossy_fullpathfile="%~dpn3.lossy%~x3"
  258.     SET loc_encode_flac_inputlwcdf_fromsource_fullpathfile="%~dpn4.lwcdf%~x4"
  259. )
  260. flac -%enc_cust_flacquality_int% -o %loc_encode_flac_outputalreadylossy_fullpathfile% %enc_cust_flacoptions_string% %loc_input%
  261. IF EXIST %loc_encode_flac_inputlwcdf_fromsource_fullpathfile% (
  262.     flac -%enc_cust_flacquality_int% -o %loc_encode_flac_outputlwcdf_fullpathfile% %enc_cust_flacoptions_string% %loc_encode_flac_inputlwcdf_fromsource_fullpathfile%
  263. )
  264. IF EXIST .\temp\*.wav DEL /F /Q .\temp\*.wav
  265. GOTO exit
  266.  
  267. :exit
  268. exit
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement