Touhou Vorbis Compressor is broken as of 2013-06-06

Issue #18 new
Anonymous created an issue

I don't know if this issue is already known, so I thought I'll point it out just to make sure.

I have the music data for each game in the .ogg format. As of the build version 2013-06-06 and onwards, all the games no longer play the .ogg files, so no music is heard. Previous builds work fine.

Sorry if that isn't enough info needed to solve the problem, but I used the "Touhou Vorbis Compressor" program to convert the music to .ogg. Thanks in advance :-)

Comments (4)

  1. nmlgc repo owner

    Yeah, I know, I broke it.

    The reason why it's broken are our own AppLocale-like Unicode compatibility hacks, which overwrite Windows system function calls using import address table patching - the same thing the Vorbis Compressor does exclusively.

    Back when I wrote it, I did not deal with all these Unicode problems that Windows' ancient API design causes. I hadn't found a good solution for these until fairly recently - and 2013-06-06 was the first build of thcrap to have it.

    Hence, you can only either have full Unicode support without AppLocale or Vorbis-compressed music. Due to the apparent lack of popularity of the Vorbis Compressor and the fact that locale problems are perhaps the single biggest cause of bugs in Touhou, I opted for the former.

    All in all, I need to fix this problem in the Vorbis Compressor first, then change to a less exclusive method of patching, and then somehow have thcrap scan for it and issue a message to all users of the old Vorbis Compressor version to update.

    (Of course, porting the Vorbis Compressor to the thcrap engine would be a much better solution. But since we're not doing any verification of downloaded code right now, DLLs in patches are a rather scary thing.)

    So yeah, it's not something that's a high priority for me at this point. However, if you think it should be, Bitbucket has recently introduced a voting feature for these issues...

  2. nmlgc repo owner

    I just happened to solve the theoretical problem that was causing this mess. From the next build on, it will be possible to chain multiple wrappers for one single Windows API function inside thcrap, as long as their order doesn't matter (and for most reasonable things, it doesn't.)

    Thus, I've now also decided on a way to tackle this issue:

    • Reimplementing the Vorbis Compressor as a thcrap plugin is the only thing that makes sense. Adding workarounds to deal with the 2011 release would still undermine thcrap's own locale independence. Fixing this problem in thvorbis would work for now, but could potentially cause even more incompatibilities with third-party patches in the future (yes, I still firmly believe we'll get some of those eventually). Furthermore, people would have to update thvorbis, which would be rather difficult to pull off.

    • When BGM Vorbis compression is reimplemented, it will only be one specific use case of full-fledged BGM replacement using Vorbis files. One modder has already asked for custom BGM, and the implementation of that will be pretty similar to how thvorbis works. (Most importantly, it will once again leverage bitstream chaining to implement looping without having to rely on or patch thbgm.fmt.)

    However, this is still going to take a while to happen. It will happen eventually - I'm all for adding features that make thcrap appear as more of what it actually is - a modkit - rather than focusing on that one specific use case of translation patches. But well, we're still very busy with the latter. :(

  3. nmlgc repo owner

    Since bitstream chaining is a property of the Ogg container, the BGM modding feature could also support other audio codecs that can be wrapped into Ogg, not just Vorbis.

    Thus, I spent some time looking into the other Xiph.org codecs today. Ogg-FLAC is definitely going to be supported for BGM modding as a lossless alternative as well.

    (I also considered including the new Opus codec - but with its native sampling rate of 48000 KHz and lack of support for the 44100 KHz audio used by the games, it doesn't seem like a viable option to me.)

  4. Log in to comment