XeNTaX Forum Index
Forum MultiEx Commander Tools Tools Home
It is currently Fri Dec 15, 2017 7:39 am

All times are UTC + 1 hour




Post new topic Reply to topic  [ 469 posts ]  Go to page Previous  1, 2, 3, 4, 5, 6 ... 32  Next
Author Message
 Post subject: Re: My quickBMS scripts
PostPosted: Thu Jul 22, 2010 2:44 pm 
Offline
double-veteran
double-veteran

Joined: Mon Aug 24, 2009 10:55 pm
Posts: 984
Has thanked: 76 times
Have thanks: 598 times

XA_deinterleave.bms
Many Playstation games have interleaved XA files to save their music. Each interleaved XA file consists of exactly 8 or 16 layers (will need to add support). Each layer starts with [00FFFFFFFFFFFFFFFFFFFF001430][number byte][02][01][layer number byte][audio designator byte][01]. If the file is stereo, the last dword is repeated. The file interleave is always 0x930, that's the distance to each [00FFFFFFFFFFFFFFFFFFFF001430]-block. The audio designator is 0x64 if audio is present and 0x00 if the layer is empty. In this case the layer number is also 0x00. That's one of the reasons why PSX images are highly compressable. ;)
Each of the block headers stays intact inside the stream. If a stream is finished, the last block has either the audio designator 0xE4 and all subsequent blocks have 0x48 OR the last block is normal (0x64) and all subsequent blocks have 0x00 as designator.
In some cases (take Descent II PSX for example), the track end isn't designated at all but the last few ms of the track are repeated till the end of the layer. I haven't yet found a way to cut these file correctly.
The following script deinterleaves those streams, cuts each stream at a given stop designator and adds a CDXA header. The files are playable with in_vgmstream.dll (newest release). Currently there is no "empty layer" support yet, but I'll code that later. If there's some header present before the [00FFFFFFFFFFFFFFFFFFFF001430]-block, just adjust the HEADER variable.
Code:
set HEADER 0
set INTERL 0x930
set LAYERS 8
set JUMP INTERL
math JUMP *= LAYERS
get FSIZE asize
for i = 1 <= LAYERS
    log MEMORY_FILE 0 0
    set MEMORY_FILE binary "\x52\x49\x46\x46\xe4\x04\xbe\x02\x43\x44\x58\x41\x66\x6d\x74\x20\x10\x0\x0\x0\x0\x0\x0\x0\x1\x55\x58\x41\x1\x0\x0\x0\x0\x0\x0\x0\x64\x61\x74\x61\xc0\x4\xbe\x2"
    set OFFSET i
    math OFFSET -= 1
    math OFFSET *= INTERL
    math OFFSET += HEADER
    set QUIT 0
    append
    for
        set CHECK OFFSET
        math CHECK += 0x12
        goto CHECK
        get DAT byte # audio marker
    if DAT == 0x48
        set QUIT 1
        elif DAT == 0xE4
        set QUIT 2
    elif DAT == 0
        set QUIT 1
        endif
        set TEST OFFSET
        math TEST += INTERL
        if TEST == FSIZE
        set QUIT 2
        endif
        if QUIT == 0
        log MEMORY_FILE OFFSET INTERL
        math OFFSET += JUMP
        elif QUIT == 2
        log MEMORY_FILE OFFSET INTERL
        break
        elif QUIT == 1
        break
        endif
    next
    append
    get SIZE asize MEMORY_FILE
    set RIFFSIZE SIZE
    math RIFFSIZE -= 8
    set DSIZE SIZE
    math DSIZE -= 0x2c
    putVarChr MEMORY_FILE 0x04 RIFFSIZE long
    putVarChr MEMORY_FILE 0x28 DSIZE long
    get NAME basename
    string NAME += "_"
    string NAME += i
    string NAME += ".xa"
    log NAME 0 SIZE MEMORY_FILE
