Touhou Patch Center:BGM modding: Difference between revisions

From Touhou Patch Center
Jump to navigation Jump to search
(Translatability seems to be needed here.)
Line 1: Line 1:
== BGM Modding Tutorial==
<translate>
== For [[:Category:Team Shanghai Alice|Team Shanghai Alice games]] ==
(Ripped straight from discord)
(Ripped straight from discord)


Line 16: Line 17:


===How to name your files===
===How to name your files===
Check out the '''data filename''' column in [https://docs.google.com/spreadsheets/d/14-DAv89VNzIXPM2q4mLBJXUIck_K1fWNuBLo9cF_kaA/edit#gid=0 Splashman's BGM list], as well as thcrap_log.txt (Ctrl-F for flac > ogg > mp3) to make sure you got the names right.
Check out the '''data filename''' column in [https://docs.google.com/spreadsheets/d/14-DAv89VNzIXPM2q4mLBJXUIck_K1fWNuBLo9cF_kaA/edit#gid=0 Splashman's BGM list], as well as thcrap_log.txt (Ctrl-F for <tt>flac > ogg > mp3</tt>) to make sure you got the names right.


===File layout===
===File layout===
You can put the files into either the patch root or the game-specific subdirectory. Usually, you'd go with the patch root – プレイヤーズスコア is th10_17 in TH10–TH12, and th128_08 in ≥TH12.8, and by only putting those two files into the patch root directory, you'd cover all of these (and future) games. But you can still use the game-specific subdirectory if you want a separate Player's Score for specific games, even in addition to putting a generic file into the patch root.<br />
You can put the files into either the patch root or the game-specific subdirectory. Usually, you'd go with the patch root – プレイヤーズスコア is <tt>th10_17</tt> in TH10–TH12, and <tt>th128_08</tt> in ≥TH12.8, and by only putting those two files into the patch root directory, you'd cover all of these (and future) games. But you can still use the game-specific subdirectory if you want a separate Player's Score for specific games, even in addition to putting a generic file into the patch root.<br />
Also, for consistency with later games, BGM mods for TH06 don't go into a separate bgm/ subdirectory, contrary to what the original files might suggest.
Also, for consistency with later games, BGM mods for TH06 don't go into a separate bgm/ subdirectory, contrary to what the original files might suggest.


Line 28: Line 29:


===Looping===
===Looping===
Each original track can be represented by two audio files in your patch: An intro file using the same filename as the original, and an optional looping file with .loop before the extension. So, for a TH06 title screen mod in Ogg Vorbis format, these would be th06_01.ogg and th06_01.loop.ogg.<br />
Each original track can be represented by two audio files in your patch: An intro file using the same filename as the original, and an optional looping file with <tt>.loop</tt> before the extension. So, for a TH06 title screen mod in Ogg Vorbis format, these would be <tt>th06_01.ogg</tt> and <tt>th06_01.loop.ogg</tt>.<br />
Looping is handled internally by simply rewinding the currently playing file after it finished playing. Any loop values from the game or loop point mods are ignored.<br />
Looping is handled internally by simply rewinding the currently playing file after it finished playing. Any loop values from the game or loop point mods are ignored.<br />
This means that you can omit the .loop file, put the entire track into the "intro file", and thcrap will just loop that.
This means that you can omit the .loop file, put the entire track into the "intro file", and thcrap will just loop that.
Line 39: Line 40:
For your first MP3, double-check whether the audio editor you want use for loop cutting actually supports the LAME extension for gapless MP3. (GoldWave v6.35 and Audacity 2.3.0 don't.) To do this, convert the MP3 to a FLAC or WAV using something that does (I used foobar2000 v1.4), and check whether your editor shows the same amount of silence at the beginning of both the FLAC/WAV and the MP3.<br />
For your first MP3, double-check whether the audio editor you want use for loop cutting actually supports the LAME extension for gapless MP3. (GoldWave v6.35 and Audacity 2.3.0 don't.) To do this, convert the MP3 to a FLAC or WAV using something that does (I used foobar2000 v1.4), and check whether your editor shows the same amount of silence at the beginning of both the FLAC/WAV and the MP3.<br />
If it doesn't, always convert to a FLAC/WAV file to "apply" the removal of the MP3 pre-gap, and use that converted file to determine the loop start/end samples. (After the loop works, you'd just throw away that lossless file.)
If it doesn't, always convert to a FLAC/WAV file to "apply" the removal of the MP3 pre-gap, and use that converted file to determine the loop start/end samples. (After the loop works, you'd just throw away that lossless file.)
Then, use pcutmp3 (attached below) on the command line to perform sample-accurate cutting. Yes, you unfortunately need Java for this.<br />
Then, use [[:File:pcutmp3.zip|pcutmp3]] on the command line to perform sample-accurate cutting.
java -jar pcutmp3.jar --crop 1:0-123,1:123-456 "C:\path\to\the\original.mp3", with 123 being the loop start, and 456 being the loop end sample.<br />
 
[[File:pcutmp3.zip]]
Yes, you unfortunately need Java for this. No, mp3DirectCut will ''not'' work.
 
<tt>java -jar pcutmp3.jar --crop 1:0-123,1:123-456 "C:\path\to\the\original.mp3"</tt> with 123 being the loop start, and 456 being the loop end sample.<br />


===Caveats and ZUN bugs===
===Caveats and ZUN bugs===
You can purchase fixes for all of those! Please talk to me if you're interested!
You can purchase fixes for all of those! Please talk to Nmlgc if you're interested!
 
* TH06 is the only game where BGM mods can have any sample rate, bit depth, and channel count.
* TH06 is the only game where BGM mods can have any sample rate, bit depth, and channel count.
* TH06: Performance on track switches could be improved a bit.
* TH06: Performance on track switches could be improved a bit.
* TH09: Make sure that your modded title screen BGM has at least 0.3 seconds of silence in the beginning. For some reason, the game always wants to play the title screen theme for a tiny amount of time before switching to the actual conversation theme at the start of a stage. :zun:
* TH09: Make sure that your modded title screen BGM has at least 0.3 seconds of silence in the beginning. For some reason, the game always wants to play the title screen theme for a tiny amount of time before switching to the actual conversation theme at the start of a stage. :zun:
* TH11: Similar issue, but with the Stage 6 theme: The game starts playing a few milliseconds of it when entering the stage, then pauses playback, and only resumes it ~4.9 seconds later.
* TH11: Similar issue, but with the Stage 6 theme: The game starts playing a few milliseconds of it when entering the stage, then pauses playback, and only resumes it ~4.9 seconds later.
* TH13: Performance when switching to the trance tracks and back could be improved a bit.
* TH13: Performance when switching to the trance tracks and back could be improved a bit.


==Tasofighter BGM modding (Th13.5, Th14.5 and Th15.5)==
== For Tasofighters (TH13.5, TH14.5, TH15.5) ==


[https://aocf.koumakan.jp/User:VasteelXolotl From VasteelXolotl's AoCF Wiki Page]<br />
[https://aocf.koumakan.jp/User:VasteelXolotl From VasteelXolotl's AoCF Wiki Page]<br />
Line 100: Line 108:
===4) Custom loop points===  
===4) Custom loop points===  
Use Egor's sfl-loop tool [[File:sflloop_v2.zip]].
Use Egor's sfl-loop tool [[File:sflloop_v2.zip]].
</translate>

Revision as of 15:17, 25 February 2019

For Team Shanghai Alice games

(Ripped straight from discord)

Supported formats, from highest to lowest priority

  • FLAC (.flac)
    Ideally, you've acquired your modded BGM in a lossless format, and FLAC support allows you to provide these directly to your players.
  • Ogg Vorbis (.ogg)
    Currently the best compromise between compression and sound quality. Limited to 16-bit.
  • MP3 (.mp3)
    Only use this if you have no other choice and your modded BGM is so obscure/ancient that it simply was never released in another format. Also the most difficult to loop correctly, and not repatchable in ≥TH07.

These formats are compatible with all thcrap supported ZUN shooters (th06-th16.5).

More formats? Talk to me! (Nmlgc)

Patch stacking

  • When stacking multiple BGM patches, the priority order above is evaluated per-patch, before moving to the next one. Meaning, an MP3 from a higher patch in the stack will always override a FLAC from a lower one.
  • Loop files must always be in the same patch and the same format as the intro file.

How to name your files

Check out the data filename column in Splashman's BGM list, as well as thcrap_log.txt (Ctrl-F for flac > ogg > mp3) to make sure you got the names right.

File layout

You can put the files into either the patch root or the game-specific subdirectory. Usually, you'd go with the patch root – プレイヤーズスコア is th10_17 in TH10–TH12, and th128_08 in ≥TH12.8, and by only putting those two files into the patch root directory, you'd cover all of these (and future) games. But you can still use the game-specific subdirectory if you want a separate Player's Score for specific games, even in addition to putting a generic file into the patch root.
Also, for consistency with later games, BGM mods for TH06 don't go into a separate bgm/ subdirectory, contrary to what the original files might suggest.

As for the patches themselves, I recommend this layout if you offer both lossless and lossy patches:

  • <patchname>_base: Modded images and Music Room comments, all tracks that are only available as MP3. Dependency on base_tsa
  • <patchname>: Lossless source tracks converted to Vorbis. Dependency on <patchname>_base
  • <patchname>_lossless: Lossless source tracks. Dependency on <patchname>_base

Looping

Each original track can be represented by two audio files in your patch: An intro file using the same filename as the original, and an optional looping file with .loop before the extension. So, for a TH06 title screen mod in Ogg Vorbis format, these would be th06_01.ogg and th06_01.loop.ogg.
Looping is handled internally by simply rewinding the currently playing file after it finished playing. Any loop values from the game or loop point mods are ignored.
This means that you can omit the .loop file, put the entire track into the "intro file", and thcrap will just loop that.

If you have lossless source files, you'd obviously want to cut those into two before converting the two resulting files to Vorbis, in case you want to offer a lossy patch.

If, for some reason, you want no loop, and the track should just stop after it finished playing: That's equivalent to "looping a short amount of silence". Putting exactly 4 seconds of silence into the corresponding .loop file would be the most performant option.

How to loop MP3 files

For your first MP3, double-check whether the audio editor you want use for loop cutting actually supports the LAME extension for gapless MP3. (GoldWave v6.35 and Audacity 2.3.0 don't.) To do this, convert the MP3 to a FLAC or WAV using something that does (I used foobar2000 v1.4), and check whether your editor shows the same amount of silence at the beginning of both the FLAC/WAV and the MP3.
If it doesn't, always convert to a FLAC/WAV file to "apply" the removal of the MP3 pre-gap, and use that converted file to determine the loop start/end samples. (After the loop works, you'd just throw away that lossless file.) Then, use pcutmp3 on the command line to perform sample-accurate cutting.

Yes, you unfortunately need Java for this. No, mp3DirectCut will not work.

java -jar pcutmp3.jar --crop 1:0-123,1:123-456 "C:\path\to\the\original.mp3" with 123 being the loop start, and 456 being the loop end sample.

Caveats and ZUN bugs

You can purchase fixes for all of those! Please talk to Nmlgc if you're interested!

  • TH06 is the only game where BGM mods can have any sample rate, bit depth, and channel count.
  • TH06: Performance on track switches could be improved a bit.
  • TH09: Make sure that your modded title screen BGM has at least 0.3 seconds of silence in the beginning. For some reason, the game always wants to play the title screen theme for a tiny amount of time before switching to the actual conversation theme at the start of a stage. :zun:
  • TH11: Similar issue, but with the Stage 6 theme: The game starts playing a few milliseconds of it when entering the stage, then pauses playback, and only resumes it ~4.9 seconds later.
  • TH13: Performance when switching to the trance tracks and back could be improved a bit.

For Tasofighters (TH13.5, TH14.5, TH15.5)

From VasteelXolotl's AoCF Wiki Page

The above includes example music replacement packs.

Music replacements are fully client-side and do not affect netplay in any way. You also don't actually touch the game's files, as this is a "softmod" through thcrap.

1) Setup

Make a new folder under thcrap's directory. Name it whatever you want, I just went with "bgm155" for simplicity.
In that folder, make another called "th155", then under that one make "data", then "bgm". Go back to the main thcrap folder for now.

Somewhere in there should be a .js file named after your default configuration. If you haven't messed with anything when installing the english patch, it should be "en.js". Copy and paste it. Rename the copy to "bgm155.js". Open it in a text editor of your choice.

The opened file should look similar to this
1.PNG
Add your patch to this. Throw it in after all the other ones to prevent any issues. Make the file look more or less like this and save it.
2.PNG

Now find your th155 thcrap shortcut and once again copy-paste it. Rename it to something convenient. Right click it and click Properties, then go into the Shortcut tab in the window that shows up. At the end of the Target field, change "en.js" to "bgm155.js". Press OK.

You've got everything set up. Neat.

2) Actually replacing music

