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.
