PCM:

ADPCM:




I'm not sure I understand, I've tried the script though I don't think it'll be useful in my hands. I have no idea what to do with it.AlphaTwentyThree wrote:Have you tried all XORs? You can find the script in my big topic. Cut the header first of course. If you have found out the XOR, just use the same script to process the whole file (explanation inside).


Code: Select all
# convert *.wav.ckd audio files from Rayman: Legends
# (c) 2013-08-30 by AlphaTwentyThree of XeNTaX
# script for QuickBMS http://quickbms.aluigi.org
get DUMMY long
idstring "RAKI"
goto 0x10
getDstring TYPE 4
get OFFSET long
FindLoc GO string "data" 0 ""
math GO += 8
goto GO
get SIZE long
get CODEC short
get CH short
get FREQ long
set NAME ""
if TYPE == "pcm "
set BLOCKALIGN 4
set BITS 16
callfunction PCM 1
elif TYPE == "adpc"
set BITS 4
set INTERLEAVE 0x8c
set CODEC 0xb
callfunction GENH 1
endif
startfunction PCM
endian little
set PRE SIZE
math PRE += 0x2c
putVarChr MEMORY_FILE PRE 0
log MEMORY_FILE 0 0
set MEMORY_FILE binary "\x52\x49\x46\x46\x20\xC0\xB1\x00\x57\x41\x56\x45\x66\x6D\x74\x20\x10\x00\x00\x00\x01\x00\x02\x00\x44\xAC\x00\x00\x10\xB1\x02\x00\x04\x00\x10\x00\x64\x61\x74\x61\xFC\xBF\xB1\x00"
append
log MEMORY_FILE OFFSET SIZE
append
set RIFFSIZE SIZE
math RIFFSIZE += 36
set AVGBYTES FREQ
if CODEC != 2
math AVGBYTES *= BLOCKALIGN
endif
putvarchr MEMORY_FILE 0x04 RIFFSIZE long
putvarchr MEMORY_FILE 0x14 CODEC short # wFormatTag: Microsoft PCM Format (0x0001)
putvarchr MEMORY_FILE 0x16 CH short # wChannels
putvarchr MEMORY_FILE 0x18 FREQ short # dwSamplesPerSec
putvarchr MEMORY_FILE 0x1c AVGBYTES long # dwAvgBytesPerSec
putvarchr MEMORY_FILE 0x20 BLOCKALIGN short # wBlockAlign
putvarchr MEMORY_FILE 0x22 BITS short # wBitsPerSample
putvarchr MEMORY_FILE 0x28 SIZE long
if NAME == ""
get NAME basename
string NAME += ".wav"
endif
get SIZE asize MEMORY_FILE
log NAME 0 SIZE MEMORY_FILE
endfunction
startfunction GENH
get FSIZE asize
math FSIZE += 0x1000
putVarChr MEMORY_FILE FSIZE 0
log MEMORY_FILE 0 0
putVarChr MEMORY_FILE 0 0x484e4547 long
putVarChr MEMORY_FILE 0x4 CH long
putVarChr MEMORY_FILE 0x8 INTERLEAVE long
putVarChr MEMORY_FILE 0xc FREQ long
putVarChr MEMORY_FILE 0x10 0xffffffff long
set SAMPLES SIZE
math SAMPLES *= 8
math SAMPLES /= BITS
putVarChr MEMORY_FILE 0x14 SAMPLES long
putVarChr MEMORY_FILE 0x18 CODEC long
math OFFSET += 0x1000
putVarChr MEMORY_FILE 0x1c OFFSET long
putVarChr MEMORY_FILE 0x20 0x1000 long
putVarChr MEMORY_FILE 0x300 FSIZE long
putVarChr MEMORY_FILE 0x304 0x32304756 long
putVarChr MEMORY_FILE 0xfff 0 byte
math FSIZE -= 0x1000
append
log MEMORY_FILE 0 FSIZE
append
get NAME filename
string NAME += ".genh"
get SIZE asize MEMORY_FILE
log NAME 0 SIZE MEMORY_FILE
endfunctionI've tried the script and a few PCM files with different headers wont work with it and only outputs the header made by the script. I've also included a adpcm file that distorts after the audio track plays.AlphaTwentyThree wrote:Ok, found the time to write the script. Had to implement the generic header first.
Try if this works:
Code: Select all
script

Thanks for the quick update, Alpha23. Is it possible for the single channel be copied as the second channel and then made as a pseudo 2ch mono ADPCM GENH temporarily until single channel GENH is supported?AlphaTwentyThree wrote:Corrected the script for PCM files, also corrected the sample calculation for the GENH header and some variable offsets.
However:
The problem with the ADPCM file is that it's MS ADPCM mono, which isn't supported by GENH nor vgmstream. I'm quite at a loss here... If anyone can help I'd be thankful!

Alpha23 do you have to use GENH headers on the ADPCM files because they are actually Microsoft WAV ADPCM files which if headers were applied, could solve the mono issue.AlphaTwentyThree wrote:I'll ask snakemeat first.
Apart from that: I'm not even sure if ms_adpcm even supports mono. And I'm not sure if it's possible to create pseudo-stereo files, but we'll see.

Well, if somebody could tell me how to construct a valid msadpcm header...!!!!! wrote:Alpha23 do you have to use GENH headers on the ADPCM files because they are actually Microsoft WAV ADPCM files which if headers were applied, could solve the mono issue.AlphaTwentyThree wrote:I'll ask snakemeat first.
Apart from that: I'm not even sure if ms_adpcm even supports mono. And I'm not sure if it's possible to create pseudo-stereo files, but we'll see.