next i


You can make the ads go away by registering


_________________
If you like what you see, why not click the little Thank You button? ;) It will definitely motivate me! :)
And here's Mr.Mouse's Facebook link: http://www.facebook.com/permalink.php?s ... 8469022795 - thanks ;)


Last edited by AlphaTwentyThree on Mon Oct 04, 2010 1:25 pm, edited 7 times in total.

Top
 Profile  
 
 Post subject: Re: My quickBMS scripts
PostPosted: Thu Jul 22, 2010 4:38 pm 
Offline
beginner
User avatar

Joined: Tue Jul 13, 2010 3:23 pm
Posts: 32
Has thanked: 6 times
Have thanks: 0 time
Thanks you for this great scripts!
In EA *.mus extractor, how can i join segments which belong together?


Last edited by RedDeadRedemption on Thu Jul 22, 2010 6:21 pm, edited 1 time in total.

Top
 Profile  
 
 Post subject: Re: My quickBMS scripts
PostPosted: Thu Jul 22, 2010 5:59 pm 
Offline
double-veteran
double-veteran

Joined: Mon Aug 24, 2009 10:55 pm
Posts: 984
Has thanked: 76 times
Have thanks: 598 times
RedDeadRedemption wrote:
Thanks you for this great script.
But how can i join segments which belong together?

1. please shorten your message ;)
2. simple answer: Manually ;) I deliberately left it open because it's a matter of taste how to join the segments. You could just use Winamp's DiskWriter plugin for example.

_________________
If you like what you see, why not click the little Thank You button? ;) It will definitely motivate me! :)
And here's Mr.Mouse's Facebook link: http://www.facebook.com/permalink.php?s ... 8469022795 - thanks ;)


Top
 Profile  
 
 Post subject: Re: My quickBMS scripts
PostPosted: Fri Jul 23, 2010 8:57 am 
Offline
beginner
User avatar

Joined: Tue Jul 13, 2010 3:23 pm
Posts: 32
Has thanked: 6 times
Have thanks: 0 time
Another question.
in addXMARIFFheader.bms, I have to try different Channels and Sample rates to find the exact one. How can i guess exact and correct Channels and sample rate of a xma file before decoding it?


Top
 Profile  
 
 Post subject: Re: My quickBMS scripts
PostPosted: Fri Jul 23, 2010 2:09 pm 
Offline
double-veteran
double-veteran

Joined: Mon Aug 24, 2009 10:55 pm
Posts: 984
Has thanked: 76 times
Have thanks: 598 times
You actually can't distinguish between the different sample rates of headerless XMA files from seeing the code. The only thing that's reliable: if toWAV doesn't decode the file correctly, it's probably the wrong sample rate or number of channels. However, toWAV doesn't seem to distinguish between 44,100 Hz and 48,000 Hz as it decodes both variants without errors. Either you search for a soundtrack, downloadable tracks from the composer's page or some other hint among the other files via hex editor. In many cases the XMA stream has a small header that states the sample rate. But be sure to cut that portion first before adding a header.

_________________
If you like what you see, why not click the little Thank You button? ;) It will definitely motivate me! :)
And here's Mr.Mouse's Facebook link: http://www.facebook.com/permalink.php?s ... 8469022795 - thanks ;)


Top
 Profile  
 
 Post subject: Re: My quickBMS scripts
PostPosted: Mon Jul 26, 2010 9:56 pm 
Offline
advanced

Joined: Mon Dec 14, 2009 5:41 pm
Posts: 47
Has thanked: 0 time
Have thanks: 0 time
The contents of this post was deleted because of possible forum rules violation.


Top
 Profile  
 
 Post subject: Re: My quickBMS scripts
PostPosted: Tue Jul 27, 2010 1:42 pm 
Offline
double-veteran
double-veteran

Joined: Mon Aug 24, 2009 10:55 pm
Posts: 984
Has thanked: 76 times
Have thanks: 598 times
The contents of this post was deleted because of possible forum rules violation.

