Friday, May 2, 2008

BJS Footer

Sorry for the lack of updates, but I haven't had much time to work on this and I'm not even sure the best way of going about explaining the BJS format. So I'm just going to post my raw notes. It's a backwards way to work, but it's best if you read the footer in order to find the meaning of the values found in the BJS. Posting a list of offsets isn't practical as every file is different.

Footer seems to follow "ASCII identifier, offset, length" pattern:
BIFF FFs then value = length of rest of footer (except last 4 bytes)
SONG FFs then value = length till VAGS
SDFV Offset to 1st Magic Number
SID0 Offset to 2nd Magic Number
NAME Offset to Internal name (Length = chars + 1)
AUTH "JAM_000x" name (+1)
BPM0 Tempo (Remember: these are OFFSETS to values)
BPB0 ? Always =4 Time signature? (Beats Per Bar)

VAGS FFs then length of ALL the following VAG related data
NVAG Number of VAGs
|VAGF VAG offset, length
|VNBD Unknown value after waveform
|VBDT Chunk of really unknown data, lengths vary greatly
|VENC ?? Appears occasionally. (Though not in JAM_0002) Always =2?
|LPNB Unknown value before next "VAGp"
|_______repeat for n VAG files...

SMPS FFs then length of ALL the following sample data
NSMP Number of samples
|*(following will not exist if NSMP = 0)
|SNAM Sample Name (length =+ 1)
|SDAT Offset and length following name. Odd. I assume assigns samples to a track.
|_______repeat for n samples...
*

VERS ? (Always =4)
NBRS Number of Bars? (Always =4, could do more?)
CNTI ? (Always =2)

TRKS FFs then length of ALL the following Track data
NTRK Number of tracks (Pads)
|TRAK Track info offset and length (76!)
|Assigns VAGs to tracks. See trackfooterdata.txt
|_______repeat for n tracks

STKS FFs then length of following data (12)
NSTK ? (=0)

SSEV ? Same offset as below, but no length (?)
NSSE ? (=0)

SSE0 ? Same as below, no length
SSET ? Ditto
NSST Number of sample sets
*SST0 Sample set name (e.g. PERC.) Only if NSST > 0 Repeat for n)*

UINT ? Same as below, no length
UIS0 Unknown data before page data, odd length (65)
Follows a bizarre pattern, seems to be the same throughout all Jam BJS':
(Decimal) 5 0 1 0 1 1 1 2 1 2 3 1 3 4 1 4 0
Might be related to page order

NUIM Number of pages

|UIM0 Page info. Assigns tracks/samples to pads within a page
|See pagefooterdata.txt for detail.
|_______Repeat for n pages

STG0 FFs then length of following data
NSTG ? (Always =0?) Found 8 bytes before BIFF

VERE ? (Always =4?) Found right before BIFF

Final 4 bytes is the offset of the first string (BIFF)
trackfooterdata.txt (Data is from JAM_0002)
00 00 80 3F Magic Number? Is probably of some significance, but I haven't seen other values
00 00 00 3F ??? The rest of the tracks are pretty predictable; the left, right and middle ones share equal values across instruments. Maybe balance?
04 00 00 00 Number of VAGs per track (Always 4)
00 00 00 00 First byte is VAG (1), third byte is button (X)
00 00 00 00 00 00 00 00 Pad
01 00 01 00 (2nd VAG (Drums2), 2nd button ([]))
00 00 00 00 00 00 00 00 Pad
02 00 02 00 (3rd VAG (Drums3), 3rd button (O))
00 00 00 00 00 00 00 00 Pad
03 00 03 00 (4th VAG (Drums4), 4th button (/\))
00 00 00 00 00 00 00 00 00 00 00 00 Pad
6A 61 6D 5F 30 30 30 32 5F 74 31 00 "jam_0002_t1" Must include trailing 00
pagefooterdata.txt
Data per page will be longer/shorter depending on the amount of pads.
Example is dan1 from JAM_0002.BJS. It has 3 pads:
03 00 00 00 Number of Pads
00 00 00 00 Pad 0 (Printed as 1)
01 00 00 00 Type ID. Loops use 1, samples use 2.
00 00 00 00 Track 0 (Known as _t1)
01 00 00 00 Pad 1 (2)
01 00 00 00 ID
01 00 00 00 Track 1 (t2)
02 00 00 00 Pad 2 (3)
01 00 00 00 ID
02 00 00 00 Track 2 (t3)
64 61 6E 31 00 00 00 00 "dan1"(name) +1, padded

This is crk1 from JAM_000D.BJS. It has 4 pads, one is a sample pad:
04 00 00 00 Number of pads
00 00 00 00 Pad 0 (Printed as 1)
01 00 00 00 ID
00 00 00 00 Track 0 (known as _t1)
01 00 00 00 Pad 1 (2)
01 00 00 00 ID
01 00 00 00 Track 1 (t2)
02 00 00 00 Pad 2 (3)
01 00 00 00 ID
02 00 00 00 Track 2 (t3)
03 00 00 00 Pad 3 (4)
02 00 00 00 SAMPLE ID
00 00 00 00 Sample 0 (s1)
63 72 6B 31 00 00 00 00 "crk1"

No comments: