Skip to content

Repository files navigation

Fmod5Sharp

Managed decoder for FMOD 5 sound banks (FSB files).

NuGet

This library allows you to read FMOD 5 sound bank files (they start with the characters FSB5) into their contained samples, and then export those samples to standard file formats (assuming the contained data format is supported).

Support for more encodings can be added as requested.

Usage

The Fmod file can be read like this

//Will throw if the bank is not valid.FmodSoundBankbank=FsbLoader.LoadFsbFromByteArray(rawData);

Or if you don't want it to throw if the file is invalid, you can use

boolsuccess=FsbLoader.TryLoadFsbFromByteArray(rawData,outFmodSoundBankbank);

You can then query some properties about the bank:

FmodAudioTypetype=bank.Header.AudioType;uintfmodSubVersion=bank.Header.Version;//0 or 1 have been observed

And get the samples stored inside it:

List<FmodSample>samples=bank.Samples;intfrequency=samples[0].Metadata.Frequency;//E.g. 44100uintnumChannels=samples[0].Metadata.Channels;//2 for stereo, 1 for mono.stringname=samples[0].Name;//Null if not present in the bank file (which is usually the case).

And, you can convert the audio data back to a standard format.

varsuccess=samples[0].RebuildAsStandardFileFormat(outvardataBytes,outvarfileExtension);//Assuming success == true, then this file format was supported and you should have some data and an extension (without the leading .).//Now you can save dataBytes to an file with the given extension on your disk and play it using your favourite audio player.//Or you can use any standard library to convert the byte array to a different format, if you so desire.

You can also check if a given format type is supported and, if so, what extension it will result in, like so:

boolisSupported=bank.Header.AudioType.IsSupported();//Null if not supportedstring?extension=bank.Header.AudioType.FileExtension();

Alternatively, you can consult the table below:

FormatSupported?ExtensionNotes
PCM8✔️wav
PCM16✔️wav
PCM24No games have ever been observed in the wild using this format.
PCM32✔️wavSupported in theory. No games have ever been observed in the wild using this format.
PCMFLOATSeen in at least one JRPG.
GCADPCM✔️wavTested with single-channel files. Not tested with stereo, but should work in theory. Seen in Unity games.
IMAADPCM✔️wavSeen in Unity games.
VAGNo games have ever been observed in the wild using this format.
HEVAGVery rarely used - only example I know of is a game for the PS Vita.
XMAMostly used on Xbox 360.
MPEGUsed in some older games.
CELTUsed in some older indie games.
AT9Native format for PlayStation Audio, including in Unity games.
XWMANo games have ever been observed in the wild using this format.
VORBIS✔️oggVery commonly used in Unity games.

Acknowledgements

This project uses:

About

Managed-Only C# Library for Decoding FMOD 5 sound banks (FSB or bank files)

Resources

Stars

1 star

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages