XeNTaX Forum Index
Forum MultiEx Commander Tools Tools Home
It is currently Wed Feb 22, 2017 2:40 pm

All times are UTC + 1 hour




Post new topic Reply to topic  [ 465 posts ]  Go to page Previous  1, 2, 3, 4, 5, 6, 7 ... 31  Next
Author Message
 Post subject: Re: My quickBMS scripts
PostPosted: Thu Sep 09, 2010 5:08 pm 
Offline
double-veteran
double-veteran

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

at3_to_aa3+smpl.bms
Changes an AT3+ (Atrac 3 plus) header to a valid OMA header (*.aa3) and automatically extracts the smpl area if there is one available (that's the loop points). This is the format used by most of the PSP games and seems also common among PS3 games. The resulting files can be decoded by Sony SoundForge or sometimes played by KMPlayer. The *.smpl files may be injected in decoded wave files again with my smpl_inject (link see first post). However the sample transition at3:wav isn't 1:1 so the loop points are biased and only serve as a help when editing tracks. If somebody could help me adjusting the loop points, that'd be awesome! :)

Code:
# at3 to aa3 converter for PSP and PS3
# transforms *.at3 files with codec
# identifier 0xfffe into aa3 (=oma) files
# that are decodable by Sony SoundForge
#
# (c) 2012-09-04 by AlphaTwentyThree of XeNTaX

idstring "RIFF"
get SIZE asize
if SIZE == 0
   cleanexit
endif
goto 0x14
get CODEC short
if CODEC == 624
   cleanexit
endif
goto 0x3c
get INFO long
FindLoc OFFSET string "data" 0 ""
math OFFSET += 4
goto OFFSET
get SIZE long
math SIZE -= 4
get FIRST long
savepos OFFSET
set PSIZE SIZE
math PSIZE += 0x460
putVarChr MEMORY_FILE PSIZE 0
log MEMORY_FILE 0 0
set MEMORY_FILE binary "\x65\x61\x33\x3\x0\x0\x0\x0\x7\x76\x47\x45\x4f\x42\x00\x00\x01\xc6\x00\x00\x02\x62\x69\x6e\x61\x72\x79\x00\x00\x00\x00\x4f\x00\x4d\x00\x47\x00\x5f\x00\x4c\x00\x53\x00\x49\x00\x00\x00\x01\x00\x40\x00\xdc\x00\x70\x00\x08\x00\x00\x00\x00\x00\x00\x4b\x45\x59\x52\x49\x4e\x47"
putVarChr MEMORY_FILE 0x400 0x1334145 long
putVarChr MEMORY_FILE 0x404 0xffff6000 long
putVarChr MEMORY_FILE 0x420 INFO long
putVarChr MEMORY_FILE 0x460 FIRST long
append
log MEMORY_FILE OFFSET SIZE
append
get NAME basename
string NAME += ".aa3"
get SIZE asize MEMORY_FILE
log NAME 0 SIZE MEMORY_FILE

goto 0x5c
getdstring CUE 4
if CUE == "smpl"
   get NAME basename
   string NAME += ".smpl"
   log NAME 0x5c 0x44
endif
goto 0x58
getdstring CUE 4
if CUE == "smpl"
   get NAME basename
   string NAME += ".smpl"
   log NAME 0x58 0x44
endif
goto 0x44
getdstring CUE 4
if CUE == "smpl"
   get NAME basename
   string NAME += ".smpl"
   log NAME 0x58 0x44
endif
goto 0x48
getdstring CUE 4
if CUE == "smpl"
   get NAME basename
   string NAME += ".smpl"
   log NAME 0x58 0x44
endif


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 Tue Sep 04, 2012 12:59 pm, edited 3 times in total.

Top
 Profile  
 
 Post subject: Re: My quickBMS scripts
PostPosted: Tue Sep 14, 2010 9:59 pm 
Offline
double-veteran
double-veteran

Joined: Sun Apr 20, 2008 2:58 am
Posts: 822
Has thanked: 5 times
Have thanks: 29 times
What if the at3 files have no header? i have encountered some of these.

Thanks for the script anyway works great :)


Top
 Profile  
 
 Post subject: Re: My quickBMS scripts
PostPosted: Mon Sep 20, 2010 11:41 pm 
Offline
double-veteran
double-veteran

Joined: Mon Aug 24, 2009 10:55 pm
Posts: 984
Has thanked: 74 times
Have thanks: 587 times
add_aa3_header.bms
Adds a standard aa3 header to a headerless file.

