Infernus_Animositas

Dragon's Dogma - Dark Arisen PC BGM Audio Modding Tutorial

Jan 12th, 2016
16,692
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 9.41 KB | None | 0 0
  1. THIS GUIDE IS GETTING UPDATED WHEN I LEARN SOMETHING NEW ABOUT THE FORMAT AND ITS LIMITATIONS. SO CHECK BACK PERIODICALLY.
  2.  
  3. So you want to swap out the BGM in game for something else you'd prefer. I got you covered.
  4. Foreword: If you have never used a hex editor before, this might be a challenge for you as there is hex editing involved.
  5.  
  6. Author's note:
  7. BACK UP EVERYTHING YOU INTEND TO REPLACE!
  8. IF YOU FORGET TO PUT IN EVEN JUST ONE SINGLE BYTE OR FORGET TO RENAME A FILE EXTENSION, THE GAME CAN AND MOST LIKELY WILL CRASH!
  9. So please be careful :)
  10.  
  11.  
  12. Tools needed
  13. ARCTool - Decompress and repack .arc archives
  14. OGGEnc 2.85 - The same vorbis libary the game uses. This is important if you want to put in a proper 5.1 surround sound audio file and I'll explain why later on.
  15. A Hex editor - I use Hex Workshop myself.
  16. Audacity
  17.  
  18. Tools can be downloaded here:
  19. https://mega.nz/#!KsEXESgQ!s4oDCCMu_ILMl-GcemnSK5T-kpxkFCviXYgqcwJkqTI
  20.  
  21.  
  22. UPDATE: If your custom track is just stereo, you don't need to make it into 6 channel WAV and then convert it into OGG. Do the following if this the case:
  23.  
  24. Import your custom track into Audacity
  25. Set the Project Rate (Hz) to 48000
  26. Export it as an OGG.
  27. Note down the file size of your OGG and its total samples.
  28.  
  29. You would only need OGGEnc if you were putting in a 6 channel OGG. After you have converted your custom track, locate the filename of the track you want to replace and then go to the "Unpacking the .ARC file" section.
  30.  
  31.  
  32. ========================================
  33. Locating the file you want to replace
  34. ========================================
  35.  
  36. Go to the folder where the BGM is kept:
  37. nativePC\sound\stream\bgm\wave
  38.  
  39. All of these .sngw files are actually just Vorbis encoded audio files. If you rename them to .ogg they will playback with any media player just fine. If you do rename them, don't forget to change the extension back or the game won't run.
  40.  
  41. Once you've found the music file you want to replace in-game, make a note of its filename
  42. e.g. Lich_DragonZonbi.sngw and then change back any file extensions as needed.
  43.  
  44.  
  45. ==========================================
  46. Making your own 5.1 surround audio file
  47. ==========================================
  48.  
  49. UPDATE: Skip this section if your custom track is just stereo. Remember, you will still need the file size of the custom OGG and its total samples.
  50.  
  51. Open up your music file in Audacity
  52. In the bottom left hand corner, set the Project Rate (Hz) to 48000. This is important or you will get weird sounding audio during gameplay
  53. Go to Edit > Preferences > Import / Export
  54. On the "When exporting tracks to an audio file" select the "Use custom mix" (for example to export a 5.1 multichannel file).
  55. Now, assuming your track that you want to import is Stereo, add four more mono tracks to give you a total of six.
  56.  
  57. Next, if you just want your file to loop from the start of the file to the end, you don't have to worry about anything right here.
  58. However, if there are specific points that you want it to loop, select the arrow down the bottom of the window where the text "Selection Start" is and change it to Samples.
  59. Locate the exact samples you want your audio to loop from and make a note of them both. LoopStart and LoopEnd.
  60.  
  61. Export your audio track. Give it the same name as the track you want to replace in the game.
  62. The type should be "WAV (Microsoft) 32-bit float PCM"
  63. When presented with the Advanced Mixing Options, make each track connect straight accross to the channel opposite it as shown in this picture.
  64. http://i.imgur.com/2AYB2tH.jpg
  65.  
  66.  
  67. =========================
  68. Encoding your music file
  69. =========================
  70.  
  71. UPDATE: Skip this section if your custom track is just stereo. Remember, you will still need the file size of the custom OGG and its total samples.
  72.  
  73. Next we're going to encode your music file to OGG now. The reason we are using this encoder is because newer encoders of Vorbis use the Vorbis I specification. When you encode a 5.1 surround sound file using a newer encoder, it maps the channels as follows:
  74. Front Left, Front Center, Front Right, Rear Left, Rear Right, LFE
  75.  
  76. Now the .sngw files that the game uses (and other MT Framework games) use is the WAVE format. It maps the channels as follows: Front Left, Front Right, Front Center, LFE, Rear Left, Rear Right.
  77.  
  78. tl;dr The channels won't line up correctly if you don't use the correct encoder.
  79.  
  80.  
  81. Go to the oggenc_2.85_libvorbis-1.2.3_SSE2 folder and copy your new 32 bit WAV music file in there.
  82. Run the Convert.bat and it will convert your WAV into OGG.
  83.  
  84. Or if you want to do it manually, hold down the shift key and then press right-click and select "Open command window here"
  85.  
  86. Type in the following
  87. oggenc2 <name of your .WAV file>
  88. e.g. oggenc2 DD_Entrance.wav
  89.  
  90. Get the file size in bytes of the newly created ogg and make a note of it.
  91. Open up your ogg file in audacity and get the total number of samples the file is and make a note of it as well.
  92. Change the extension from .ogg to .sngw
  93. Go to the bgm folder
  94. nativePC\sound\stream\bgm\wave
  95.  
  96. Backup the original file of what you want to replace and paste your .sngw file.
  97.  
  98.  
  99. =========================
  100. Unpacking the .ARC file
  101. =========================
  102.  
  103. Now we have to unpack the bbs_rpg.arc using ARCTool - This is where all but 5 of the BGM files other data is read by the game engine.
  104. (StaffRoll_A, StaffRoll_B and Coils_of_Light's other data is kept in stage802.arc and stage804.arc, Tittle_DDN.sngw and gamestart.sngw are in title.arc)
  105.  
  106. Go to the ARCTool folder and copy the bbs_rpg.arc file into it and then run the Extract.bat file
  107. After it's unpacked, navigate to bbs_rpg\sound\stream\bgm
  108.  
  109.  
  110. =========================
  111. Hex Editing the BGM.STQ
  112. =========================
  113.  
  114. Open up the bgm.stq in a hex editor
  115.  
  116. Take a look at the table I've made. You can view it here:
  117. https://docs.google.com/spreadsheets/d/1rxsEWprQiBQnG51Kp4VFBPryQnLzhoI65zk8I6bojMc/edit?usp=sharing
  118. Note: Anything in a (Hexadecimal) colummn with quotations "" around certain entries are only there to keep the spreadsheet software from doing a command. Basically, just ignore the quotation marks.
  119.  
  120. Find the filename of the music file you want to replace. The second column "Song ID (Hexadecimal)" gives you the Song ID. The Song ID is a hex value, not a text string. So if you can't find it when you do a search, that is probably why.
  121.  
  122. Do a search for your music file's song ID in BGM.STQ and it will take you exactly where you can find the data of the song you want to replace.
  123.  
  124.  
  125. This is where the math starts to come into the tutorial (sort of).
  126.  
  127.  
  128. The first four bytes are the Song ID that we searched for, the next four bytes are file size for the .sngw file
  129. These values given are for the original music file, we are going to overwrite them.
  130.  
  131. Open up calculator, set it to Programmer and make sure it's on "Dec".
  132. Put in the file size of the ogg file you created and then click the "Hex" radio button.
  133. e.g. my file size is 7705703 bytes, so converted to hex it is 759467.
  134.  
  135. Now we have to put that value into the .stq but in reverse.
  136. For me, I would put in 679475, but that's only three bytes in length. 67 94 75. We need to add a 00 to it to complete it and make it four bytes. You can tell if you've done it right, because if you highlight what you just replaced, the int32/uint32 number should show the file size of your OGG exactly.
  137.  
  138. The next four bytes after that are the total samples. It's the same process with the calculator
  139. Put in the total number of samples in "Dec", change it to "Hex"
  140. e.g my file's total samples is 5309970 and in hex that is 510612.
  141. Put the numbers in backwards, mine is 12 06 51 and again that is only 3 bytes so we add a 00 to the end to make it four bytes exactly.
  142.  
  143. The next four bytes is the number of channels. The default is six channels so most likely it will show "06 00 00 00".
  144. Change 06 to one of the following as needed for your custom track
  145.  
  146. 06 = 5.1 Surround
  147. 02 = Stereo
  148. 01 = Mono
  149.  
  150. For example if your custom track is stereo, change the 06 to a 02 instead.
  151.  
  152. The next four bytes are the LoopStart
  153. If you have a specific sample you want your song to loop from do the same as before with the calculator
  154. If you want the song to loop from the very start, put "01 00 00 00"
  155. If you do not want the file to loop but just play once, put in "FF FF FF FF" which is "-1"
  156.  
  157. The final four bytes are the LoopEnd
  158. If you have a specific sample you want your song to loop to, just do the same as before with the calculator
  159. If you want the song to loop at the very end, copy and paste the total samples number you got previously
  160. If you do not want the file to loop but just play once, put in "FF FF FF FF" which is "-1"
  161.  
  162. Save the bgm.stq file
  163.  
  164.  
  165. ================================
  166. Repacking the bbs_rpg.arc
  167. ================================
  168.  
  169. Go back to the ARCTool directory.
  170. Rename the original .arc to something else and keep it as a backup.
  171. Run ARCTool from the command line.
  172.  
  173. Put in the following to repack the bbs_rpg folder into bbs_rpg.arc
  174. arctool -c -dd -alwayscomp -v 7 -pc -txt bbs_rpg
  175.  
  176. After it has completed, copy the newly created bbs_rpg.arc to
  177. nativePC\rom
  178. Paste in the new bbs_rpg.arc in the folder.
  179.  
  180.  
  181. Run the game and test it, if the game crashes, you did something wrong. Put back the original bbs_rpg.arc and all will be well!
  182.  
  183. Then try again if you feel so inclined :)
  184.  
  185.  
  186. ==============
  187. THANKS
  188. ==============
  189.  
  190. Thanks goes out to the creators of ARCTool, Audacity and to the Xiph foundation.
  191.  
  192. -Infernus Animositas
Advertisement
Add Comment
Please, Sign In to add comment