This article holds info about existing tools to extract, play or otherwise modify Touhou game BGM files.

All of the tools are built for Windows only, however some have source code included and therefore it might be possible to get them to work on other platforms.


Touhou Project BGM Extractor - an English GUI utility by NamelessLegacy written in C (visual studio build, source code included!). Supports all Windows Touhou games and a few others. Easily understandable and highly configurable; song playback and comment display, automatic translation downloading from the independent Touhou Wiki, data files for individual games, multiple ways of specifying intervals, built-in tagging in either Japanese or English and flac/ogg/mp3 encoding. Seems like it supersedes all other utilities made so far.

thbgmextractor - a Japanese GUI utility written in C# (visual studio build, source code included!). It has the ability to produce loops and fade-out, with a diagram visualising it. It also has configurable hooks for encoders like lame, oggenc and wma. Uses standard titles_thXX.txt data files, supports th06 and above.

thbgmtowav - a Japanese/English commandline tool by T. Solamarle written in C (gcc build, source code not included). It has the ability to produce loops, fade-out and silence. Uses standard titles_thXX.txt data files, supports th07 and above (and th06 after some hacking). Needs to have the thbgm.dat file in the same directory and extracts into the same directory. The output file name format is thbgm_XX.wav; ignores names in data file. Does not handle the extended titles file format (w/ input file names).

Thbgm-tool - a bundle of simple specialized commandline binaries to rip out bgm from th07, th07.5, th08 and th09 bgm data files. The author is unknown, C source code is available for the th09 extractor. They have the ability to produce loops and fade-out. Doesn't use any config files, all data is hardcoded. Those binaries that generate Japanese filenames need to run under the Japanese Locale to work properly.

Brightmoon - a generic touhou data file extractor w/ GUI; source code included, author unknown. Can be used to crack open the packed SWR/th105b.dat and UNL/th123b.dat, which store the soundtrack as Ogg Vorbis audio and Soundforge loop metadata. Can be combined with th105towav.php / th123towav.php, oggdec and thbgmtowav to produce looped output.


thplay - 東方蓄音機 (Touhou Gramophone) (Japanese)

bgmforall - BGM For All Version 1.1 By 野风信子 (Chinese)

THxxBGM - 東方BGM Player (Japanese)

Other utilities

th08bgm_patch - Binary patcher to fix several audio glitches in Imperishable Night's BGM file (source code included)

thbgmchg - BGM changer

thplay Data Convert - Create a custom bgm.dat file for thplay

Data Files

There is a common format for files that store information about BGM names and their positions in thbgm.dat files. The usual naming convention is titles_thXX.txt.

Here are some sources of these files:


Aside from a few special cases, all Touhou BGMs are meant to loop infinitely. Since no wave-based format I know of lets you specify looping rules, they are stored in separate files. The instructions themselves are essentially an offset into the wave data stream to mark the beginning of the loop, and a length value (or alternatively, end position). If the loop does not reach the end of the file, the part after the loop will never play.

Here's a brief description of how each game stores its loop data:


  • wave files in bgm/*.wav
  • loops in 紅魔郷MD.dat/*.pos
    <start sample>.4b <end sample>.4b

TH07 and above (Team Shanghai Alice games)

  • wave data in thbgm.dat, loops in th<xx>.dat/thbgm.fmt
    • Format: { <waw name>.16b <start offset>.4b <???>.4b <intro length>.4b <total length>.4b 0x0100020044ac000010b102000400100000000000 }.52b* <zeroes?>+


  • wave files and loop data in th075bgm.dat/*.wav (Brightmoon archive)
  • loop data is saved with special RIFF chunks at the end of each wave file
    • Format: <RIFF header>.40b <wave data size>.4b <wave data>.<wave data size>b <junk>.16b <start sample>.4b <junk>.40b <loop section length>.4b

TH10.5 and above (Tasofro games)

  • ogg files in th<xxx>b.dat/*.ogg, loops in th<xxx>b.dat/*.sfl; loops are stored inside Soundforge metadata, some tracks don't have loops
    • Format: <junk>.28b <start sample>.4b <junk>.40b <length in samples>.4b

All wave files are 44100 Hz 16 bit stereo. When dealing with sample-based loop data (th06/tasofro games), multiply the sample values by 4 and add the size of the wave header (0x2C = 44 bytes) when calculating byte offsets.

Community content is available under CC-BY-SA unless otherwise noted.