Editing KTSL2ASBIN files - three-houses-research-team/Throne-of-Knowledge GitHub Wiki

Tools

Guide

Locating your file

First, you'll have to locate the KTSL2ASBIN file you plan to work with. The very first KTSL2ASBIN entry ID is 31010, which corresponds to Male Byleth (Academy era) The characters are ordered by ID, so the next one is Edelgard and so on. If you want to work with "War era" files, the first ID is 31096.

Extracting

There are multiple ways to extract and listen to files packed in a KTSL2ASBIN.

VGMToolbox

I am currently not going to write an extensive guide on how to use VGMToolbox, so if you feel like you're skilled enough to use it, here are the arguments to split a KTSL2ASBIN into .vgmstream files. (Screenshot courtesy of DeathChaos25)

(You can click on the picture to see it in original size)

Now, put the TXTH file from earlier in the same directory as your extracted file.

Good ol' hex editing

Using 010 Editor and the KTSR.bt template linked earlier, you will find that there are multiple "info_section" entries. (Note that this template is old and may still change, if this isn't relevant anymore, please ask in the Discord server) Each of these entries is a voice file encoded with the GCADPCM codec. By clicking on one of those entries, 010 Editor will automatically select the relevant bytes for you. You may now right click on the selection and do "Selection -> Save Selection". Pick a name that makes it easy for you to remember what section you are currently working on and use the "vgmstream" extension.

Now, put the TXTH file from earlier in the same directory as your extracted file.

Testing

First, try listening to your file in Foobar to make sure you extracted everything properly. If you get an error while trying to play it, make sure the TXTH file is in the same directory and is named ".vgmstream.txth", period in front included.

If everything seems fine, you can now open the .vgmstream file in 010 Binary and apply the KTGLADPCM.bt file you downloaded earlier.

Conversion

Now, using the VGAudio version from earlier, you will need to convert your new voiceline to a GCADPCM file. To do so, use the following command in a terminal:

VGAudioCli.exe input.wav output.dsp --out-format gcadpcm

Of course, you will need to replace "input.wav" by the name of your own file. (File extension is at your discretion, as long as it is supported by VGAudio)

Now, open the output.dsp file in 010 Editor and use the "dsp.bt" template. Put it side to side with the .vgmstream file you extracted earlier.

Injection (VGMStream)

(Note: DSP files are in big endian while KTSLGCADPCM are in little endian so convert them accordingly) Now that you have both files opened side by side, do the following:

  • In the VGMStream file, delete the "Stream_Data stream"
  • In the DSP file, select the "AudioData" section. Remember the size of the selection in bytes
  • Paste it at the end of your VGMStream.
  • Change the "stream_size" value in the VGMStream by the size of the AudioData section.
  • Replace the "sampleCount" value of the VGMStream by the "NimbleCount" value from the DSP.
  • Replace both "Duration" values by the result of this formula: sampleCount - (sampleCount / 8)
  • Replace the "clippedSampleCount" value by the result of this formula: sampleCount - 1
  • In the VGMStream, replace all 16 DSP coefficients by those in the DSP. Note: As mentionned previously, DSP files are in Big Endian, meaning you need to permute every pair of bytes. Example: 05 AC in DSP becomes AC 05 in the VGMStream
  • Replace both "Sample rate" in VGMStream by the one in the DSP
  • Select the entirety of the VGMStream, look at the selected size, and write it in the "Total File size" field
  • Now, replace the "Audio Data size" by the result of the following formula: Total File Size - 0x20

Once you're done, save your VGMStream file next to the TXTH file and listen to it in Foobar. If every went well, you should now hear your injected voice line!

Injection (KTSL2ASBIN)

Now, go back to the KTSL2ASBIN and find the section you extracted. Select the entirety of the section and delete it. Now, paste the entirety of the VGMStream file in its stead (Make sure your 010 Editor is in INSert mode and not OVR mode. You can check this in the bottom right corner of the window) Save the file and you're done! You can now replace the original file from the game with your favorite patching method.

KTSS (Will soon be moved out)

Conversion guide for KTSS

Use in a command prompt with the following command:

VGAudioCli.exe input.wav output.ktss --bitrate "150000" --CBR --opusheader ktss