Wii SDF to playable GENH

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

Wii SDF to playable GENH

Post by AlphaTwentyThree »

Hi folks,

this is no request, I just wanted to post my little conversion script here. I found several Wii games that use sdf as audio format, which is currently unsupported. The following script converts these files to something playable.
This could also be a template for a generic script.
Have fun! :)

Code: Select all

# converts Wii SDF audio files to playable GENH streams
# written by AlphaTwentyThree of Zenhax
# script for QuickBMS http://quickbms.aluigi.org

idstring "SDF"
set OFFSET 0x84
set OFF_COEFF1 0x28
set OFF_COEFF2 0x56
set OFF_NOS 0x20
set OFF_FREQ 0x10
set OFF_CH 0x14
set OFF_INTERLEAVE 0x18
set REVERSE 1

goto OFF_NOS
get NOS long
goto OFF_FREQ
get FREQ long
goto OFF_CH
get CH byte
goto OFF_INTERLEAVE
get INTERLEAVE long

get SIZE asize
math SIZE -= OFFSET
xmath PRE_SIZE "SIZE + 0xc0"
putVarChr MEMORY_FILE SIZE 0
log MEMORY_FILE 0 0

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"
if REVERSE == 1
   callfunction rev
endif
log NAME 0 SIZE MEMORY_FILE

startfunction rev
   goto 0x80 MEMORY_FILE
   for i = 1 <= 32
      savepos OFF MEMORY_FILE
      get DUMMY short MEMORY_FILE
      reverseshort DUMMY
      putVarChr MEMORY_FILE OFF DUMMY short
   next i
endfunction
Mygoshi
Posts: 654
Joined: Mon Oct 27, 2014 1:49 pm

Re: Wii SDF to playable GENH

Post by Mygoshi »

Very useful, thanks!
Last edited by Mygoshi on Wed Feb 17, 2021 8:23 pm, edited 3 times in total.
AnonBaiter
Posts: 1125
Joined: Tue Feb 02, 2016 2:35 am

Re: Wii SDF to playable GENH

Post by AnonBaiter »

Welcome back, AlphaTwentyThree!