Author Topic: Looking for a way to extract Legacy of Lunatic Kingdom's music into .flac files  (Read 6781 times)

So that's what I want. I've the soundtracks for all the official games in flac files, but not for Legacy of Lunatic Kingdom. I downloaded an app named Music Room dedicated to directly extract music from the games, but LoLK is still not supported even though it came out in 2015. So, do any of you know of an alternative approach that would let me get the .flac music files I want?

Thank you for reading  :)

I literally just figured this out, else I would have posted sooner!

You can import the thbgm file as raw data into Audacity, which will bring the soundtrack up as one 46 minute audio track. Crop as needed and save as FLAC. There are small gaps of silence between tracks so it's easy to see where one ends/begins, but I've noticed they end shortly into a second loop.
« Last Edit: March 06, 2017, 05:40:06 AM by ElaineSpencer »

Sage Ω (Ultima)

  • CEO at Team Eternal Desire
  • ??? X
So as chance would have it, I released a tool a made to extract or replace all of the songs from the games. It doesn't export to flac format but there are many tools that can convert to that format so it shouldn't matter too much.

This tool extracts the data to uncompressed wav files which are the original format of the music itself.

The tool can be found in this thread.

Touhou Music Room does actually support LoLK, and can extract its soundtrack directly into FLAC. You just need to download the th15 BGM file and copy it into the Music Room's "bgminfo" folder.
Playing Touhou since 18 March 2012. Playing video games since 19XX.
Normal 1CC: EoSD, PCB, IN, PoFV, MoF, SA, UFO, TD, DDC, HSiFS, CtC.
Extra 1CC: EoSD, PCB+Phantasm, IN, PoFV (K&S), MoF, SA, TD, HSiFS, CtC+Phantasm.
Hard 1CC: EoSD, PCB, IN, MoF, TD, CtC.
Lunatic 1CC: EoSD

Ooh, man! I completely forgot about my post, so I'm really sorry to be reviving it now.

Thing is, I'm trying to do what @shockdude told me, but I can't seem to get Music Room to work.

When I open the application I can't find any option to load a game.

http://i127.photobucket.com/albums/p150/Near150/Th%20Music%20Room%201_zpsss54o5co.png

And when I try to directly drop a folder containing game/s or the game .exe directli into it, I get this...

http://i127.photobucket.com/albums/p150/Near150/Th%20Music%20Room%202_zpsiaijwpma.png

No compatible game found. And doesn't matter which one it is, including the original, unmodified and unpatched .exe files.

Thanks in advance and excuse me again for reviving this old post.

Arcorann

  • hey catgirl
  • Surprisingly unkempt
I'm surprised no-one mentioned thbgmextractor, the tool that's been around since forever and still the most versatile in terms of extraction options. Grab the title file from here (titles_th15.txt, either file works). The only issue is that one has to have an encoder for FLAC already installed and either convert afterwards or try to configure the encoder hooks.

EDIT: To configure the encoder hook, assuming that a copy of flac.exe is in the folder (if flac.exe is elsewhere replace with its full path), add the following to Encoders.conf:
Code: [Select]
[FLAC default / FLAC 1.3.2, file out]
 executable = flac.exe
 arguments  = "%THBGM_INPUTFILEPATH%" -o "%THBGM_OUTPUTFILEPATH%"
 extension  = flac
 stdin      = no
The tags will be added automatically based on what is entered into the Tags tab. By default these are the tags in the title files, which are in Japanese. If you want English I suggest replacing the tags manually before extracting (edit on the Tags tab for the song titles, go to Edit -> Edit tags... to do the artist and album).
« Last Edit: April 19, 2017, 12:22:38 PM by Arcorann »

Such fast answer, thanks  :)

Even so, I'd like to know what's wrong with T?h? Music Room, since it's seems easier to use at least at first glance. I've seen around ther a capture of the app:



And as you can see, there's a great difference with my captures: the "Select Game Directory..." option is not greyed out.

Maybe it's because my copies of the games are not actually installed? Being honest here: all of my games were... you know. Even so, now that I'm living in Japan, I bought all of them -to support ZUN for all the enjoyment he has brought to me-. So maybe I should install them from the CDs for T?h? Music Room to work...?

Arcorann

  • hey catgirl
  • Surprisingly unkempt
The interface in your screenshots seems strangely empty. I can see that there are several missing labels, such as the Japanese/English switcher on the top left. I don't know what is causing this but this definitely isn't normal. Could you check to make sure all of the files are there, particularly the bgminfo folder?

That's what happens when the Music Room config file is missing.

also it looks like the Touhou Music Room link went down. That's unfortunate.
I've attached my Music Room here. It's been customized with all mainline Touhou games, more music CDs, and even updated FLAC and LAME libraries.

Edit: Fixed "The Rabbit Has Landed"
« Last Edit: April 23, 2017, 06:06:37 PM by shockdude »
Playing Touhou since 18 March 2012. Playing video games since 19XX.
Normal 1CC: EoSD, PCB, IN, PoFV, MoF, SA, UFO, TD, DDC, HSiFS, CtC.
Extra 1CC: EoSD, PCB+Phantasm, IN, PoFV (K&S), MoF, SA, TD, HSiFS, CtC+Phantasm.
Hard 1CC: EoSD, PCB, IN, MoF, TD, CtC.
Lunatic 1CC: EoSD

