Skip to content

Instantly share code, notes, and snippets.

@stupidpupil
Last active January 26, 2023 21:05
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save stupidpupil/d7ad71c944002f04c4b790376880ac8b to your computer and use it in GitHub Desktop.
Save stupidpupil/d7ad71c944002f04c4b790376880ac8b to your computer and use it in GitHub Desktop.

I note that I've done most of my actual file and audio processing under either macOS or Linux, where I'm much more familiar with the scripting tools. I might not be able to help you as much I'd like.

General advice for trying to make a voice pack

I'd suggest taking a look at my voicepack template or at least Kregano's tutorial that it's based off.

Why? Well, Kregano's tutorial covers using a script (by robojumper) that fixes several problems with the built-in approach to voice 'banks', and my template then tries to help you avoid having to decide what to name bits of code and stuff.

If you do try my template, I suggest calling your project and your mod something like 'SlickSlothGrenadierVoice' or something (without spaces, and the same name for the project and mod) otherwise it ends up even more confusing in places...

Getting CoH2 sound files into XCOM 2

Converting .smf files to .ogg - a workaround

I wrote the section below first, but actually Audacity seems to be able to open .smf files directly. I guess it just ignores the bits it can't understand and interprets it as an Ogg Vorbis file?

So you can probably just skip the next bit.

Converting .smf files to .ogg - in bulk

.smf files from CoH2 contain Ogg Vorbis compressed audio, but they have 16 bytes of something at the start of them, so the trick is to cut that off. Mostly people talk about doing this by hand with a hex editor, which is clearly a pain to do for lots at once. (To be clear, they're not "Standard Midi Files" - that's just a coincidence.)

The Ruby script below uses the Unix command tail to take each smf file in the same directory as it, skip until the 17th byte and then pass that to ffmpeg to copy into a .ogg file (just to make sure that the container file is correctly structured).

Dir.glob("*.smf") do |in_name|
  out_name = File.basename(in_name, '.smf')+".ogg"

  `tail -c +17 "#{in_name}" | ffmpeg -i - -acodec copy "#{out_name}"`
end

I'm not what the best approach is under Windows, because I don't know that it includes utilities built for this sort of thing. You might able to use this version of dd and then maybe something like this (saved as a .bat file and run in a folder with the dd.exe and all the .smf files):

forfiles /s /m *.smf /c "dd.exe if=@path of=@path.ogg skip=16"

Converting oggs to wav

XCOM2 (/ Unreal Engine 3) requires its sound files to be in a particular format - mono, 16-sample 44.1kHz PCM wave files.

The easiest thing is probably just to use Audacity - which will also let you fiddle with the volume, add a radio effect filter and so on - and then export to the correct format. I think Kregano's tutorial covers this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment