Answered
0
0

Is the FSB format documented somewhere? Or can we get access to the fsbank.exe source code if we are a licensed user? I realize the format may change from version to version, but it would be really nice if we could incorporate the FSB file creation into our own development tool.

Thanks,
Kristine

  • You must to post comments
Best Answer
0
0

This is the info for FSB4. FMOD Ex does not support anything less than FSB4 now.

#define FMOD_FSB_NAMELEN             30

/* These flags are used for FMOD_FSB_HEADER::mode */
#define FMOD_FSB_SOURCE_FORMAT         0x00000001  /* all samples stored in their original compressed format */
#define FMOD_FSB_SOURCE_BASICHEADERS   0x00000002  /* samples should use the basic header structure */
#define FMOD_FSB_SOURCE_ENCRYPTED      0x00000004  /* all sample data is encrypted */
#define FMOD_FSB_SOURCE_BIGENDIANPCM   0x00000008  /* pcm samples have been written out in big-endian format */
#define FMOD_FSB_SOURCE_NOTINTERLEAVED 0x00000010  /* Sample data is not interleaved. */
#define FMOD_FSB_SOURCE_MPEG_PADDED    0x00000020  /* Mpeg frames are now rounded up to the nearest 2 bytes for normal sounds, or 16 bytes for multichannel. */
#define FMOD_FSB_SOURCE_MPEG_PADDED4   0x00000040  /* Mpeg frames are now rounded up to the nearest 4 bytes for normal sounds, or 16 bytes for multichannel. */

/* These flags are used for FMOD_FSB_HEADER::version */
#define FMOD_FSB_VERSION_3_0         0x00030000  /* FSB version 3.0 */
#define FMOD_FSB_VERSION_3_1         0x00030001  /* FSB version 3.1 */
#define FMOD_FSB_VERSION_4_0         0x00040000  /* FSB version 4.0 */


/* FMOD 3 defines.  These flags are used for FMOD_FSB_SAMPLE_HEADER::mode */
#define FSOUND_LOOP_OFF              0x00000001  /* For non looping samples. */
#define FSOUND_LOOP_NORMAL           0x00000002  /* For forward looping samples. */
#define FSOUND_LOOP_BIDI             0x00000004  /* For bidirectional looping samples.  (no effect if in hardware). */
#define FSOUND_8BITS                 0x00000008  /* For 8 bit samples. */
#define FSOUND_16BITS                0x00000010  /* For 16 bit samples. */
#define FSOUND_MONO                  0x00000020  /* For mono samples. */
#define FSOUND_STEREO                0x00000040  /* For stereo samples. */
#define FSOUND_UNSIGNED              0x00000080  /* For user created source data containing unsigned samples. */
#define FSOUND_SIGNED                0x00000100  /* For user created source data containing signed data. */
#define FSOUND_MPEG                  0x00000200  /* For MPEG layer 2/3 data. */
#define FSOUND_CHANNELMODE_ALLMONO   0x00000400  /* Sample is a collection of mono channels. */
#define FSOUND_CHANNELMODE_ALLSTEREO 0x00000800  /* Sample is a collection of stereo channel pairs */
#define FSOUND_HW3D                  0x00001000  /* Attempts to make samples use 3d hardware acceleration. (if the card supports it) */
#define FSOUND_2D                    0x00002000  /* Tells software (not hardware) based sample not to be included in 3d processing. */
#define FSOUND_SYNCPOINTS_NONAMES    0x00004000  /* Specifies that syncpoints are present with no names */
#define FSOUND_DUPLICATE             0x00008000  /* This subsound is a duplicate of the previous one i.e. it uses the same sample data but w/different mode bits */
#define FSOUND_CHANNELMODE_PROTOOLS  0x00010000  /* Sample is 6ch and uses L C R LS RS LFE standard. */
#define FSOUND_MPEGACCURATE          0x00020000  /* For FSOUND_Stream_Open - for accurate FSOUND_Stream_GetLengthMs/FSOUND_Stream_SetTime.  WARNING, see FSOUND_Stream_Open for inital opening time performance issues. */
#define FSOUND_HW2D                  0x00080000  /* 2D hardware sounds.  allows hardware specific effects */
#define FSOUND_3D                    0x00100000  /* 3D software sounds */
#define FSOUND_32BITS                0x00200000  /* For 32 bit (float) samples. */
#define FSOUND_IMAADPCM              0x00400000  /* Contents are stored compressed as IMA ADPCM */
#define FSOUND_VAG                   0x00800000  /* For PS2 only - Contents are compressed as Sony VAG format */
#define FSOUND_XMA                   0x01000000  /* For Xbox360 only - Contents are compressed as XMA format */
#define FSOUND_GCADPCM               0x02000000  /* For Gamecube only - Contents are compressed as Gamecube DSP-ADPCM format */
#define FSOUND_MULTICHANNEL          0x04000000  /* For PS2 and Gamecube only - Contents are interleaved into a multi-channel (more than stereo) format */
#define FSOUND_OGG                   0x08000000  /* For vorbis encoded ogg data */
#define FSOUND_CELT                  0x08000000  /* For vorbis encoded ogg data */
#define FSOUND_MPEG_LAYER3           0x10000000  /* Data is in MP3 format. */
#define FSOUND_MPEG_LAYER2           0x00040000  /* Data is in MP2 format. */
#define FSOUND_LOADMEMORYIOP         0x20000000  /* For PS2 only - "name" will be interpreted as a pointer to data for streaming and samples.  The address provided will be an IOP address */
#define FSOUND_IMAADPCMSTEREO        0x20000000  /* Signify IMA ADPCM is actually stereo not two interleaved mono */
#define FSOUND_IGNORETAGS            0x40000000  /* Skips id3v2 etc tag checks when opening a stream, to reduce seek/read overhead when opening files (helps with CD performance) */
#define FSOUND_SYNCPOINTS            0x80000000  /* Specifies that syncpoints are present */

