-
Notifications
You must be signed in to change notification settings - Fork 7
Description
Description:
Currently, bnk-extract-GUI allows users to extract and modify .wem audio files from .bnk and .wpk files. However, it lacks the ability to add new .wem files to a .wpk file and properly associate them with specific events in a .bnk file.
To fully support this, modifications must be made to both the .wpk container and the .bnk file structure, ensuring the correct integration of newly added .wem files.
Proposed Implementation:
1. Extending the .wpk File Structure
- Append new .wem files to the .wpk file while maintaining the integrity of its internal indexing.
- Update the file table inside .wpk to include the newly added .wem file references, adjusting offsets accordingly.
- Ensure that the new .wem files are properly compressed and encoded to match the existing audio format (e.g., Vorbis, PCM, or ADPCM).
2. Understanding and Modifying the .bnk File Header
The .bnk file header plays a crucial role in event handling and sound playback. It contains:
- File Signature & Version – Identifies the file as a .bnk and determines compatibility.
- Sound Table Offset – Points to the section of the file where individual sounds are mapped to event IDs.
- Event Table – Defines which sounds (by ID) are triggered by specific in-game events.
- Stream/Memory Flags – Specifies if a sound should be streamed or fully loaded into memory.
- Checksum/Validation Data – Ensures integrity of the .bnk file after modification.
Modifications Required:
- Extract the existing event-to-sound ID mappings from the .bnk file.
- Assign a new sound ID to each newly added .wem file.
- Modify the event table inside .bnk to point to the new sound IDs.
- Ensure that file offsets, checksums, and pointers remain consistent after modification.
3. UI & Functionality Enhancements
Add a "Import .wem to .wpk" option in the GUI, allowing users to add new sound files.
Provide a dropdown or mapping tool to associate imported .wem files with specific events in the .bnk file.
Implement a preview function to test new mappings before finalizing changes.
Challenges & Considerations
Some games may implement proprietary header variations, requiring additional parsing logic.
Certain .bnk files include checksum validation; research may be needed to bypass or recompute checksums.
The tool should warn users if existing sound IDs are overwritten and provide an undo option for safety.
Benefits:
✅ Allows users to add new sounds to the game without external repacking tools.
✅ Provides direct control over event-to-sound mapping within .bnk files.
✅ Expands the functionality of bnk-extract-GUI, making it a more powerful modding tool.