[Script] RIFX dsp to GENH

Codecs, formats, encoding/decoding of game audio, video and music
AlphaTwentyThree
Posts: 909
Joined: Sat Aug 09, 2014 11:21 am

[Script] RIFX dsp to GENH

Post by AlphaTwentyThree »

Apparently I'm on fire right now because I finally figured out how to properly deal with GC_ADPCM. ;)
This script converts RIFX-headered gcadpcm streams to playable genh files. :)

Code: Select all

# converts RIFX header files with GCADPCM stream to playable GENH
# written by AlphaTwentyThree of Zenhax
# script 1.01
# script for QuickBMS http://quickbms.aluigi.org

idstring "RIFX"
endian big
get RSIZE long
idstring "WAVEfmt "
get BSIZE long
savepos MYOFF
get CODEC short
if CODEC == 2
   set INTERLEAVE 8
else
   set INTERLEAVE 4
endif
get CH short
get FREQ long
get UNK long
get UNK short
get BITS short
get UNK longlong
get NOS long
savepos TEMP

set Wii_Area 0
for
   math MYOFF += BSIZE
   goto MYOFF
   getDstring IDENT 4
   get BSIZE long
   savepos MYOFF
   if IDENT == "smpl"
      get NAME basename
      string NAME += ".smpl"
      log NAME MYOFF BSIZE
   elif IDENT == "WiiH"
   set Wii_Area 1
      set OFF_COEFF1 MYOFF
      getDstring COEFF1 0x20
      getDstring DUMMY 0xe
      savepos OFF_COEFF2
      getDstring COEFF2 0x20
      getDstring DUMMY 0xe
   elif IDENT == "data"
      set OFFSET MYOFF
      set SIZE BSIZE
      break
   else # do nothing, just skip, e.g. JUNK
   endif
next
if Wii_Area == 0
   goto TEMP
   set OFF_COEFF1 TEMP
   getDstring COEFF1 0x20
   getDstring DUMMY 0xe
    savepos OFF_COEFF2
    getDstring COEFF2 0x20
    getDstring DUMMY 0xe
endif

xmath PRE_SIZE "SIZE + 0xc0"
putVarChr MEMORY_FILE SIZE 0
log MEMORY_FILE 0 0

endian little
putVarChr MEMORY_FILE 0 0x484e4547 long # "GENH"
putVarChr MEMORY_FILE 4 CH long # ch
putVarChr MEMORY_FILE 8 INTERLEAVE long # interleave
putVarChr MEMORY_FILE 0xc FREQ long
putVarChr MEMORY_FILE 0x10 0xffffffff long
putVarChr MEMORY_FILE 0x14 NOS long # number of samples
putVarChr MEMORY_FILE 0x18 0xc long # ?
putVarChr MEMORY_FILE 0x1c 0xc0 long # stream start
putVarChr MEMORY_FILE 0x20 0xc0 long # stream start
putVarChr MEMORY_FILE 0x24 0x80 long # coeff1
putVarChr MEMORY_FILE 0x28 0xa0 long # coeff2
putVarChr MEMORY_FILE 0x2c 1 long
putVarChr MEMORY_FILE 0x34 0x80 long # coeff1
putVarChr MEMORY_FILE 0x38 0xa0 long # coeff2
putVarChr MEMORY_FILE 0x7f 0 byte
append
log MEMORY_FILE OFF_COEFF1 0x20
log MEMORY_FILE OFF_COEFF2 0x20
log MEMORY_FILE OFFSET SIZE
append
get SIZE asize MEMORY_FILE
get NAME basename
string NAME += ".genh"
log NAME 0 SIZE MEMORY_FILE
AlphaTwentyThree
Posts: 909
Joined: Sat Aug 09, 2014 11:21 am

Re: [Script] RIFX dsp to GENH

Post by AlphaTwentyThree »

Just updated the script to support two other variants! :)