_________________
If you like what you see, why not click the little Thank You button? ;) It will definitely motivate me! :)
And here's Mr.Mouse's Facebook link: http://www.facebook.com/permalink.php?s ... 8469022795 - thanks ;)


Top
 Profile  
 
 Post subject: Re: My quickBMS scripts
PostPosted: Tue Jul 27, 2010 2:05 pm 
Offline
advanced

Joined: Mon Dec 14, 2009 5:41 pm
Posts: 47
Has thanked: 0 time
Have thanks: 0 time
Would you like me to upload some of the bnk so you can update that extractor script to get filenames?


Top
 Profile  
 
 Post subject: Re: My quickBMS scripts
PostPosted: Tue Jul 27, 2010 7:41 pm 
Offline
double-veteran
double-veteran

Joined: Mon Aug 24, 2009 10:55 pm
Posts: 984
Has thanked: 76 times
Have thanks: 598 times
Barnaby wrote:
Would you like me to upload some of the bnk so you can update that extractor script to get filenames?
Nope, already downloaded the image file. ;)

_________________
If you like what you see, why not click the little Thank You button? ;) It will definitely motivate me! :)
And here's Mr.Mouse's Facebook link: http://www.facebook.com/permalink.php?s ... 8469022795 - thanks ;)


Top
 Profile  
 
 Post subject: Re: My quickBMS scripts
PostPosted: Mon Aug 09, 2010 12:29 pm 
Offline
double-veteran
double-veteran

Joined: Mon Aug 24, 2009 10:55 pm
Posts: 984
Has thanked: 76 times
Have thanks: 598 times
extract_spk.bms
Extracts the *.spk sound archives from Splinter Cell: Conviction. Works on both PC and Xbox 360 version. :)
Code:
get BNAME basename
string BNAME += "_"
FindLoc DAT string \x02\x23\x00\x08 0 "" # data start (= offset correction)
set FILES DAT
math FILES -= 0x40
math FILES /= 8
goto 0x40
set OFFSET DAT
for i = 1 <= FILES
   get DUMMY long
   get SIZE long
   set NAME BNAME
   string NAME += i
   log NAME OFFSET SIZE
   math OFFSET += SIZE
next i
Note 1: To convert the files of the PC version further, use Zench's DecUbiSnd tool.
Note 2: To convert the Xbox 360 files, use PoP360XMA (from this forum), rebuild the XMA2 stream, add an XMA header and decode them with toWAV.

_________________
If you like what you see, why not click the little Thank You button? ;) It will definitely motivate me! :)
And here's Mr.Mouse's Facebook link: http://www.facebook.com/permalink.php?s ... 8469022795 - thanks ;)


Top
 Profile  
 
 Post subject: Re: My quickBMS scripts
PostPosted: Wed Aug 18, 2010 12:24 am 
Offline
double-veteran
double-veteran

Joined: Mon Aug 24, 2009 10:55 pm
Posts: 984
Has thanked: 76 times
Have thanks: 598 times
addInterleavedPCM.bms
Adds an adjustable Interleaved PCM header to a headerless file. Playable with vgmstream afterwards. Those files are mostly the audio of PS2 movies. It's a variant of uncompressed PCM and can be transformed to non-interleaved PCM (e.g. with Winamp's DiscWriter plugin). The format itself is of course uncompressed.

Code:
set MEMORY_FILE binary "\x53\x53\x68\x64\x18\x0\x0\x0\x1\x0\x0\x0\x80\xbb\x0\x0\x2\x0\x0\x0\x0\x2\x0\x0\xff\xff\xff\xff\xff\xff\xff\xff\x53\x53\x62\x64\x0\x14\xf0\x0"

set FREQ 44100
set CH 2

