Author Topic: A Touhou BGM Replacer and Extractor  (Read 7483 times)

Sage Ω (Ultima)

  • CEO at Team Eternal Desire
  • ??? X
A Touhou BGM Replacer and Extractor
« on: March 06, 2017, 07:40:47 AM »
So I found out that there are no existing bgm replacement tools out there that work with Touhou 13, 14, 14.3, and 15. So I decided to make one myself.


For replacing songs the instructions are pretty simple. Use touhou toolkit or your tool of choice to extract the contents of the th##.dat file. From the extracted contents find and copy the thbgm.fmt file to the same directory as this tool. Then take the thbgm.dat from the game's directory and copy that into the tool's directory. Run the tool and follow the instructions from there. When finished, copy the files back to their original locations, delete the originals and rename the _new files to match. Rebuild the th##.dat archive with touhou toolkit (or whatever you used to extract it) and run the game. Your song should be playing and looping correctly.

Loop points are in samples.

For extracting the process is the exact same except you don't have to replace anything obviously. You will get two files, one is the song you extracted, and the other is a file containing the loop points in sample format.

There is still a bit data about the thbgm.fmt file that I have yet to uncover the usage of. However, I have used the tool a few times and have not noticed any issues when playing the games themselves. If you find anything be sure to let me know in this thread. That being said, the tool is in the attachments of this post.

Re: A Touhou BGM Replacer and Extractor
« Reply #1 on: March 06, 2017, 11:56:08 PM »
Oh sweet butter crumpets, thank you! I'll be giving this a try.

I've been trying to figure out the best way to replace stage and boss music in LoLK for a joke mod. I'll have to see if this gives a better result than Audacity  :D

Sage Ω (Ultima)

  • CEO at Team Eternal Desire
  • ??? X
Re: A Touhou BGM Replacer and Extractor
« Reply #2 on: March 07, 2017, 03:59:43 PM »
Hopefully everything works out well. The way it works is quite simple, the tool gets all of the song information from thbgm.fmt, uses the offsets in that file to manually open up thbgm.dat. The replacement process is pretty much just swapping the raw pcm data with a custom song, and of course updating the song info in thbgm.fmt so that you don't have issues like the song cutting off early, or ruining other songs due to mismatching offsets.

So far I have used it just fine on Mountain of Faith and Impossible Spellcard.