Touhou Patch Center:BGM modding/zh-hans

对于上海爱丽丝幻乐团制游戏
（以下内容直接抄自Discord）

支持的文件格式
越上面的格式越优先被读取. 理想情况下，你已经获得了一个无损格式的修改过的BGM，FLAC支持允许你直接向你的玩家提供这种格式. 目前而言压缩率和音质之间的最佳折衷格式. 限制16位. 只有当你别无选择，且你修改过的BGM过于冷门或太老以至于它从未以另一种格式发布时才使用该格式. 此格式最难完成曲目循环，且不可在≥TH07的游戏中被二次补丁.
 * FLAC (.flac)
 * Ogg Vorbis (.ogg)
 * MP3 (.mp3)

所有thcrap支持的ZUN制STG（th06～th16.5）均可以使用上述格式.

想要更多的格式支持？请通过Discord告诉我！——Nmlgc

关于补丁叠加

 * 如果应用了多个BGM补丁，在应用下一个补丁之前，BGM补丁的优先级会按照上面的格式顺序重新排列. 这意味着即使你把MP3补丁先打上了，也会被原本低优先级的FLAC格式的补丁覆盖.
 * 循环节文件必须和引子文件在同一个补丁包里，并使用相同的文件格式.

文件名格式
在Splashman制作的BGM表（谷歌文档）中查找data filename列中查找名称. 也可以在thcrap_log.txt中使用Ctrl+F搜索 flac > ogg > mp3 确保你拿到了对应的名字.

文件层级
你可以把BGM文件放在补丁根目录或者特定游戏的目录. 一般情况下是放在补丁目录的.

特别的，对于Player's Score（疮痍曲），在TH10～TH12中应用请命名为 th10_17 ，在≥TH12.8中应用则命名为 th128_08 ，且必须放置于补丁根目录才能覆盖不止一个游戏. 当然，如果只想改特定游戏的疮痍曲，可以把文件放置于特定游戏的目录. 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.

对于补丁而言，如果你同时提供无损和有损格式的BGM补丁，建议采用如下格式命名和制作补丁：
 * <补丁名>_base: 改过的图和音乐室曲评，只提供MP3全曲，依赖补丁base_tsa
 * <补丁名>: 由无损格式转换出的OGG格式，依赖补丁<补丁名>_base
 * <补丁名>_lossless: 无损格式. 依赖补丁<补丁名>_base

循环播放
每一首原曲可以被两个BGM文件替换（补丁）掉：一首引子曲文件，命名和原文件一样；以及一首循环节曲文件，在原来的扩展名前额外加入 .loop. 那么，对于TH06的标题曲，如果是OGG文件，这两个文件就是 th06_01.ogg 和 th06_01.loop.ogg.

循环在程序内部处理，只需在当前播放的文件播放完后倒回去重放即可，thcrap忽略来自游戏本身或循环点MOD的任何循环值.

这意味着你可以省略.loop文件，将整个曲目放入引子文件，这样thcrap将只循环该文件. 否则在引子文件播放后将无限循环.loop文件中的曲子.

如果你有无损的源文件，那么，在将无损转化为两个OGG之前，最好先把该文件切成两个文件，以免最后导出的OGG出现音质损耗.

如果某些情况下你不希望曲子自动循环，曲子应该在一次播放后结束播放，这相当于“循环一段短暂的沉默”. 在相应的.loop文件中放入4秒的空缺音频是最有效的选择.

怎样使 MP3 文件也能循环播放
对于MP3文件，仔细检查用于循环剪切的音频编辑器是否真的支持无间隙MP3的LAME扩展（已知GoldWave v6.35 和 Audacity 2.3.0 不支持）. 要做到这步，将MP3转码为FLAC或WAV（我是用foobar2000 v1.4转的），然后检查编辑器中，对于FLAC/WAV文件和MP3文件，两者开头的空白是否一样长.

如果不一样，则必须每次编辑前用原来的MP3转一个FLAC/WAV来去除MP3预置空白的干扰，并总是使用FLAC/WAV文件来定位循环头和循环尾. （当然，编辑完就可以扔掉这个无损文件了） 然后，使用命令行工具 pcutmp3 进行精确的循环节裁剪.

但是很不幸，你需要Java才能执行这个操作. 没有Java，mp3DirectCut将不会工作. 好了，还有谁想要用MP3的？

java -jar pcutmp3.jar --crop 1:0-123,1:123-456 "C:\path\to\the\original.mp3" → 123作为循环头，456作为循环尾

注意事项以及ZUN bug
You can purchase fixes for all of those! 如果你感兴趣，请联系Nmlgc！


 * TH06（红魔乡）是唯一的BGM支持任意码率、任意比特深度、任意声道数的游戏.


 * TH06（红魔乡）：音轨切换的性能能提升一点.


 * TH09（花映冢）：确保你修改的标题曲一开始有至少0.3秒的空白. 出于某种原因，游戏总是希望在正式切换到关卡对话前播放一小段标题BGM. :zun:


 * TH11（地灵殿）：同上，但只针对6面道中曲：游戏会在进入6面关卡时播放几毫秒，然后突然暂停，再从曲目时间轴的4.9秒后继续播放曲目.


 * TH13（神灵庙）：音轨切换的性能能提升一点.

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

https://cdn.discordapp.com/attachments/475336678379356172/475356364903022593/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.

https://cdn.discordapp.com/attachments/475336678379356172/475356367188787235/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

https://cdn.discordapp.com/attachments/475336678379356172/475367273134293022/jdiff.PNG

4) Custom loop points
Use Egor's sfl-loop tool.