get SIZE asize
get NAME basename
string NAME += ".ads"
putVarChr MEMORY_FILE 0xc FREQ long
putVarChr MEMORY_FILE 0x10 CH long
putVarChr MEMORY_FILE 0x24 SIZE long
append
log MEMORY_FILE 0 SIZE
append
math SIZE += 0x28
log NAME 0 SIZE MEMORY_FILE

_________________
If you like what you see, why not click the little Thank You button? ;) It will definitely motivate me! :)
And here's Mr.Mouse's Facebook link: http://www.facebook.com/permalink.php?s ... 8469022795 - thanks ;)


Last edited by AlphaTwentyThree on Mon Nov 08, 2010 7:09 am, edited 1 time in total.

Top
 Profile  
 
 Post subject: Re: My quickBMS scripts
PostPosted: Wed Aug 18, 2010 2:32 am 
Offline
double-veteran
double-veteran

Joined: Sun Apr 20, 2008 2:58 am
Posts: 836
Has thanked: 5 times
Have thanks: 32 times
Thanks :)

EDIT: is the interleave adjustable on the ps2 adpcm script?


Top
 Profile  
 
 Post subject: Re: My quickBMS scripts
PostPosted: Fri Aug 20, 2010 1:33 pm 
Offline
double-veteran
double-veteran

Joined: Mon Aug 24, 2009 10:55 pm
Posts: 984
Has thanked: 76 times
Have thanks: 598 times
I'm not entirely sure if the actually is an interleave... Note that this format is different from Playstation ADPCM and occurs for example when you demux *.pss videos with PSSDemux (Zophar's Domain).
If you encounter files you have problems with, let me know and I'll take a look. ;)

_________________
If you like what you see, why not click the little Thank You button? ;) It will definitely motivate me! :)
And here's Mr.Mouse's Facebook link: http://www.facebook.com/permalink.php?s ... 8469022795 - thanks ;)


Top
 Profile  
 
 Post subject: Re: My quickBMS scripts
PostPosted: Mon Sep 06, 2010 1:29 am 
Offline
double-veteran
double-veteran

Joined: Mon Aug 24, 2009 10:55 pm
Posts: 984
Has thanked: 76 times
Have thanks: 598 times
SFD_to_ADX.bms
Demuxes Dreamcast Sofdec videos to a CRI ADX file. Change 448 to 480 and ".adx" to ".mpg" to get the video stream. :)
Code:
get FSIZE asize
endian BIG
set OFFSET 0

append
DO
   goto OFFSET
   get UNKNOWN long
   get UNKNOWN long
   get UNKNOWN long
   get IDENT long
   math OFFSET += 0x1e
   if IDENT == 448
      log MEMORY_FILE OFFSET 0x7e2
   endif
   math OFFSET += 0x7e2
WHILE OFFSET < FSIZE

get NAME basename
string NAME += ".adx"
get SIZE asize MEMORY_FILE
log NAME 0 SIZE MEMORY_FILE

_________________
If you like what you see, why not click the little Thank You button? ;) It will definitely motivate me! :)
And here's Mr.Mouse's Facebook link: http://www.facebook.com/permalink.php?s ... 8469022795 - thanks ;)


Last edited by AlphaTwentyThree on Thu Sep 30, 2010 10:40 pm, edited 1 time in total.

Top
 Profile  
 
 Post subject: Re: My quickBMS scripts
PostPosted: Wed Sep 08, 2010 1:22 pm 
Offline
double-veteran
double-veteran

