• Stars
    star
    136
  • Rank 267,670 (Top 6 %)
  • Language
    Python
  • License
    MIT License
  • Created almost 9 years ago
  • Updated almost 3 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

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

python-fsb5

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

Supported formats

  • MPEG
  • Vorbis (OGG)
  • WAVE (PCM8, PCM16, PCM32)

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

Tool Usage

usage: extract.py [-h] [-o OUTPUT_DIRECTORY] [-p] [-q]
                  [fsb_file [fsb_file ...]]

Extract audio samples from FSB5 files

positional arguments:
  fsb_file              FSB5 container to extract audio from (defaults to
                        stdin)

optional arguments:
  -h, --help            show this help message and exit
  -o OUTPUT_DIRECTORY, --output-directory OUTPUT_DIRECTORY
                        output directory to write extracted samples into
  -q, --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

import fsb5

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

print(fsb.header)

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

# iterate over samples
for sample in fsb.samples:
  # print sample properties
  print('''\t{sample.name}.{extension}:
  Frequency: {sample.frequency}
  Channels: {sample.channels}
  Samples: {sample.samples}'''.format(sample=sample, extension=ext))

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

Useful header properties

  • numSamples: The number of samples contained in the file
  • mode: The audio format of all samples. Can be one of:
  • fsb5.SoundFormat.NONE
  • fsb5.SoundFormat.PCM8
  • fsb5.SoundFormat.PCM16
  • fsb5.SoundFormat.PCM24
  • fsb5.SoundFormat.PCM32
  • fsb5.SoundFormat.PCMFLOAT
  • fsb5.SoundFormat.GCADPCM
  • fsb5.SoundFormat.IMAADPCM
  • fsb5.SoundFormat.VAG
  • fsb5.SoundFormat.HEVAG
  • fsb5.SoundFormat.XMA
  • fsb5.SoundFormat.MPEG
  • fsb5.SoundFormat.CELT
  • fsb5.SoundFormat.AT9
  • fsb5.SoundFormat.XWMA
  • fsb5.SoundFormat.VORBIS

Useful sample properties

  • name : The name of the sample, or a 4 digit number if names are not provided.
  • frequency : The sample rate of the audio
  • channels : The number of channels of audio (either 1 or 2)
  • samples : The number of samples in the audio
  • metadata : A dictionary of fsb5.MetadataChunkType to tuple (sometimes namedtuple) or bytes.

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

Supported fsb5.MetadataChunkTypes are:

  • CHANNELS: A 1-tuple containing the number of channels
  • FREQUENCY: A 1-tuple containing the sample rate
  • LOOP: A 2-tuple of the loop start and end
  • XMASEEK: Raw bytes
  • DSPCOEFF: Raw bytes
  • XWMADATA: Raw bytes
  • VORBISDATA: A named tuple with properties crc32 (int) and unknown (bytes)

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.

More Repositories

1

Hearthstone-Deck-Tracker

A deck tracker and deck manager for Hearthstone on Windows
C#
4,667
star
2

HSTracker

A deck tracker and deck manager for Hearthstone on macOS
Swift
1,170
star
3

UnityPack

Python deserialization library for Unity3D Asset format
Python
720
star
4

UnityHook

Platform to hook into Unity3D assemblies
C#
267
star
5

hsdata

Hearthstone Data
262
star
6

SabberStone

Just another Hearthstone Simulator in C# .Net Core, with some A.I. approaches!
C#
249
star
7

python-hearthstone

Hearthstone Python library (CardDefs, DBF, enums, log parser)
Python
237
star
8

Arcane-Tracker

An automatic Hearthstone tracker for Android
Kotlin
147
star
9

Joust

🍿 Hearthstone replays in your browser.
TypeScript
116
star
10

Sunwell

Canvas-based high quality Hearthstone card renderer - no longer maintained
TypeScript
94
star
11

proto-extractor

Program to extract protobufs compiled for C#
C#
88
star
12

dj-paypal

Paypal integration for Django - Inspired by dj-Stripe
Python
84
star
13

HearthDb

HearthDb is a .NET Hearthstone database.
C#
69
star
14

hs-bugs

Unofficial Hearthstone issue tracker
65
star
15

docker-pgredshift

Redshift docker image based on postgres
Dockerfile
64
star
16

python-hslog

Python module to parse Hearthstone Power.log files
Python
59
star
17

HDT-Releases

58
star
18

hearthstone-deckstrings

πŸ”— Decode and encode Hearthstone Deckstrings.
JavaScript
52
star
19

python-hsreplay

Python library for creating and parsing HSReplay XML files
Python
50
star
20

LotusTracker

Deck Tracker for Magic Arena [DEPRECATED]
C++
50
star
21

twitch-hdt-frontend

πŸ“Ί The official Twitch Extension for Hearthstone Deck Tracker.
TypeScript
42
star
22

hs-icons

Hearthstone vector icons
39
star
23

hsproto

Hearthstone Protobuf files
33
star
24

hsreplaynet-localstack

HSReplay.net local Docker dev stack
Python
32
star
25

HDT-Localization

Localization for Hearthstone Deck Tracker
XML
23
star
26

Brazier

Hearthstone Simulator in Java
Java
21
star
27

dynity

Load an assembly in Unity at runtime
C++
20
star
28

keg

A client for Blizzard's NGDP protocol
Python
20
star
29

django-reflinks

Referral links implementation for Django
Python
15
star
30

twitch-hdt-ebs

πŸ“’ Twitch Extension Backend Service for Hearthstone Deck Tracker.
Python
15
star
31

decrunch

Python wrapper around Crunch DXTc decompressor
C++
14
star
32

articles

Analysis of Hearthstone replays
Jupyter Notebook
11
star
33

hs-card-tiles

Hearthstone Card Tiles
C#
9
star
34

unity-examples

ASP
9
star
35

UnityPack-Swift

Swift port of UnityPack
C
8
star
36

hearthstonejson-client

πŸ“– HearthstoneJSON client for browsers and Node.
TypeScript
8
star
37

python-hearthstone-data

CardDefs.xml and Strings.txt for Hearthstone, conveniently packaged in Python
Python
7
star
38

HearthBot

Hearthstone bot for Discord
Python
7
star
39

hsreplay-xml

πŸ“Ό Replay format for Hearthstone
6
star
40

HSTracker-Beta

6
star
41

hearthsim.info

The HearthSim community website
SCSS
6
star
42

hearthforge

JavaScript
5
star
43

hsreplaynet-i18n

🌎 Translations for HSReplay.net.
Gettext Catalog
5
star
44

pyreplib

Starcraft Replay File parser [archived]
C++
5
star
45

deck-code-bot

A bot for decoding Hearthstone deck codes on Reddit
Python
4
star
46

legal

HearthSim legal documents (Privacy Policy, Terms of Services, etc)
Markdown
3
star
47

hsreplaynet-embed

Embeddable library for HSReplay.net features on other sites
TypeScript
3
star
48

FSBReader

FSB Reader code for FSBExtractor
Pascal
3
star
49

scenfiles

Hearthstone .scen files and conversion utility
Python
2
star
50

HearthstoneJSON.com

The HearthstoneJSON.com frontend jekyll website
CSS
2
star
51

hsreplay-test-data

Log data for HSReplay and hslog tests
XML
2
star
52

node-canvas-lambda

Builds node-canvas for lambda
Shell
2
star
53

kettle-design

Repo for Kettle design collaboration
C#
2
star
54

CardBot-lua

An IRC card search bot for #hearthsim [archived]
Lua
2
star
55

django-intenumfield

An IntEnumField for Django
Python
2
star
56

deckwarper

πŸ”§ A tiny web-based tool to create and edit Hearthstone decks.
JavaScript
2
star
57

hsreplaynet-api-docs

1
star
58

SabberStoneSynchronizer

Synchronizer between a running Hearthstone client and SabberStone.
C#
1
star
59

hearthsim-instrumentation

Legacy HSReplay.net runtime tooling
Python
1
star
60

HDT-Releases-HSReplay

1
star
61

MtgLotusValley.com

www.mtglotusvalley.com
Vue
1
star
62

hsreplaynet-lambdas

Python
1
star
63

branding

🎨 Logos, Colors and Guidelines for the HearthSim brands.
1
star
64

eslint-config-typescript

HearthSim's common ESLint configuration
JavaScript
1
star
65

Firestarter

Rust
1
star
66

mpqlib

Bob Jenkins' MPQLib (Public Domain)
C
1
star
67

react-hs-components

πŸ—„οΈ Common React components used across HearthSim products.
TypeScript
1
star
68

django-hearthstone

Hearthstone DBF models for Django
Python
1
star
69

hs-proto-go

Autogenerated Golang code for hs-proto
Shell
1
star