HearthSim/python-fsb5

Name: python-fsb5

Owner: HearthSim

Description: Library and tool to extract audio from FSB5 (FMOD Sample Bank) files

Created: 2016-01-11 19:45:05.0

Updated: 2018-05-20 08:17:39.0

Pushed: 2017-04-18 03:37:22.0

Homepage: https://hearthsim.info

Size: 460

Language: Python

GitHub Committers

UserMost Recent Commit# Commits

Other Committers

UserEmailMost Recent Commit# Commits

README

python-fsb5

Python library and tool to extract FSB5 (FMOD Sample Bank) files.

Supported formats

Other formats can be identified but will be extracted as .dat files and may not play as the headers may be missing.

Tool Usage
e: extract.py [-h] [-o OUTPUT_DIRECTORY] [-p] [-q]
              [fsb_file [fsb_file ...]]

act audio samples from FSB5 files

tional arguments:
b_file              FSB5 container to extract audio from (defaults to
                    stdin)

onal arguments:
, --help            show this help message and exit
 OUTPUT_DIRECTORY, --output-directory OUTPUT_DIRECTORY
                    output directory to write extracted samples into
, --quiet           suppress output of header and sample information
                    (samples that failed to decode will still be printed)
Resource files

Unity3D packs multiple FSB5 files each containing a single sample into it's .resource files. python-fsb5 will automatically extract all samples if multiple FSB5s are found within one file. Output files will be prefixed with the (0 based) index of their FSB container within the resource file e.g. out/sounds-15-track1.wav is the path for a WAVE sample named track1 which is contained within the 16th FSB file within sounds.resource.

Unnamed samples

FSB5 does not require samples to store a name. If samples are stored without a name they will use their index within the FSB e.g. sounds-0000.mp3 is the first sample in sounds.fsb.

Requirements

python-fsb5 should work with python3 from version 3.2 and up.

libogg and libvorbis are required to decode ogg samples. For linux simply install from your package manager. For windows ensure the dlls are avaliable (ie. in System32 or the directory you are running the script from). Known working dlls are avaliable as part of the release.

If ogg files are not required to be decoded then the libraries are not required.

Library usage
rt fsb5

ad the file into a FSB5 object
 open('sample.fsb', 'rb') as f:
b = fsb5.FSB5(f.read())

t(fsb.header)

t the extension of samples based off the sound format specified in the header
= fsb.get_sample_extension()

erate over samples
sample in fsb.samples:
print sample properties
int('''\t{sample.name}.{extension}:
equency: {sample.frequency}
annels: {sample.channels}
mples: {sample.samples}'''.format(sample=sample, extension=ext))

rebuild the sample and save
th open('{0}.{1}'.format(sample.name, ext), 'wb') as f:
rebuilt_sample = fsb.rebuild_sample(sample)
f.write(rebuilt_sample)
Useful header properties Useful sample properties

All contents of sample.metadata is optional and often not provided. Several metadata types seem to override sample properties.

Supported fsb5.MetadataChunkTypes are:

If a metadata chunk is unrecognized it will be included in the dictionary as an interger mapping to a bytes.

Rebuilding samples

Samples also have the data property. This contains the raw, unprocessed audio data for that sample from the FSB file. To reconstruct a playable version of the audio use rebuild_sample on the FSB5 object passing the sample desired to be rebuilt.

License

python-fsb5 is licensed under the terms of the MIT license. The full text of the license is available in the LICENSE file.


This work is supported by the National Institutes of Health's National Center for Advancing Translational Sciences, Grant Number U24TR002306. This work is solely the responsibility of the creators and does not necessarily represent the official views of the National Institutes of Health.