Code:
# adjust format!
# set CODE 0x01002417 # 44100, 1,  32
# set CODE 0x01002422 # 44100, 1,  48
# set CODE 0x0100242E # 44100, 1,  64
# set CODE 0x01002445 # 44100, 1,  96
# set CODE 0x0100245c # 44100, 1, 128
# set CODE 0x0100248B # 44100, 1, 192
# set CODE 0x01002817 # 44100, 2,  32
# set CODE 0x01002822 # 44100, 2,  48
# set CODE 0x0100282E # 44100, 2,  64
# set CODE 0x01002845 # 44100, 2,  96
set CODE 0x0100285C # 44100, 2, 128
# set CODE 0x0100288B # 44100, 2, 192
# set CODE 0x010034E8 # 44100, 6, 320
# set CODE 0x01003573 # 44100, 6, 512
# set CODE 0x01004455 # 48000, 1, 128
# set CODE 0x01004855 # 48000, 2, 128
# set CODE 0x010054AA # 48000, 6, 256
# set CODE 0x010054D5 # 48000, 6, 320
# set CODE 0x010054FF # 48000, 6, 384
# set CODE 0x01005555 # 48000, 6, 512
reverselong CODE

set OFFSET 0x0
set MEMORY_FILE binary "\x65\x61\x33\x3\x0\x0\x0\x0\x7\x76\x47\x45\x4f\x42\x00\x00\x01\xc6\x00\x00\x02\x62\x69\x6e\x61\x72\x79\x00\x00\x00\x00\x4f\x00\x4d\x00\x47\x00\x5f\x00\x4c\x00\x53\x00\x49\x00\x00\x00\x01\x00\x40\x00\xdc\x00\x70\x00\x08\x00\x00\x00\x00\x00\x00\x4b\x45\x59\x52\x49\x4e\x47"
putVarChr MEMORY_FILE 0x400 0x1334145 long
putVarChr MEMORY_FILE 0x404 0xffff6000 long
putVarChr MEMORY_FILE 0x420 CODE long
goto OFFSET
get FIRST long
putVarChr MEMORY_FILE 0x460 FIRST long
savepos DATA
get SIZE asize
math SIZE -= OFFSET
math SIZE -= 4
append
log MEMORY_FILE DATA SIZE
append
get NAME basename
string NAME += ".aa3"
math SIZE += 0x460

log NAME 0 SIZE MEMORY_FILE

Hope that helps, Orange ;)

_________________
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 Sep 21, 2010 1:18 am 
Offline
double-veteran
double-veteran

Joined: Sun Apr 20, 2008 2:58 am
Posts: 822
Has thanked: 5 times
Have thanks: 29 times
Thanks alpha.

However it does not work for a standard stereo 48hz file i tried. Not sure if it has to do with regular atrac3 or atrac3plus. Also this file has a MSF header at the start.

http://www.megaupload.com/?d=PYD76HDL


Top
 Profile  
 
 Post subject: Re: My quickBMS scripts
PostPosted: Fri Sep 24, 2010 10:31 am 
Offline
double-veteran
double-veteran

Joined: Mon Aug 24, 2009 10:55 pm
Posts: 984
Has thanked: 74 times
Have thanks: 587 times
func_header_AT3.bms
This is a header adder function for standard RIFF at (no AT3+).
Note that Atrac files only have 66, 105 or 132 kbps. If you don't know which one of them they have, you'll have to try out, I haven't found a way to distinguish between them. As always, you'll need a headerless file.

Code:
# Add an Atrac RIFF header to data.
# Needed variables: OFFSET, SIZE, BITRATE, FREQ, CH
# Note that mono atrac files are non-standard and automatically saved as stereo.
# To get the original file, decode the stereo at3 to wav and change the channels via hex.
# (c) 2012-07-25 by AlphaTwentyThree of XeNTaX

startfunction AT3
   endian little
   set MEMORY_FILE binary "\x52\x49\x46\x46\x88\xb3\x6d\x0\x57\x41\x56\x45\x66\x6d\x74\x20\x20\x0\x0\x0\x70\x2\x2\x0\x80\xbb\x0\x0\x9a\x40\x0\x0\x80\x1\x0\x0\xe\x0\x1\x0\x0\x10\x0\x0\x0\x0\x0\x0\x1\x0\x0\x0\x66\x61\x63\x74\x8\x0\x0\x0\x91\x81\x24\x1\x1b\x4\x0\x0\x64\x61\x74\x61\x88\xb3\x6d\x0"
   if BITRATE == 66
      putVarChr MEMORY_FILE 0x1c 0x204d long
      putVarChr MEMORY_FILE 0x20 0xc0 long
   elif BITRATE == 105
      putVarChr MEMORY_FILE 0x1c 0x3324 long
      putVarChr MEMORY_FILE 0x20 0x130 long
   elif BITRATE == 132
      putVarChr MEMORY_FILE 0x1c 0x409a long
      putVarChr MEMORY_FILE 0x20 0x180 long
   endif
   set RIFFSIZE SIZE
   math RIFFSIZE += 0x44
   putVarChr MEMORY_FILE 0x04 RIFFSIZE long
   putVarChr MEMORY_FILE 0x18 FREQ long
   putVarChr MEMORY_FILE 0x48 SIZE long
   append
   log MEMORY_FILE OFFSET SIZE
   append
   if NAME == ""
      get NAME basename
      if CH == 1
         set CH 2
         string NAME += "_"
         string NAME += "mono"
      endif
      string NAME += ".at3"
   endif
   putVarChr MEMORY_FILE 0x16 CH byte
   
   get SIZE asize MEMORY_FILE
   log NAME 0 SIZE MEMORY_FILE
endfunction


And as always a sample main:
Code:
include "func_header_AT3.bms"

set FREQ 32000
set CH 2
set OFFSET 0x0
set BITRATE 132

get SIZE asize
math SIZE -= OFFSET
callfunction AT3 1

_________________
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 Wed Jul 25, 2012 7:09 pm, edited 3 times in total.

Top
 Profile  
 
 Post subject: Re: My quickBMS scripts
PostPosted: Fri Sep 24, 2010 10:44 am 
Offline
double-veteran
double-veteran

Joined: Mon Aug 24, 2009 10:55 pm
Posts: 984
Has thanked: 74 times
Have thanks: 587 times
The following two scripts are for transferring the loop points from PSP and PS3 AT3+ files to decoded wave files. Background: AT3+ needs to be traversed into OMA first to decode it with Sony SoundForge which deletes the looping cues. Use the first script to extract the cues from the *.at3 files, then write them to the decoded *.wav files with the second script. It will overwrite the files. Note that the looping cue isn't at the very right spot as I don't know how the AT3 samples are represented in the decoded WAV. It's some ms off, but if it's not at the very beginning of the stream you'll get the idea about where the cue should be.
The second procedurecan also be used to inject a *.smpl file into any wave file with the same name. If that wave file already has a "smpl" are in the header, the script automatically saves the old one as *.smpl_old and substitutes it with the new. :)

at3_smpl_extract.bms
Code:
goto 0x5c
getdstring CUE 4
if CUE == "smpl"
   get NAME basename
   string NAME += ".smpl"
   log NAME 0x5c 0x44
endif
goto 0x58
getdstring CUE 4
if CUE == "smpl"
   get NAME basename
   string NAME += ".smpl"
   log NAME 0x58 0x44
endif
goto 0x44
getdstring CUE 4
if CUE == "smpl"
   get NAME basename
   string NAME += ".smpl"
   log NAME 0x58 0x44
endif
goto 0x48
getdstring CUE 4
if CUE == "smpl"
   get NAME basename
   string NAME += ".smpl"
   log NAME 0x58 0x44
endif

at3_wav_smpl_inject.bms
Code:
open FDDE WAV 0
FindLoc DATA STRING "data" 0 ""

open FDDE SMPL 1 EXISTS
if EXISTS == 0
    print "no sample file available"
    cleanexit
endif
goto 0x58 0
getdstring CUE 4
if CUE == "smpl"
    get NAME basename
    string NAME += ".smpl_old"
    log NAME 0x58 0x44 0
endif
append
log MEMORY_FILE 0 0x24 # write header to memory
get SMPLSIZE asize 1
log MEMORY_FILE 0 SMPLSIZE 1 # append smpl area
get DSIZE asize 0
math DSIZE -= DATA
log MEMORY_FILE DATA DSIZE
append
get NAME basename
string NAME += ".wav"
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 Mon Jan 03, 2011 7:35 pm, edited 2 times in total.

Top
 Profile  
 
 Post subject: Re: My quickBMS scripts
PostPosted: Fri Sep 24, 2010 6:01 pm 
Offline
double-veteran
double-veteran

Joined: Sun Apr 20, 2008 2:58 am
Posts: 822
Has thanked: 5 times
Have thanks: 29 times
Thanks alpha worked with haze.

now we just need to figure out how to parse the interleave segments and an at3 file.


Top
 Profile  
 
 Post subject: Re: My quickBMS scripts
PostPosted: Thu Sep 30, 2010 9:22 am 
Offline
double-veteran
double-veteran

