Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- @echo off
- :: header text
- echo -----------------------------------------------------------
- echo lFLC.bat for lFLCDrop v1.0.0.7 by JesseG
- echo -----------------------------------------------------------
- echo.
- :: ********************************************
- :: *** CUSTOM SETTINGS CAN BE TWEAKED BELOW ***
- :: encoding settings
- SET enc_cust_lossyWAVpreset_char=2
- SET enc_cust_createcorrectionfile_bool=1
- SET enc_cust_signalnoiseratio_int=21
- SET enc_cust_noisethresholdshift_float=0.0
- SET enc_cust_noclips_bool=0
- SET enc_cust_flacquality_int=5
- SET enc_cust_flacoptions_string=-b 512 --keep-foreign-metadata -f
- :: decoding settings (effects ALL frontend presets)
- SET dec_cust_decodecorrectionfile_bool=1
- SET dec_cust_mergecorrectionfile_bool=1
- SET dec_cust_deleteunmergedwavs_bool=1
- :: *** CUSTOM SETTINGS CAN BE TWEAKED ABOVE ***
- :: ********************************************
- :: NOTES:
- :: 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
- :: ********************************************
- :: *************************************************
- :: *** DO NOT MESS WITH ANYTHING BELOW THIS LINE ***
- :: *** UNLESS YOU REALLY KNOW WHAT YOU ARE DOING ***
- :: *************************************************
- :: check for needed files & folders
- IF NOT EXIST .\temp\ MKDIR .\temp
- IF NOT EXIST .\lossyWAV.exe GOTO err_mis1
- IF NOT EXIST .\flac.exe GOTO err_mis2
- :: commandline variable error detection
- IF '%1'=='' GOTO err_par1
- IF '%2'=='' GOTO err_par1
- IF '%3'=='' GOTO err_par1
- IF '%4'=='' GOTO err_par1
- :: import commandline variables
- SET qualitypreset=%1
- SET outputflag=%2
- SET loc_output=%3
- SET loc_input=%4
- SET loc_encode_flac_inputlossy_fromtemp=".\temp\%~n4.lossy%~x4"
- SET loc_encode_flac_inputlwcdf_fromtemp=".\temp\%~n4.lwcdf%~x4"
- SET loc_encode_flac_outputlossy_fullpathfile="%~dpn3.lossy%~x3"
- SET loc_encode_flac_outputlwcdf_fullpathfile="%~dpn3.lwcdf%~x3"
- SET loc_decode_flac_display_nameextension="%~nx4"
- SET loc_decode_destination_fullpath="%~dp3"
- SET loc_decode_lwcdf_fullpathfile_FLAC="%loc_output:~1,-11%.lwcdf.flac"
- SET loc_decode_lwcdf_fullpathfile_WAV="%loc_output:~1,-11%.lwcdf.wav"
- SET loc_decode_lossy_fullpathfile_WAV="%loc_output:~1,-11%.lossy.wav"
- :: encode/decode
- IF '%qualitypreset%'=='-d' GOTO decode
- GOTO encode
- :: error handlers
- :err_par1
- echo Error: unable to parse the correct command line variables.
- pause
- GOTO exit
- :err_mis1
- echo Error: lossyWAV.exe not found. Check readme.txt for instructions.
- pause
- GOTO exit
- :err_mis2
- echo Error: flac.exe not found. Check readme.txt for instructions.
- pause
- GOTO exit
- :err_e1hc
- echo Warning: lossyWAV does not process files that are already lossy.
- echo Your lossy WAV file will now be encoded to FLAC anyways,
- echo but a correction file cannot be generated.
- echo.
- GOTO enc_flac
- :err_e1lw
- echo Warning: lFLC.bat has a saftey feature to prevent processing of
- echo files that have ".lossy.wav" extensions even when they
- echo do not have lossyWAV metadata. This is to prevent the
- echo double-processing of legacy lossyWAV files.
- echo.
- echo Your WAV file will now be encoded to FLAC anyways,
- echo but a correction file will not be generated.
- echo.
- GOTO enc_flac
- :err_d_n1
- echo Error while attempting to merge lossyWAV:
- echo Correction file does not exist.
- echo Set "dec_cust_decodecorrectionfile_bool" to 1 in lFLC.bat or
- echo set "dec_cust_mergecorrectionfile_bool" to 0 in lFLC.bat
- echo.
- GOTO dec_end
- :err_d_n2
- echo Error while attempting to merge legacy lossyWAV:
- echo Correction file does not exist.
- echo.
- GOTO dec_end
- :decode
- echo Decoding:
- echo %loc_decode_flac_display_nameextension%
- echo.
- flac -d -f --keep-foreign-metadata --decode-through-errors --totally-silent %loc_input%
- IF ERRORLEVEL==1 GOTO dec_nomd
- lossyWAV %loc_output% -check -quiet -nowarn
- IF NOT ERRORLEVEL 16 GOTO dec_nolw
- IF %dec_cust_decodecorrectionfile_bool%==1 (
- IF EXIST %loc_decode_lwcdf_fullpathfile_FLAC% (
- flac -d -f --keep-foreign-metadata --decode-through-errors --totally-silent %loc_decode_lwcdf_fullpathfile_FLAC%
- )
- )
- IF %dec_cust_mergecorrectionfile_bool%==1 (
- IF EXIST %loc_decode_lwcdf_fullpathfile_WAV% (
- lossyWAV %loc_output% -merge -o %loc_decode_destination_fullpath%
- ) ELSE GOTO err_d_n1
- IF "%dec_cust_deleteunmergedwavs_bool%"=="1" (
- DEL /F /Q %loc_decode_lossy_fullpathfile_WAV%
- DEL /F /Q %loc_decode_lwcdf_fullpathfile_WAV%
- )
- )
- GOTO dec_end
- :dec_nomd
- flac -d -f --decode-through-errors --totally-silent %loc_input%
- :dec_nolw
- IF %dec_cust_decodecorrectionfile_bool%==1 (
- IF EXIST %loc_decode_lwcdf_fullpathfile_FLAC% (
- flac -d -f --keep-foreign-metadata --decode-through-errors --totally-silent %loc_decode_lwcdf_fullpathfile_FLAC%
- IF ERRORLEVEL==1 GOTO dec_cnmd
- )
- )
- GOTO dec_cmrg
- :dec_cnmd
- flac -d -f --decode-through-errors --totally-silent %loc_decode_lwcdf_fullpathfile_FLAC%
- :dec_cmrg
- SET loc_temp1="%loc_input:~-11%"
- IF NOT "%loc_temp1:~1,-2%"==".lossy.flac" GOTO dec_end
- IF %dec_cust_mergecorrectionfile_bool%==1 (
- IF EXIST %loc_decode_lwcdf_fullpathfile_WAV% (
- lossyWAV %loc_output% -merge -o %loc_decode_destination_fullpath%
- ) ELSE GOTO err_d_n2
- IF "%dec_cust_deleteunmergedwavs_bool%"=="1" (
- DEL /F /Q %loc_decode_lossy_fullpathfile_WAV%
- DEL /F /Q %loc_decode_lwcdf_fullpathfile_WAV%
- )
- )
- GOTO dec_end
- :dec_end
- GOTO exit
- :encode
- IF EXIST .\temp\*.wav DEL /F /Q .\temp\*.wav
- IF '%qualitypreset%'=='-1' GOTO encode_1
- IF '%qualitypreset%'=='-2' GOTO encode_1
- IF '%qualitypreset%'=='-3' GOTO encode_1
- IF '%qualitypreset%'=='-4' GOTO encode_1
- IF '%qualitypreset%'=='-5' GOTO encode_1
- IF '%qualitypreset%'=='-6' GOTO encode_1
- IF '%qualitypreset%'=='-7' GOTO encode_1
- IF '%qualitypreset%'=='-8' GOTO enc_cust
- GOTO err_par1
- :encode_1
- lossyWAV %loc_input% -check -quiet -nowarn
- IF ERRORLEVEL 16 IF NOT ERRORLEVEL 17 GOTO err_e1hc
- SET loc_temp1="%loc_input:~-11%"
- IF "%loc_temp1:~1,-2%"==".lossy.wav" GOTO err_e1lw
- lossyWAV %loc_input% %qualitypreset% -o ".\temp\" -below -nowarn -force -correction
- flac -5 -o %loc_encode_flac_outputlossy_fullpathfile% -f -b 512 --keep-foreign-metadata %loc_encode_flac_inputlossy_fromtemp%
- flac -5 -o %loc_encode_flac_outputlwcdf_fullpathfile% -f -b 512 --keep-foreign-metadata %loc_encode_flac_inputlwcdf_fromtemp%
- IF EXIST .\temp\*.wav DEL /F /Q .\temp\*.wav
- GOTO exit
- :enc_flac
- SET loc_temp1="%loc_input:~-11%"
- IF "%loc_temp1:~1,-2%"==".lossy.wav" (
- SET loc_encode_flac_outputalreadylossy_fullpathfile="%~dpnx3"
- SET loc_encode_flac_inputlwcdf_fromsource_fullpathfile="%loc_input:~1,-11%.lwcdf.wav"
- SET loc_encode_flac_outputlwcdf_fullpathfile="%loc_output:~1,-12%.lwcdf.flac"
- ) ELSE (
- SET loc_encode_flac_outputalreadylossy_fullpathfile="%~dpn3.lossy%~x3"
- SET loc_encode_flac_inputlwcdf_fromsource_fullpathfile="%~dpn4.lwcdf%~x4"
- )
- flac -5 -o %loc_encode_flac_outputalreadylossy_fullpathfile% -f -b 512 --keep-foreign-metadata %loc_input%
- IF EXIST %loc_encode_flac_inputlwcdf_fromsource_fullpathfile% (
- flac -5 -o %loc_encode_flac_outputlwcdf_fullpathfile% -f -b 512 --keep-foreign-metadata %loc_encode_flac_inputlwcdf_fromsource_fullpathfile%
- )
- IF EXIST .\temp\*.wav DEL /F /Q .\temp\*.wav
- GOTO exit
- :enc_cust
- :: ***********************************
- :: *** CUSTOM ENCODING SECTION ***
- :: ***********************************
- lossyWAV %loc_input% -check -quiet -nowarn
- IF ERRORLEVEL 16 IF NOT ERRORLEVEL 17 GOTO enc_c_hc
- SET loc_temp1="%loc_input:~-11%"
- IF "%loc_temp1:~1,-2%"==".lossy.wav" GOTO enc_c_il
- IF %enc_cust_createcorrectionfile_bool%==1 (
- IF %enc_cust_noclips_bool%==1 (
- lossyWAV %loc_input% -%enc_cust_lossyWAVpreset_char% -o ".\temp\" -below -nowarn -force -snr %enc_cust_signalnoiseratio_int% -nts %enc_cust_noisethresholdshift_float% -noclips -correction
- ) ELSE (
- lossyWAV %loc_input% -%enc_cust_lossyWAVpreset_char% -o ".\temp\" -below -nowarn -force -snr %enc_cust_signalnoiseratio_int% -nts %enc_cust_noisethresholdshift_float% -correction
- )
- ) ELSE (
- IF %enc_cust_noclips_bool%==1 (
- lossyWAV %loc_input% -%enc_cust_lossyWAVpreset_char% -o ".\temp\" -below -nowarn -force -snr %enc_cust_signalnoiseratio_int% -nts %enc_cust_noisethresholdshift_float% -noclips
- ) ELSE (
- lossyWAV %loc_input% -%enc_cust_lossyWAVpreset_char% -o ".\temp\" -below -nowarn -force -snr %enc_cust_signalnoiseratio_int% -nts %enc_cust_noisethresholdshift_float%
- )
- )
- flac -%enc_cust_flacquality_int% -o %loc_encode_flac_outputlossy_fullpathfile% %enc_cust_flacoptions_string% %loc_encode_flac_inputlossy_fromtemp%
- 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%
- IF EXIST .\temp\*.wav DEL /F /Q .\temp\*.wav
- GOTO exit
- :enc_c_il
- echo Warning: lFLC.bat has a saftey feature to prevent processing of
- echo files that have ".lossy.wav" extensions even when they
- echo do not have lossyWAV metadata. This is to prevent the
- echo double-processing of legacy lossyWAV files.
- echo.
- echo Your WAV file will now be encoded to FLAC anyways,
- echo but a correction file will not be generated.
- echo.
- GOTO enc_c_fl
- :enc_c_hc
- IF %enc_cust_createcorrectionfile_bool%==1 (
- echo Warning: lossyWAV does not process files that are already lossy.
- echo Your lossy WAV file will now be encoded to FLAC anyways,
- echo but a correction file cannot be generated.
- echo.
- ) ELSE (
- echo Warning: lossyWAV does not process files that are already lossy.
- echo Your lossy WAV file will now be encoded to FLAC anyways.
- echo.
- )
- :enc_c_fl
- SET loc_temp1="%loc_input:~-11%"
- IF "%loc_temp1:~1,-2%"==".lossy.wav" (
- SET loc_encode_flac_outputalreadylossy_fullpathfile="%~dpnx3"
- SET loc_encode_flac_inputlwcdf_fromsource_fullpathfile="%loc_input:~1,-11%.lwcdf.wav"
- SET loc_encode_flac_outputlwcdf_fullpathfile="%loc_output:~1,-12%.lwcdf.flac"
- ) ELSE (
- SET loc_encode_flac_outputalreadylossy_fullpathfile="%~dpn3.lossy%~x3"
- SET loc_encode_flac_inputlwcdf_fromsource_fullpathfile="%~dpn4.lwcdf%~x4"
- )
- flac -%enc_cust_flacquality_int% -o %loc_encode_flac_outputalreadylossy_fullpathfile% %enc_cust_flacoptions_string% %loc_input%
- IF EXIST %loc_encode_flac_inputlwcdf_fromsource_fullpathfile% (
- flac -%enc_cust_flacquality_int% -o %loc_encode_flac_outputlwcdf_fullpathfile% %enc_cust_flacoptions_string% %loc_encode_flac_inputlwcdf_fromsource_fullpathfile%
- )
- IF EXIST .\temp\*.wav DEL /F /Q .\temp\*.wav
- GOTO exit
- :exit
- exit
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement