Plants vs. Zombies 2 Hacking Guide/Rip or modify audio

The audio in Plants vs. Zombies 2 is stored in the OBB as either WEM or BNK files. After unpacking the OBB, two direct subdirectories can be found which contain the audio stored in the game:

* `./soundbanks/`, which contains groups of audio files (soundbanks), as BNK files.
* `./streamingwaves/`, which contains other, singular audio files, as WEM files.

Unlike many other proprietary file formats found in the OBB, WEM and BNK do not belong to PopCap, but rather a separate video game audio software company, Audiokinetic. The files are generated by one of Audiokinetic's audio workspace applications, Wwise. However, although Wwise is designed to generate these files, it does not provide an easy way to read or convert external WEM or BNK files that have already been generated, but some other tools (such as ww2ogg) have been created that allow users to further manipulate these files.

This article will go over how to convert files between common and proprietary formats and how to replace the audio files so that they play in Plants vs. Zombies 2.

Tutorials here are written for Windows and the Android international OBB.

## See also

* Plants vs. Zombies 2 Hacking Guide/OBB and RSB file structure - Overview of the proprietary file formats and the rest of the OBB.

## Convert WAV to WEM

*WEM files in Plants vs. Zombies 2 are monophonic and use the Vorbis compression format. WEMs found elsewhere or generated otherwise may not be compatible with Plants vs. Zombies 2.*

1. **Convert the WAV files to mono.** Ensure that the WAV files are mono (meaning they do not have stereo or surround channels). If not, then use an audio editor (like Audacity) to collapse or remove the audio channels.
2. **Install Wwise.** Wwise is the application used to convert WEM files into WAV files.
3. **Start the Wwise Launcher and launch Wwise.** Click on the "Wwise" tab in the launcher. Then click the button reading, "Launch Wwise".
4. **Open or create a Wwise project.** After Wwise has launched, you will be prompted with a dialog asking to open or create a project. The name and the imported assets do not matter.
5. **Import the WAV files to convert.** Go to *Project* > *Import Audio Files...*. In the Audio File Importer dialog, click "Add Files..." and select all the WAV files to convert. Then click "Import".
6. **Select the imported files.** Locate the newly imported files in the Project Explorer panel under *Actor-Mixer Hierarchy* > *Default Work Unit* and select them.
7. **Change the compression settings to use the Vorbis format.** WEM files in Plants vs. Zombies 2 use the Vorbis compression format.
	1. In the Sound Property Editor panel, click the "Conversion" tab.
	2. In the "Conversion Settings" fieldset, change the Mode to "Define Custom", and then click "Edit...".
	3. In the Conversion Settings Editor dialog, locate the dropdown in the "Format" column, and select "Vorbis".
8. **Convert the audio files.** Go to *Project* > *Convert All Audio Files...*. In the dialog, leave "Windows" checked and click "OK".
9. **Locate the newly generated WEM files.** Go to *Project* > *File Manager..*. In the File Manager dialog, right-click the "Project Folder" field and click "Open Containing Folder", which should open the project directory in Windows Explorer. From there, navigate to `./.cache/Windows/SFX/`. The WEM files should be in this directory; you can now copy them as you please.

*If you do not convert to mono or set the compression to Vorbis, then Plants vs. Zombies 2 will not be able to read the audio file and will crash when it tries to play it.*

## Replace audio files

After converting your audio files to WEM files, you can now copy them to an unpacked OBB directory created by Taiji.

Replacing a WEM is just a matter of overwriting it with the new WEM file. To swap in a new WEM file, remove the old file and copy the new file in its place with the filename of the old file.

If you want to replace the audio in a soundbank, then first unpack the BNK with Taiji, locate the WEMs in the unpacked BNK directory, and swap in the WEM like before. Then, repack the BNK and delete the unpacked BNK directory.

After replacing all the desired WEMs or BNKs, you can now repack the OBB with the new audio and swap in the new OBB.

Note that your audio may not play exactly the same; often, the game will apply live effects to the audio (like changing speed or pitch) in-game.

## Convert WEM to WAV, or BNK to WEMs

Taiji can convert the audio assets that are already present, in case you want to rip the game's audio. This can also be useful if you need to identify a WEM file before replacing it.

Additionally, ww2ogg can convert from WEM to OGG, and bnkextr can extract the WEMs from a BNK. However, bnkextr cannot pack WEMs back into a BNK.