Joined: Mon Aug 24, 2009 10:55 pm
Posts: 984
Has thanked: 74 times
Have thanks: 587 times
Just corrected the XA deinterleave script: viewtopic.php?f=13&t=4450&p=40777#p40777
Now recognizes correct stream stops. :)

_________________
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 Oct 01, 2010 7:50 pm 
Offline
double-veteran
double-veteran

Joined: Mon Aug 24, 2009 10:55 pm
Posts: 984
Has thanked: 74 times
Have thanks: 587 times
func_str2num.bms
Function that converts a string representation of an integer to an integer varialble. Needed for func_XMA_header.bms for example.
The string you want to convert has to be named NUM.
Code:
startfunction str2num
    set TONUM 0
    strlen l NUM
    for i = 0 < l
        set EXP l
        math EXP -= i
        math EXP -= 1
        set B 0xA
        math B p EXP
        getVarChr T NUM i
        math T -= 0x30
        math T *= B
        math TONUM += T
    next i
    set NUM TONUM
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 Fri Feb 24, 2012 6:24 am, edited 1 time in total.

Top
 Profile  
 
 Post subject: Re: My quickBMS scripts
PostPosted: Fri Oct 01, 2010 9:30 pm 
Offline
double-veteran
double-veteran

Joined: Mon Aug 24, 2009 10:55 pm
Posts: 984
Has thanked: 74 times
Have thanks: 587 times
VAG_scanner.bms
Scans a file for mono VAG files, automatically names the files.
Code:
for i = 1
    FindLoc OFFSET STRING "VAGp" 0 ""
    if OFFSET != ""
        set SIZE OFFSET
        math SIZE += 0xC
        goto SIZE
        get SIZE long
        reverselong SIZE
        math SIZE += 0x30
        set NAME OFFSET
        math NAME += 0x20
        goto NAME
        get NAME string
        string NAME += ".vag"
        log NAME OFFSET SIZE
        math OFFSET += SIZE
        goto OFFSET
    else
        cleanexit
    endif
next i

_________________
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: Sat Oct 02, 2010 12:53 pm 
Offline
mega-veteran
mega-veteran

Joined: Fri Jun 11, 2010 12:08 pm
Posts: 307
Has thanked: 75 times
Have thanks: 18 times
I tried use scripts and at3 converter, but SoundForge still believes .aa3 and RIFF .at3 files as empty:
Image

Files for testing - http://ifolder.ru/19576388


Last edited by Researchman on Sat Oct 02, 2010 3:35 pm, edited 1 time in total.

Top
 Profile  
 
 Post subject: Re: My quickBMS scripts
PostPosted: Sat Oct 02, 2010 3:12 pm 
Offline
double-veteran
double-veteran

Joined: Mon Aug 24, 2009 10:55 pm
Posts: 984
Has thanked: 74 times
Have thanks: 587 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: Sat Oct 02, 2010 5:30 pm 
Offline
double-veteran
double-veteran

Joined: Mon Aug 24, 2009 10:55 pm
Posts: 984
Has thanked: 74 times
Have thanks: 587 times
post deleted

_________________
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 Sun Dec 05, 2010 8:47 pm, edited 1 time in total.

Top
 Profile  
 
 Post subject: Re: My quickBMS scripts
PostPosted: Sat Oct 02, 2010 5:42 pm 
Offline
double-veteran
double-veteran

Joined: Mon Aug 24, 2009 10:55 pm
Posts: 984
Has thanked: 74 times
Have thanks: 587 times
Regarding your uploaded samples: all *.mft files can bee converted with the above script. I've also looked at the other two files:
- SND0.at3 is standard AT3+ and has to be turned into an *.aa3 with my at3toaa3.bms script before you can open it with SoundForge.
- The Audio.at3 can be parsed with the script in the next post. It's a headerless AT3+ file. The script transforms it into an *.aa3 file so that SoundForge can open it.

_________________
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 Sat Oct 02, 2010 6:12 pm, edited 1 time in total.

Top
 Profile  
 
 Post subject: Re: My quickBMS scripts
PostPosted: Sat Oct 02, 2010 6:11 pm 
Offline
mega-veteran
mega-veteran

Joined: Fri Jun 11, 2010 12:08 pm
Posts: 307
Has thanked: 75 times
Have thanks: 18 times
Audio.at3 obtained through this program http://ifolder.ru/19566825 (get from ps3ripkits.com)

This program can convert .pmf psp movie files and .pam ps3 movie files(if rename to .pmf) to uncompress .avi(video) and .at3(audio).



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

All times are UTC + 1 hour


Who is online

Users browsing this forum: No registered users and 2 guests


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