The same is still happening after trying with your download :(

And of course in shockdude's download I've the bgminfo folder.

I've replicated your issue. The Music Room doesn't work if it's contained in a directory containing non-english characters. If your Windows login name contains non-English characters like accents, welp.
You need to move the Music Room to a folder that contains only English characters. "F:\Disc Dur\Touhou Music Room" should work.
Playing Touhou since 18 March 2012. Playing video games since 19XX.
Normal 1CC: EoSD, PCB, IN, PoFV, MoF, SA, UFO, TD, DDC, HSiFS, CtC.
Extra 1CC: EoSD, PCB+Phantasm, IN, PoFV (K&S), MoF, SA, TD, HSiFS, CtC+Phantasm.
Hard 1CC: EoSD, PCB, IN, MoF, TD, CtC.
Lunatic 1CC: EoSD

It was exactly this!! Now it works! Thank you all!!  :D

.... But. For some reason, it doesn't work with Seiran's theme. It says something like it might be protected against writing (wtf). Would it be too much if anyone uploaded just that one for me?

oops. Fixed, updated the original attachment.
Playing Touhou since 18 March 2012. Playing video games since 19XX.
Normal 1CC: EoSD, PCB, IN, PoFV, MoF, SA, UFO, TD, DDC, HSiFS, CtC.
Extra 1CC: EoSD, PCB+Phantasm, IN, PoFV (K&S), MoF, SA, TD, HSiFS, CtC+Phantasm.
Hard 1CC: EoSD, PCB, IN, MoF, TD, CtC.
Lunatic 1CC: EoSD

Yep, now I got it  ;) Thank you.

Just out of curiosity: what was the problem?

Great, enjoy!

Touhou Music Room used to be able to download song info from TouhouWiki, but that doesn't work anymore.
For The Rabbit Has Landed, my copy had downloaded an invalid track title containing illegal filename characters, which prevented it from being exported. I fixed it by manually editing the bgm file.
Playing Touhou since 18 March 2012. Playing video games since 19XX.
Normal 1CC: EoSD, PCB, IN, PoFV, MoF, SA, UFO, TD, DDC, HSiFS, CtC.
Extra 1CC: EoSD, PCB+Phantasm, IN, PoFV (K&S), MoF, SA, TD, HSiFS, CtC+Phantasm.
Hard 1CC: EoSD, PCB, IN, MoF, TD, CtC.
Lunatic 1CC: EoSD

Drake

  • *
That's probably because whoever edited the wiki put a ref tag in the english title field, so pulling that title yields illegal characters.

A Colorful Calculating Creative and Cuddly Crafty Callipygous Clever Commander
- original art by Aiけん | ウサホリ -

If you want to do the hard (but effective) way, here's how I rip music from the games:

1. Find the offsets and sizes of each track (and its loop points). For the main games, it's usually stored in "thbgm.fmt" (for LoLK at least). LUCKILY FOR YOU HOWEVER, there is this site which already took care of this step for you. Just download the "titles_th15.zip" file and open the text file, which contains, in some sort of list format, the (hexadecimal) offset for the music in the thbgm file in bytes, the size of the intro (part that doesn't loop) also in bytes, and the size of the looping section yet again in bytes.
2. Use a hex editor and open the thbgm.dat file. Copy all the data corresponding to the entire music track and paste it into a new file. Name it whatever you want, it's just raw uncompressed data.
3. Open Audacity. Select "File > Import > Raw Data" and open the new saved file which is the portion of the thbgm file.
4. Select "Signed 16-bit PCM" encoding, "Little endian" endianness, and stereo. Set start offset to 0 and amount to import to 100%, and set sample rate to 44100Hz (TD spirit world tracks are 22050Hz, however!).
5. Done! Now if you play it, you'll hear the music!

But let's say you want to extend the track a bit? Simple.

6. Change the time format of Audacity by clicking the arrows next to the timers and stuff at the bottom (unless you moved it) to "samples."
7. Set "Selection Start" to the starting loop point. Since each sample is 2 bytes and the music is in 2 channels, the starting loop point will be [size of the intro section in bytes / 4]. Set "Selection Length" to the size of the looping portion of the music (again, this would be the size you got from the titles file divided by 4 since it's in bytes).
8. Done! You got your loop section selected. With any luck, you should probably have something similar to this now: (this is Emotional Skyscraper ~ Cosmic Mind, but you get the idea)

Do Shift+Play and watch as the end of the track loops perfectly!
9. Copy-paste this section as much as you want to, maybe add some fade-out after 2 or so loops, and export as FLAC!

Hope this wasn't *too* complex and that it helped. :)

Oookay. Thanks a lot for taking your time for explaining me this, but I think I'll settle with T?h? Music Room for now  :ohdear: Even so, if I ever have problems with it in the future I can go back to this thread and try your method, so thanks!

Arcorann

  • hey catgirl
  • Surprisingly unkempt
LUCKILY FOR YOU HOWEVER, there is this site which already took care of this step for you. Just download the "titles_th15.zip" file and open the text file, which contains, in some sort of list format, the (hexadecimal) offset for the music in the thbgm file in bytes, the size of the intro (part that doesn't loop) also in bytes, and the size of the looping section yet again in bytes.

If you're downloading a title file, you might as well use the program it was designed for (i.e. thbgmextractor), which I linked above.

I had the idea of creating a pack of titles files for all games, and having one set for kanji titles, one for romaji titles and one for English titles. Maybe I should do that when TH16 comes out.

Oh crap I had no idea that's what the program did. Whatever, at least now you'll know how to do it in the future for recently-released titles lol.