/* These flags are used for FMOD_FSB_SAMPLE_HEADER::mode */
#define FSOUND_CHANNELMODE_MASK      (FSOUND_CHANNELMODE_ALLMONO | FSOUND_CHANNELMODE_ALLSTEREO | FSOUND_CHANNELMODE_PROTOOLS)  
#define FSOUND_CHANNELMODE_DEFAULT   0x00000000  /* Determine channel assignment automatically from channel count. */
#define FSOUND_CHANNELMODE_RESERVED  0x00000C00  

#define FSOUND_NORMAL                (FSOUND_16BITS | FSOUND_SIGNED | FSOUND_MONO)

#define FSB_SAMPLE_DATA_ALIGN        32

typedef struct
{
    char            id[4];          /* 'FSB4' */
    int             numsamples;     /* number of samples in the file */
    unsigned int    shdrsize;       /* size in bytes of all of the sample headers including extended information */
    unsigned int    datasize;       /* size in bytes of compressed sample data */

    unsigned int    version;        /* extended fsb version */
    unsigned int    mode;           /* flags that apply to all samples in the fsb */
    FMOD_UINT64     hash;           /* trunacted MD5 hash generated using only information which would break FEV/FSB combatibility */
    FMOD_GUID       guid;           /* Unique identifier. */

} FMOD_FSB_HEADER; /* 48 bytes */

typedef struct
{
    unsigned short  size;
    char            name[FMOD_FSB_NAMELEN];

    unsigned int    lengthsamples;
    unsigned int    lengthcompressedbytes;
    unsigned int    loopstart;
    unsigned int    loopend;

    unsigned int    mode;
    int             deffreq;
    unsigned short  defvol;
    short           defpan;
    unsigned short  defpri;
    unsigned short  numchannels;
    float           mindistance;
    float           maxdistance;
    unsigned int    size_32bits;
    unsigned short  varvol;
    short           varpan;
} FMOD_FSB_SAMPLE_HEADER; /* 80 bytes */

typedef struct
{
    unsigned int    lengthsamples;
    unsigned int    lengthcompressedbytes;   

} FMOD_FSB_SAMPLE_HEADER_BASIC; /* 8 bytes */
  • You must to post comments
0
0

Here’s the latest fsb header info. fmod still reads FSB2 just for backwards compatability but fsbank only writes out FSB3 now – your tools should do the same.

Enjoy!

#define FSOUND_FSB_NAMELEN  30

/*
    Defines for FSOUND_FSB_HEADER->mode field
*/
#define FSOUND_FSB_SOURCE_FORMAT  0x00000001  /* all samples stored in their original compressed format */

/*
    16 byte header.
*/
typedef struct
{
    char                id[4];          /* 'FSB2' */
    int                 numsamples;     /* number of samples in the file */
    int                 shdrsize;       /* size in bytes of all of the sample headers including extended information */
    int                 datasize;       /* size in bytes of compressed sample data */
} FSOUND_FSB_HEADER_FSB2;

/*
    24 byte header.
*/
typedef struct
{
    char                id[4];          /* 'FSB3' */

    int                 numsamples;     /* number of samples in the file */
    int                 shdrsize;       /* size in bytes of all of the sample headers including extended information */
    int                 datasize;       /* size in bytes of compressed sample data */
    unsigned int        version;        /* extended fsb version - hi-word = major, lo-word = minor */
    unsigned int        mode;           /* flags that apply to all samples in the fsb */
} FSOUND_FSB_HEADER;