Joined: Mon Aug 24, 2009 10:55 pm
Posts: 984
Has thanked: 76 times
Have thanks: 598 times
addXboxADPCMheader.bms
Adds an adjustable and toWAV-decodable Xbox ADPCM header to headerless files or skips a given header area (for headers that aren't supported by toWAV). Normally those files have a simple ".wav" extension but you don't want toWAV to overwrite the original files, so I changed it to ".xba" (Xbox audio).
The new revision will adjust the header according to the channels (now also supports mono streams) and can detect the channels automatically. However, this option will only work if the stream doesn't start with a silence but with that 0x????0000 marker.
To find out the stream start and channel count manually, open the file in a hex editor and set the column size to 0x24. If you see a 1-byte zero column, the file is mono, otherwise it's stereo (you can check that by setting the column size to 0x48, there should be two zero columns). A valid stream start is marked by a 0x0000 at the start of the first column.

Code:
# func_header_XADP.bms (ALWAYS KEEP THIS NAME!)
# adds a correct Xbox ADPCM header to any data
# play with vgmstream (errornous!) or decode correctly with towav
# (c) 2012-05-29 by AlphaTwentyThree of XeNTaX

startfunction XADP
   set MEMORY_FILE binary "\x52\x49\x46\x46\x18\x51\xa3\x0\x57\x41\x56\x45\x66\x6d\x74\x20\x14\x0\x0\x0\x69\x0\x2\x0\x44\xac\x0\x0\xcc\xc1\x0\x0\x48\x0\x4\x0\x2\x0\x40\x0\x64\x61\x74\x61\xf0\x50\xa3\x0"
   set RIFFSIZE SIZE
   math RIFFSIZE += 0x28
   putVarChr MEMORY_FILE 0x04 RIFFSIZE long
   putVarChr MEMORY_FILE 0x16 CH byte
   putVarChr MEMORY_FILE 0x18 FREQ long
   set VAR1 0x3073
   math VAR1 *= CH
   if FREQ == 48000
      math VAR1 *= 44100
   else
      math VAR1 *= FREQ
   endif
   math VAR1 /= 22050
   putVarChr MEMORY_FILE 0x1c VAR1 long   
   set VAR2 0x24
   math VAR2 *= CH
   putVarChr MEMORY_FILE 0x20 VAR2 short
   putVarChr MEMORY_FILE 0x2c SIZE long
   append
   log MEMORY_FILE OFFSET SIZE
   append
   if NAME == ""
      get NAME basename
      string NAME += ".lwav"
   endif
   get SIZE asize MEMORY_FILE
   log NAME 0 SIZE MEMORY_FILE
endfunction


Code:
# main script to add an Xbox ADPCM header to a single file.
# includes a function that automatically tests data for channels
# (c) 2012-05-29 by AlphaTwentyThree of XeNTaX

include "func_header_XADP.bms"
set OFFSET 0x0
set FREQ 22050
set CH 2
set TESTV 0 # set to zero to force channels and skip test


if TESTV == 1
   callfunction testXADP 1
endif
get SIZE asize
math SIZE -= OFFSET
callfunction XADP 1
get NAME basename
string NAME += ".xadp"
get SIZE asize MEMORY_FILE
log NAME 0 SIZE MEMORY_FILE

# - determine channels automatically
startfunction testXADP
   set TEST OFFSET
   math TEST += 1
   goto TEST
   get VALID threebyte
   set TEST OFFSET
   math TEST += 0x27
   goto TEST
   get ZEROTEST byte
   if ZEROTEST == 0 # mono
      set CH 1
   else
      math TEST -= 0x20 # goto OFFSET+0x7
      goto TEST
      get ZEROTEST byte
      if ZEROTEST == 0
         set CH 2
      else
         print "ERROR: channels could not be determined!"
      endif
   endif
endfunction



_________________
If you like what you see, why not click the little Thank You button? ;) It will definitely motivate me! :)
And here's Mr.Mouse's Facebook link: http://www.facebook.com/permalink.php?s ... 8469022795 - thanks ;)


Last edited by AlphaTwentyThree on Tue May 29, 2012 12:01 am, edited 2 times in total.

Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 469 posts ]  Go to page Previous  1, 2, 3, 4, 5, 6 ... 32  Next

All times are UTC + 1 hour


Who is online

Users browsing this forum: No registered users and 1 guest


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group