You'll need to understand the files in this game and how they work to get a good grasp on what you need to do to achieve the goals you want. This is a beginner tutorial designed to help you replace simple tracks in the game with ones you want. To replace bigger/more complex tracks, I will make a seperate guide because you will need some extra software and guidance to do that.
There are 4 types of files you mostly need to concern yourself with in music modding:
- BFSTM (.bfstm) "Binary Cafe Stream" files
- BFSTP (.bfstp) "Binary Cafe Stream Prefetch" files
- BFWAV (.bfwav) "Binary Cafe Wave" files
- Bars (.bars) files
BFSTPs are essentially the little brother of BFSTMs. A lot of BFSTMs can't play immediately as the game has to load them in, so in order to avoid that, there are "prefetch" files for each of these BFSTMs that contain compressed data of their respective file and only play for 1 second before switching over to the BFSTM to play the rest. These are known as BFSTPs.
BFWAVs are another type of music file that are only for smaller sounds, short events, almost every sound effect in the game, etc.
All BFWAVs and BFSTPs are contained within Bars files. Bars files are simply containers for these files, and can contain multiple BFSTPs or BFWAVs within them if they concern one object/category (e.g: Guardian sword sfx). These can be found under content/Sound/Resource in the update folder for the game data.
IMPORTANT: This game's sound files have a sample rate 32000Hz. The music you get from Youtube and most MP3s are usually in 44100Hz or above, so make sure to convert before you start working on your new files. All your music mods should be in 32000Hz sample rate to avoid distortions and glitches.
For simple files, such as the one that plays near the Temple of Time, you only need to worry about 1 BFSTM file. In this case: BGM_Spot_TempleOfTime.bfstm. This goes for other BGM_Spot files you can find. However, if you want to replace the music for, say Guardian battles (Stalkers/Skywatchers), that has 5 files you should look at: BGM_Guardian_main.bfstm, BGM_Guardian_outro.bfstm, and GuardianBGM.bars which contains BGM_Guardian_main.bfstp and BGM_Guardian_outro.bfstp.
First I'll go over how to replace the Temple of Time music as an example, and then the Guardian's later as it just needs some extra steps. If you're just here for the former, you only need the 1st and 2nd resources I've listed below, but I recommend getting everything I list to make your life easier in the future.
You will need:
- A music editing software of your choice (I personally use Wavepad Sound Editor), e.g: Audacity
- Looping Audio Converter (this will be your best friend) by libertyernie
- bfstp fixer by NanobotZ or just follow this guide
- BCFSTM-BCFWAV Converter by Aboood40091 (also in the same guide)
- Python 3.7
- Bars Tool by NanobotZ for replacing/exporting BFSTPs and BFWAVs
- VLC Media player for previewing BFSTM files (not necessary but highly recommended)
- NW4F Wave converter for converting Wav files to BFWAV
- Foobar2000 Media Player and vgmStream plugin for previewing/converting BFWAV files
So, now you're all set, let's start off with making a simple looping track that will replace the Temple of Time theme to demonstrate. This fundamentally applies to any future tracks you make in terms of looping, so follow closely.
First, preview the actual original game file you're replacing so that you know how long it is and what constraints you wanna roughly keep your new file in (there's nothing wrong with making a loop a minute or so longer than normal for BGM_Spots, but I wouldn't recommend it for other tracks as it will probably function differently than what you're used to).
Now, assuming you have a file or sample you want to use, let's open it up in an editor and find a good place to loop. I don't know what sound editor you may use, but I find Wavepad perfect for this so I'll use screenshots of my process with it. This is the file I'm using:
As you can see, the sample rate is 44100, which we want to convert to 32000Hz before we start working on the file.
So after that, you do your edits as you wish to the file. For me, I turned the amplitude down by about 50% to get it close to the volume of the original file I'm aiming to replace. Then after you're happy, you look for a good spot to loop from and into. If you're having trouble and the file is very 'droney' (like a choir) or fades out, you can do an easy trick which I'll show here:
The trick is to select a portion of the start of the song precisely before your loop starts, and make sure to zoom in so you know not only the time at which the selection ends, but the precise sample it ends at.
You see, the bottom scale has turned into sample rate because milliseconds weren't precise enough.
Make a note of where precisely your intro stops and your loop starts. You will need this sample value later. Here, I noted down a value of 231002.
Now copy your intro, paste it in a new file on its own, and give it a fade in. Then paste mix the edited intro to the end of the original loop you want and it should fade in as the end of the song fades out.
My file now looks like this:
Now, get rid of any dead space at the end of your song, and make sure your loop ends precisely where the wave form stops continuing:
Make a note of the sample value where the loop ends, you will need this later also to confirm the file ends at the correct position. Here, I noted down a value of 4452607.
You should now find the point where your loop starts and highlight everything until the end of the song, and then play (ensuring the 'loop' option is selected) to test your loop.
IMPORTANT: When you are creating a loop, you must ensure that the start point and end point of the loop are ideally when the wave form reaches 0 amplitude, and one wave is coming up while the other is going down, to ensure optimal flow (you can see this in the zoomed in screenshots above). This is how you get seamless loops. Failure to adhere to these principles means you'll hear skips, 'pops' or static when the song loops. You should be concerned about this if you're an audiophile.
Alright, so now save your file as a .wav ensuring it's in 32000Hz, and then open up Looping Audio Converter and drag your file onto it.
Your setup should look like this, don't touch anything other than output directory which could be anywhere you want (I just use desktop so it's easy to find and handle immediately), the output format, and the loop information. Ensure you output it as a BFSTM, and make sure you select 'Ask for all files' for files with no loop information (that's yours!). Then this screen should come up:
Remember those sample values I told you to note down? This is where they are essential. Put your beginning loop value in 'Start' and the End should already be the other value you noted down, as the song/loop should end there. Make sure you check the 'Loop' box on the bottom left, play the file if you want to make sure, then click Okay.
You should now have your new BFSTM with all the loop data correctly made and ready to use. Rename the file exactly to the name of the original file you wanted to replace, and then place it in your new mod folder with a rules.txt and content folder. BFSTMs go in content/Sound/Resource/Stream.
Enable your new mod in Cemu, and make sure it works. If it does, congratulations, you have now perfectly made a BGM_Spot mod.
Now, for the next step up to say, the Guardian Music:
As I mentioned before, there is a main and an outro to this song. Assuming you made appropriate new themes for them, following the guide above, you should now get to the Looping Audio Converter Stage again.
This time, you want your main theme to loop, but your outro to not loop, so ensure you write no looping data for the outro and make sure looping is unchecked. Generate your 2 BFSTM files. Now, these files need a BFSTP prefetch to play perfectly, so you need to make them.
Use this guide to make the BFSTPs for your BFSTMs, and your directory before you run the .bat file should look like this (pycache won't be there the first time) (also you can batch run multiple BFSTMs at once).
You should then get 2 new BFSTPs for each file. Delete the ones that aren't 'fixed' and keep the ones I circled.
Now, time to rename everything to what they're supposed to be. You can rename the BFTSMs easily to the original filenames of the tracks you're replacing. BFSTPs also mostly follow the same naming convention and share the same exact filename as their respective BFSTM, but this can vary with each file, so you have to make sure.
To do this, using Bars Tool (make it the default program to open .bars files) find the Bars file that contains the BFSTPs of what you're looking for. Then, copy the Bars file, paste it to your modding workspace where you're gonna create the new updated Bars file for your mod, and open it up.
As you can see, the Guardian main BFSTP is named something completely ridiculous, so copy that name, and rename your new BFSTPs to these names shown (I haven't tried seeing what happens if I don't rename the file, it might not matter but I don't wanna risk it).
Now, you can press 'replace' on the BFSTP you selected and choose the new BFSTP you just made/renamed to replace it. Do this for the outro too.
You should then see a new bars.backup file has been made that just contains the old bars you modified, just remove the .backup part of the filename to restore it if you need to use it again. But the .bars file has now been updated with your new data, and should be ready to be placed in the content/Sound/Resource directory of your new mod folder.
Inside the 'Stream' Folder you should have your 2 new BFSTMs in there.
Drag your completed mod folder into the graphicsPack directory of CEMU and enable it after starting it up, and test.
If you followed this guide exactly, things should work perfectly and you can pat yourself on the back!
BFWAV files (for SOUND EFFECTS):
If you found that the file you want to replace is a BFWAV hidden inside a bars file, you can simply make your new sound effect/track as a .wav file (at 32000Hz). You can preview the original BFWAV inside the Bars Tool using Foobar2000 and ensure that your new file is shorter or equal in length to the original. Then, drag your wave file over the converter, and it should generate a bfwav of it.
Then using the Bars Tool, replace the old BFWAV with your new one (ensuring it has the right filename), and then implement it into your mod directory.
That should be all for simple BGM/SFX replacements, and I will make another tutorial for more complex files (such as Towns and Castle BGM). I hope this answered many of your questions and made the music scene much more accessible to beginners and veterans alike! Let me know if it helped!