Each theme has 3 files - two .ogg files (one of which is simply just the music to play in-game, and the other is a 20-second preview for the stage select) and an .sfl file containing loop metadata for the in-game theme.
Rename them to fit AoCF's file names. For convenience, here they are
https://pastebin.com/KaC3s2vV .

Remember all those folders you made? Go down to the "bgm" folder and place the files you want there. Boom, you did it.

3) Changing in-game music titles

So you changed Marisa's theme to the objectively superior one, switched Nitori's theme to Aya's or something else entirely. There's one small problem, though - the music title doesn't match. You wanna fix that? Sure you do, or else it'll keep bugging you for all eternity.

In the "bgm" folder, make a new file called "bgm.csv.jdiff". Open it in a text editor of your choice. Remember the numbers in brackets in the other paste? They'll come in handy now. Open a curly bracket in the first line. In the second line, type in the number of the theme you want to change in quotes, then a colon and another curly bracket, e.g "2": {

In the next line, type in "7": "[track title]"

If you want to change the name of the arranger/composer as well, you can do it as such in the next line: "8": "[composer name]"

Afterwards, close the curly bracket in the next line with }. Repeat the above as many times as necessary, then add another }. You're done. Here's my jdiff file, if you need a reference
jdiff.PNG

4) Custom loop points

Use Egor's sfl-loop tool File:sflloop v2.zip.