Last active
April 18, 2023 13:57
-
-
Save YoRyan/e581d5cf81b11e8d411223b917571d42 to your computer and use it in GitHub Desktop.
Extract the soundtrack from Sid Meier's Civilization VI and its expansions with PowerShell. No piracy - this requires your own copy of the game.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# To run in the PowerShell ISE, first execute: | |
# > Set-ExecutionPolicy -Scope Process -ExecutionPolicy Unrestricted | |
# on the interactive console. | |
$OutputPath = "." | |
# Path to directory containing ww2ogg executable and codebook - https://github.com/hcs64/ww2ogg | |
$Ww2OggPath = ".\ww2ogg024\" | |
# Path to revorb executable - https://hydrogenaud.io/index.php/topic,64328.msg574110.html#msg574110 | |
$RevorbExec = ".\revorb.exe" | |
# Path to Civ 6 ;) | |
$Civ6Path = "D:\SteamLibrary\steamapps\common\Sid Meier's Civilization VI" | |
function Extract-Sound-Bank ($bank_path, $bank_guid, $out_path) | |
{ | |
New-Item -ItemType directory -Path $out_path -Force | |
foreach ($node in (Select-Xml -Path $bank_path -XPath "//SoundBank[@GUID='$bank_guid']/ReferencedStreamedFiles/File").Node) { | |
$wem_filename = "$($node.Attributes['Id'].Value).wem" | |
$track_name = $node["ShortName"].InnerText.TrimEnd(".wav") | |
Extract-Track "$(Split-Path $bank_path)\$wem_filename" "$out_path\$track_name" | |
} | |
} | |
function Extract-Track ($input_wem, $output_basename) | |
{ | |
$ogg = "$($output_basename).ogg" | |
& "$Ww2OggPath\ww2ogg.exe" $input_wem -o $ogg --mod-packets --pcb "$Ww2OggPath\packed_codebooks_aoTuV_603.bin" | |
& $RevorbExec $ogg | |
} | |
Extract-Sound-Bank "$Civ6Path\Base\Platforms\Windows\audio\Music_Bank.xml" ` | |
"{AD4D06FD-95CA-42CD-9536-9ADB0555E7E1}" "$OutputPath\Base Game" | |
Extract-Sound-Bank "$Civ6Path\DLC\Expansion1\platforms\windows\audio\XP1_Music_Bank.xml" ` | |
"{35A96671-6E7A-47C1-8182-B9C013C814A5}" "$OutputPath\Rise and Fall" | |
Extract-Sound-Bank "$Civ6Path\DLC\Expansion2\platforms\windows\audio\XP2_Music_Bank.xml" ` | |
"{1CFDCA39-4887-4B25-A73D-83CB57253F42}" "$OutputPath\Gathering Storm" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment