@echo off
rmdir /s /q .\temp
rmdir /s /q .\WAVs
mkdir .\temp
mkdir .\WAVs
cls
echo #####################################
echo # E-mu Drumulator ROM Decoder v0.60 # (Alternate Set 1 ROMs)
echo #####################################
echo.
echo Input files must be Drumulator sound ROM binaries placed within the 
echo [Drumulator_ROMS] folder. All ROMs must have a *.bin file extension!
echo.
echo There must be four sound ROM binaries per kit and must be named as 
echo A111.BIN, B111.BIN, C111.BIN, and D111.BIN exactly.
echo.
echo New WAV files will appear in the WAVS folder when the decoding task 
echo is finished.
echo.
echo Note: 3rd party ROMs often do not have 12 unique instruments sounds, so some 
echo decoded WAVs may be redundant and identical to other instruments. This is 
echo not an error in the decoding process.
echo.
pause
echo.
echo Copying needed files into temp directory for processing...
copy .\[Drumulator_ROMS]\*.* .\temp >NUL
echo.
echo Merging sound ROMs...
copy /B .\temp\A111.BIN + .\temp\B111.BIN + .\temp\C111.BIN + .\temp\D111.BIN .\temp\DRUMUINV.BIN >NUL
echo.
echo Inverting mu-Law values for proper signing...
.\tools\srec_cat .\temp\DRUMUINV.BIN -raw -xor 0xFF -o .\temp\DRUMULAW.RAW -raw
echo.
echo Splitting sound ROM into individual instruments...
rem clave uses closed hi-hat sample
.\tools\sfk partcopy .\temp\DRUMULAW.RAW -fromto 0x99DB 0xA1AD .\temp\CLAVE.RAW -quiet -yes
rem cowbell uses claps sample
.\tools\sfk partcopy .\temp\DRUMULAW.RAW -fromto 0xC3A2 0xD238 .\temp\COWBELL.RAW -quiet -yes
.\tools\sfk partcopy .\temp\DRUMULAW.RAW -fromto 0xC3A2 0xD238 .\temp\CLAPS.RAW -quiet -yes
.\tools\sfk partcopy .\temp\DRUMULAW.RAW -fromto 0xA1AD 0xC38F .\temp\OPENHAT.RAW -quiet -yes
.\tools\sfk partcopy .\temp\DRUMULAW.RAW -fromto 0x99DB 0xA1AD .\temp\CL_HAT.RAW -quiet -yes
.\tools\sfk partcopy .\temp\DRUMULAW.RAW -fromto 0xD238 0xFF6B .\temp\CYMBAL.RAW -quiet -yes
.\tools\sfk partcopy .\temp\DRUMULAW.RAW -fromto 0x0011 0x0CCF .\temp\KICK.RAW -quiet -yes
.\tools\sfk partcopy .\temp\DRUMULAW.RAW -fromto 0x0CCF 0x2DD0 .\temp\SNARE.RAW -quiet -yes
rem rimshot uses snare sample
.\tools\sfk partcopy .\temp\DRUMULAW.RAW -fromto 0x0CCF 0x2DD0 .\temp\RIMSHOT.RAW -quiet -yes
.\tools\sfk partcopy .\temp\DRUMULAW.RAW -fromto 0x2DD0 0x4D91 .\temp\HI_TOM.RAW -quiet -yes
.\tools\sfk partcopy .\temp\DRUMULAW.RAW -fromto 0x4DA4 0x72F6 .\temp\MID_TOM.RAW -quiet -yes
.\tools\sfk partcopy .\temp\DRUMULAW.RAW -fromto 0x72F6 0x99C8 .\temp\LOW_TOM.RAW -quiet -yes
echo.
echo Converting mu-Law to 16-bit WAV...
.\tools\sox\sox.exe -r 22050 -c 1 -e mu-law -t raw .\temp\CLAVE.RAW -b 16 -c 1 -e signed-integer .\WAVS\CLAVE.WAV
.\tools\sox\sox.exe -r 22050 -c 1 -e mu-law -t raw .\temp\COWBELL.RAW -b 16 -c 1 -e signed-integer .\WAVS\COWBELL.WAV
.\tools\sox\sox.exe -r 22050 -c 1 -e mu-law -t raw .\temp\CLAPS.RAW -b 16 -c 1 -e signed-integer .\WAVS\CLAPS.WAV
.\tools\sox\sox.exe -r 22050 -c 1 -e mu-law -t raw .\temp\OPENHAT.RAW -b 16 -c 1 -e signed-integer .\WAVS\OPENHAT.WAV
.\tools\sox\sox.exe -r 22050 -c 1 -e mu-law -t raw .\temp\CL_HAT.RAW -b 16 -c 1 -e signed-integer .\WAVS\CL_HAT.WAV
.\tools\sox\sox.exe -r 22050 -c 1 -e mu-law -t raw .\temp\CYMBAL.RAW -b 16 -c 1 -e signed-integer .\WAVS\CYMBAL.WAV
.\tools\sox\sox.exe -r 22050 -c 1 -e mu-law -t raw .\temp\KICK.RAW -b 16 -c 1 -e signed-integer .\WAVS\KICK.WAV
.\tools\sox\sox.exe -r 22050 -c 1 -e mu-law -t raw .\temp\SNARE.RAW -b 16 -c 1 -e signed-integer .\WAVS\SNARE.WAV
.\tools\sox\sox.exe -r 22050 -c 1 -e mu-law -t raw .\temp\RIMSHOT.RAW -b 16 -c 1 -e signed-integer .\WAVS\RIMSHOT.WAV
.\tools\sox\sox.exe -r 22050 -c 1 -e mu-law -t raw .\temp\HI_TOM.RAW -b 16 -c 1 -e signed-integer .\WAVS\HI_TOM.WAV
.\tools\sox\sox.exe -r 22050 -c 1 -e mu-law -t raw .\temp\MID_TOM.RAW -b 16 -c 1 -e signed-integer .\WAVS\MID_TOM.WAV
.\tools\sox\sox.exe -r 22050 -c 1 -e mu-law -t raw .\temp\LOW_TOM.RAW -b 16 -c 1 -e signed-integer .\WAVS\LOW_TOM.WAV
echo.
echo Process complete.
echo.
pause
rmdir /s /q .\temp