Hacking [RELEASE] BARS extractor for BOTW (also, a new unknown music format?)

SamusAranX

Member
OP
Newcomer
Joined
Apr 27, 2014
Messages
20
Trophies
0
XP
161
Country
Germany
Since the only extractor for BOTW's .bars files I could find on this forum was Windows-only and I'm not a huge fan of that, I spent the last night reverse-engineering the BARS format used in BOTW and wrote a cross-platform extractor myself: https://gist.github.com/SamusAranX/6eb8b6fd1777b17afc3107a979c2409a
I subsequently posted it here: http://gbatemp.net/threads/tutorial...reath-of-the-wild.463642/page-24#post-7357406, but created this new thread so it could get more eyes on it. Hope that's okay.

While sifting through the data, I noticed there was another format with "FSTP" headers in the .bars files, and so far, it seems as if there's no converter for these yet. As I wrote in the information section below, I think they're 4 bit mono ADPCM files at 32000 Hz, but Audacity doesn't support importing that.
bars_extractor.py will extract these as .bfstp files so they can be converted when someone comes up with a converter.

If you want to have a crack at it, but lack the necessary files, try these:
MusicianThemeBgm_Event_BGM_MusicianThemeE.bfstp (with all headers and information)
MusicianThemeBgm_Event_BGM_MusicianThemeE.raw (headers and information stripped)
MusicianThemeBgm_Event_BGM_MusicianThemeE.wav (VERY LOUD! The above, imported into Audacity and exported to WAV)
As you can hear, there's definitely music in there, I just can't decode it into a proper format because I lack the tools.

Usage information and examples can be found on the Gist's page, but I'll copy the gist of it (heh) so you can read it here.

Usage
Code:
$ python3 bars_extractor.py [list of BARS files]
or
Code:
$ python3 bars_extractor.py *.bars

bars_extractor.py will only accept the wildcard syntax if "*.bars" is the only parameter.

Information
  • bars_extractor.py always overwrites files when extracting.
  • File names will be trimmed to fit into significantly less than 255 characters. In BOTW's files, there's at least one BARS file that contains a track name that is exactly 255 chars long, which is too much for most file systems. Check line 114 if you want to disable the trimming.
  • Most of the time, BARS files contain a bunch of BFWAV files that can be easily converted (or played back in foobar2000, for example), but sometimes there are files with an "FSTP" header. As of now, this seems to be an unknown format (because I can't find anything about it), but in case someone wants to tinker with the files, bars_extractor.py will attempt to extract them into files with the .bfstp extension.
    • I think they're 4 bit ADPCM files with one channel at a sample rate of 32000 Hz, but I currently lack the tools to test that.
Example
Code:
$ python3 bars_extractor.py KorokPot.bars
KorokPot.bars: 8 Tracks found:
KorokPot.bars: Saved track 1 to KorokPot_KorokPot_Slide01.bfwav
KorokPot.bars: Saved track 2 to KorokPot_KorokPot_Break01.bfwav
KorokPot.bars: Saved track 3 to KorokPot_KorokPot_Land02.bfwav
KorokPot.bars: Saved track 4 to KorokPot_KorokPot_Slide00.bfwav
KorokPot.bars: Saved track 5 to KorokPot_KorokPot_Break00.bfwav
KorokPot.bars: Saved track 6 to KorokPot_KorokPot_Break02.bfwav
KorokPot.bars: Saved track 7 to KorokPot_KorokPot_Land00.bfwav
KorokPot.bars: Saved track 8 to KorokPot_KorokPot_Land01.bfwav

Changes
Version 1.1
  • Moved script logic to a separate function that's called from main()
  • Added a new FWAV header for experimental extraction
  • Changed all structs from signed to unsigned values
  • Now correctly jumps to AMTA offsets instead of assuming they exist back-to-back
  • Added better error handling
 
Last edited by SamusAranX,

AboodXD

I hack NSMB games, and other shiz.
Member
Joined
Oct 11, 2014
Messages
2,870
Trophies
1
Location
Not under a rock.
XP
2,747
Country
United Arab Emirates
Hm... I thought BARs were SARC archives?

Edit: all I can say that those FSTP files are veeery similar to FSTM.

Since Foobar2000/vgmstream doesn't support this format, I might write a converter to BFSTM.
 
Last edited by AboodXD,

AyanamiRei0

GBATemp's Resident Evangelion fanboy.
Member
Joined
Jan 4, 2016
Messages
1,496
Trophies
1
Age
29
Location
Brexit
XP
1,467
Country
United Kingdom
Hm... I thought BARs were SARC archives?

Edit: all I can say that those FSTP files are veeery similar to FWAV.

Since Foobar2000/vgmstream doesn't support this format, I might write a converter to BFWAV.

Edit 2: I take it back, they are similar to BFSTMs.

Would this tool also work with other formats?
 

AboodXD

I hack NSMB games, and other shiz.
Member
Joined
Oct 11, 2014
Messages
2,870
Trophies
1
Location
Not under a rock.
XP
2,747
Country
United Arab Emirates
I honestly don't think so... :(

I already wrote a BFWAV to BFSTM tool, but it wasn't that great... :/

Anyway, regarding BFSTP, it's the same as BFSTM, with some slight changes.

For instance, "DATA" header has been renamed to "PDAT" and a few changes have been made to it... ._.
 
Last edited by AboodXD,

AboodXD

I hack NSMB games, and other shiz.
Member
Joined
Oct 11, 2014
Messages
2,870
Trophies
1
Location
Not under a rock.
XP
2,747
Country
United Arab Emirates

SamusAranX

Member
OP
Newcomer
Joined
Apr 27, 2014
Messages
20
Trophies
0
XP
161
Country
Germany
Shows what I know about figuring out weird audio formats. :D
I just assumed it would be 4 bits, based on the fact that all other audio files were as well.
 

Nitram12

New Member
Newbie
Joined
Oct 25, 2021
Messages
1
Trophies
0
XP
3
Country
Chile
Hey, just so you know, I made a fork of this script that supports Switch bars files, among other things. I can't link it here since this is a new account, but if anyone wants to use it, just click on "Forks" over the original script page, and click on "View fork" next to my username (Nitr4m12).
 
Last edited by Nitram12,
General chit-chat
Help Users
  • No one is chatting at the moment.
    Julie_Pilgrim @ Julie_Pilgrim: https://www.youtube.com/watch?v=9McGKrxOnB8 me looking at the switch's library like