/*
    64 byte sample header.
*/
typedef struct
{
    unsigned short  size;
    char            name[FSOUND_FSB_NAMELEN];

    unsigned int    lengthsamples;
    unsigned int    lengthcompressedbytes;
    unsigned int    loopstart;
    unsigned int    loopend;

    unsigned int    mode;
    int             deffreq;
    unsigned short  defvol;
    short           defpan;
    unsigned short  defpri;
    unsigned short  numchannels;

} FSOUND_FSB_SAMPLE_HEADER;
  • You must to post comments
0
0

The fsb format was updated a while back to version 3.1. Again, it’s still backwards compatible but fsbank will always write out 3.1 files now. Here’s the updated header info:

#define FSOUND_FSB_NAMELEN  30

/*
    Defines for FSOUND_FSB_HEADER->mode field
*/
#define FSOUND_FSB_SOURCE_FORMAT        0x00000001  /* all samples stored in their original compressed format */
#define FSOUND_FSB_SOURCE_BASICHEADERS  0x00000002  /* samples should use the basic header structure */

/*
    Defines for FSOUND_FSB_HEADER->version field
*/
#define FSOUND_FSB_VERSION_3_1          0x00030001  /* FSB version 3.1 */

/*
    16 byte header.
*/
typedef struct
{
    char                id[4];          /* 'FSB2' */
    int                 numsamples;     /* number of samples in the file */
    int                 shdrsize;       /* size in bytes of all of the sample headers including extended information */
    int                 datasize;       /* size in bytes of compressed sample data */
} FSOUND_FSB_HEADER_FSB2;

/*
    24 byte header.
*/
typedef struct
{
    char                id[4];          /* 'FSB3' */
    int                 numsamples;     /* number of samples in the file */
    int                 shdrsize;       /* size in bytes of all of the sample headers including extended information */
    int                 datasize;       /* size in bytes of compressed sample data */
    unsigned int        version;        /* extended fsb version */
    unsigned int        mode;           /* flags that apply to all samples in the fsb */
} FSOUND_FSB_HEADER;

/*
    64 byte sample header.
*/
typedef struct
{
    unsigned short  size;
    char            name[FSOUND_FSB_NAMELEN];

    unsigned int    lengthsamples;
    unsigned int    lengthcompressedbytes;
    unsigned int    loopstart;
    unsigned int    loopend;

    unsigned int    mode;
    int             deffreq;
    unsigned short  defvol;
    short           defpan;
    unsigned short  defpri;
    unsigned short  numchannels;

} FSOUND_FSB_SAMPLE_HEADER;

/*
    80 byte sample header.
*/
typedef struct
{
    unsigned short  size;
    char            name[FSOUND_FSB_NAMELEN];

    unsigned int    lengthsamples;
    unsigned int    lengthcompressedbytes;
    unsigned int    loopstart;
    unsigned int    loopend;

    unsigned int    mode;
    int             deffreq;
    unsigned short  defvol;
    short           defpan;
    unsigned short  defpri;
    unsigned short  numchannels;

    F_FLOAT         mindistance;
    F_FLOAT         maxdistance;
    int             varfreq;
    unsigned short  varvol;
    short           varpan;

} FSOUND_FSB_SAMPLE_HEADER_3_1;

/*
    8 byte sample header.
*/
typedef struct
{
    unsigned int    lengthsamples;
    unsigned int    lengthcompressedbytes;
} FSOUND_FSB_SAMPLE_HEADER_BASIC;
  • You must to post comments
0
0

note FSB can be loaded in 3 reads. There are 3 sections to an FSB.

  1. main header. Read in FMOD_FSB_HEADER
  2. sample header block. Read in FMOD_FSB_HEADER::shdrsize bytes. This will contain "For i = 0 to FMOD_FSB_HEADER-1 * FMOD_FSB_SAMPLE_HEADER". FMOD_FSB_SAMPLE_HEADER structs are stored here, but if there are syncpoints, xma seek tables or gcadpcm context data here, you will need to scan through a header at a time using FMOD_FSB_SAMPLE_HEADER::size. It will be FMOD_FSB_SAMPLE_HEADER followed by the relevant metadata (not documented here)
  3. Raw data. Read in FMOD_FSB_HEADER::datasize here. This would be mp3/xma/adpcm/pcm/celt or whatever format is specified with FMOD_FSB_SAMPLE_HEADER::mode.

Note if FMOD_FSB_SOURCE_BASICHEADERS is specified, there is no metadata, and only 1 master FMOD_FSB_SAMPLE_HEADER to describe the channels/frequency of the sounds. This is also the info for subsound 0. From then on all structs are stored as FMOD_FSB_SAMPLE_HEADER_BASIC to provide the pcm and compressed length of each subsound. ‘basicheaders’ FSBs have to all be the same channelcount and format and frequency and quality.

This basicheaders variation is great to store 8 bytes per subsound instead of 80. You can imagine if you had 10,000 sounds the savings would be substantial (80kb instead of 800kb)

  • You must to post comments
Showing 4 results
Your Answer

Please first to submit.