FileForums

FileForums (https://fileforums.com/index.php)
-   Conversion Tutorials (https://fileforums.com/forumdisplay.php?f=55)
-   -   How to correctly process WWise Vorbis Audio | Guide + WemTool (https://fileforums.com/showthread.php?t=104859)

Masquerade 30-12-2021 11:22

How to correctly process WWise Vorbis Audio | Guide + WemTool
 
1 Attachment(s)
How to correctly process WWise Vorbis Audio | Guide + WemTool

Good evening everybody,

I am sure we have all seen audio in *.wem format before. This is a very common type of audio in games and is made by WWise sound engine. The audio in the .WEM format can either be Vorbis (you may know this as *.OGG) or WAVE audio (*.WAV).

Wems that contain WAV audio can be already compressed by ProFrager's Media Streams Compressor just fine and is not the focus of this guide.

Instead, I would like to explain the best way to compress the Vorbis wems. For normal vorbis audio, we would use ProFrager's OGGRE compressor however ProFrager also made a separate version of OGGRE for WWise vorbis. In order to gain the benefits of this tool, you could follow these steps:
  1. Use WW2OGG on your wem file to convert the *.wem file to an *.ogg file.
  2. Compress this *.ogg file with the WWise OGGRE encoder.
  3. Decompress the compressed file with the WWise OGGRE decoder
  4. Patch the decompressed output to the original *.wem file using your patch engine of choice. I like to use HDiffZ since it makes the smallest patches, however XDelta will be sufficient here.

This is a very basic process. However, from reading the above steps - you wil be thinking - how on Earth am I meant to use OGGRE (WWise version) with FreeArc?

The answer is, we don't. Because Oggre WWise can only proccess one file at once and not many files. FreeArc would bundle all of your *.oggs together in $$arcdatafile$$.tmp. Because we cannot use FreeArc for this (it would crash because the decoded output of the compressed *.ogg file DOES NOT MATCH the input file to the encoder), we have to go down a different route. Attempting to individually compress each *.wem file in a game where there could be thousands of wems is a nonsense task, so instead I simplified it.

I would like to introduce WemTool - a wrapper for several tools which will parallel process all of your wem files.
Code:

WemTool [For Vorbis WWise Audio]

 Available Options:

 -e : encode wems
 -d : decode wems

 Example Usage:

 WemTool.exe -e
 WemTool.exe -d

Please note that this is a very simple program and WemTool.exe contains the following tools:

- WW2OGG by hcs64
- MParallel by LoRd_MuldeR
- Oggre WWise by ProFrager
- HDiffZ by sisong

In order to use it, simply drop WemTool.exe into the root of the game folder that contains *.wem files and run it from command line with either encode or decode option. WemTool will compress all the *.wem files possible (it runs recursive) and then delete the successfully compressed wems, leaving a *.ww file and a *.DIFFZ file which then can be decoded by WemTool back into a *.wem. All CPU threads are used. If any *.wem files are left after WemTool has run, it means that they contain Wave audio and you should compress them with MSC instead.

To demonstrate on a sample of *.wem files from the game "Old World":
https://i.ibb.co/Jxyq1KN/ex-comparison.png

My apologies for the long read. I hope you understand what has just been explained, but this is certainly a lot more wordy than I would have desired.

Please note that I did little to no coding here, it's Bat2Exe + all aforementioned tools, so all credits here go to ProFrager, LoRd_MuldeR, hcs64 and sisong for their tools which all are used by this program.

L33THAK0R 01-01-2022 00:18

Quite an interesting read, well done putting this all together in such a cohesive post!

Masquerade 15-01-2022 13:53

WemTool v2
  • Moved from MTP to MParallel - increased console output, but everything seems to be working just fine now. Test on a sample before your game.

Snake288 15-01-2022 15:47

hello, if I may, the voice of God *.wem would like to ask your support on how to reduce the size of wem files the sample video can be a very understandable training video.

fabrieunko 15-01-2022 23:26

Hello, thank you works well on Gow on the other hand how to use it with an installer? is there one that supports it or do you have to do a .bat? who would run the -d function after decompressing the .bin?

Masquerade 16-01-2022 00:07

Quote:

Originally Posted by fabrieunko (Post 495439)
Hello, thank you works well on Gow on the other hand how to use it with an installer? is there one that supports it or do you have to do a .bat? who would run the -d function after decompressing the .bin?

Put this after your archive extraction via ISDone:
Code:

Exec2(ExpandConstant('{app}\WemTool.exe'), '-d')

fabrieunko 16-01-2022 03:23

Thank you, can you help me? I use

Windows Phone Installer (DSG)

I have identified the ISdone line which I think is the correct one and the line Exec2

Code:

function ISArcExtract(CurComponent: Cardinal; PctOfTotal: Double; InName, OutPath, ExtractedPath: AnsiString; DeleteInFile: Boolean; Password, CfgFile, WorkPath: AnsiString; ExtractPCF: Boolean): Boolean; external 'ISArcExtract@{tmp}\ISDone.dll stdcall delayload';
function IS7ZipExtract(CurComponent: Cardinal; PctOfTotal: Double; InName, OutPath: AnsiString; DeleteInFile: Boolean; Password: AnsiString): Boolean; external 'IS7zipExtract@{tmp}\ISDone.dll stdcall delayload';
function ISRarExtract(CurComponent: Cardinal; PctOfTotal: Double; InName, OutPath: AnsiString; DeleteInFile: Boolean; Password: AnsiString): Boolean; external 'ISRarExtract@{tmp}\ISDone.dll stdcall delayload';
function ISPrecompExtract(CurComponent: Cardinal; PctOfTotal: Double; InName, OutFile: AnsiString; DeleteInFile: Boolean): Boolean; external 'ISPrecompExtract@{tmp}\ISDone.dll stdcall delayload';
function ISSRepExtract(CurComponent: Cardinal; PctOfTotal: Double; InName, OutFile: AnsiString; DeleteInFile: Boolean): Boolean; external 'ISSrepExtract@{tmp}\ISDone.dll stdcall delayload';
function ISxDeltaExtract(CurComponent: Cardinal; PctOfTotal: Double; MinRAM, MaxRAM: Integer; InName, DiffFile, OutFile: AnsiString; DeleteInFile, DeleteDiffFile: Boolean): Boolean; external 'ISxDeltaExtract@{tmp}\ISDone.dll stdcall delayload';
function ISPackZIP(CurComponent: Cardinal; PctOfTotal: Double; InName, OutFile: AnsiString; ComprLvl: Integer; DeleteInFile: Boolean): Boolean; external 'ISPackZIP@{tmp}\ISDone.dll stdcall delayload';
function ShowChangeDiskWindow(Text, DefaultPath, SearchFile: AnsiString): Boolean; external 'ShowChangeDiskWindow@{tmp}\ISDone.dll stdcall delayload';

function Exec2 (FileName, Param: PAnsiChar;Show: Boolean): Boolean; external 'Exec2@{tmp}\ISDone.dll stdcall delayload';

should I replace the line (just above) with this one?

Code:

Exec2(ExpandConstant('{app}\WemTool.exe'), '-d')

:( Sad8669 16-01-2022 03:41

An alternative way is to execute a bat file through Inno Setup.

Code:

[Run]
Filename: "{app}\your bat.bat"; Parameters: "install"; Flags: runhidden

where the bat contains commands to run WemTool.exe.

KaktoR 16-01-2022 03:43

Quote:

Originally Posted by fabrieunko (Post 495443)
Thank you, can you help me? I use

Windows Phone Installer (DSG)

I have identified the ISdone line which I think is the correct one and the line Exec2

Code:

function ISArcExtract(CurComponent: Cardinal; PctOfTotal: Double; InName, OutPath, ExtractedPath: AnsiString; DeleteInFile: Boolean; Password, CfgFile, WorkPath: AnsiString; ExtractPCF: Boolean): Boolean; external 'ISArcExtract@{tmp}\ISDone.dll stdcall delayload';
function IS7ZipExtract(CurComponent: Cardinal; PctOfTotal: Double; InName, OutPath: AnsiString; DeleteInFile: Boolean; Password: AnsiString): Boolean; external 'IS7zipExtract@{tmp}\ISDone.dll stdcall delayload';
function ISRarExtract(CurComponent: Cardinal; PctOfTotal: Double; InName, OutPath: AnsiString; DeleteInFile: Boolean; Password: AnsiString): Boolean; external 'ISRarExtract@{tmp}\ISDone.dll stdcall delayload';
function ISPrecompExtract(CurComponent: Cardinal; PctOfTotal: Double; InName, OutFile: AnsiString; DeleteInFile: Boolean): Boolean; external 'ISPrecompExtract@{tmp}\ISDone.dll stdcall delayload';
function ISSRepExtract(CurComponent: Cardinal; PctOfTotal: Double; InName, OutFile: AnsiString; DeleteInFile: Boolean): Boolean; external 'ISSrepExtract@{tmp}\ISDone.dll stdcall delayload';
function ISxDeltaExtract(CurComponent: Cardinal; PctOfTotal: Double; MinRAM, MaxRAM: Integer; InName, DiffFile, OutFile: AnsiString; DeleteInFile, DeleteDiffFile: Boolean): Boolean; external 'ISxDeltaExtract@{tmp}\ISDone.dll stdcall delayload';
function ISPackZIP(CurComponent: Cardinal; PctOfTotal: Double; InName, OutFile: AnsiString; ComprLvl: Integer; DeleteInFile: Boolean): Boolean; external 'ISPackZIP@{tmp}\ISDone.dll stdcall delayload';
function ShowChangeDiskWindow(Text, DefaultPath, SearchFile: AnsiString): Boolean; external 'ShowChangeDiskWindow@{tmp}\ISDone.dll stdcall delayload';

function Exec2 (FileName, Param: PAnsiChar;Show: Boolean): Boolean; external 'Exec2@{tmp}\ISDone.dll stdcall delayload';

should I replace the line (just above) with this one?

Code:

Exec2(ExpandConstant('{app}\WemTool.exe'), '-d')

No!

Use it in "procedure CurStepChanged" CurStep = ssPostInstall

I don't know this script, but it should look something like this
Code:

procedure CurStepChanged
...
..
if (CurStep = ssPostInstall) then begin
...
Exec2(ExpandConstant('{app}\WemTool.exe'), '-d')
..


fabrieunko 16-01-2022 03:53

Thanks Kaktor, do you think this is good?

Code:

procedure CurStepChanged(CurStep: TSetupStep);
var
  ResultCode: Integer;
begin
  if CurStep = ssInstall then
  begin
    CreateDir(ExpandConstant('{app}\Uninstall'));
    FileCopy(ExpandConstant('{tmp}\botva2.dll'),ExpandConstant('{app}\Uninstall\botva2.dll'),True);
    FileCopy(ExpandConstant('{tmp}\dark.png'),ExpandConstant('{app}\Uninstall\dark.png'),True);
    FileCopy(ExpandConstant('{tmp}\light.png'),ExpandConstant('{app}\Uninstall\light.png'),True);
    FileCopy(ExpandConstant('{tmp}\Setup1.jpg'),ExpandConstant('{app}\Uninstall\Setup1.jpg'),True);
    FileCopy(ExpandConstant('{tmp}\Symbol Font.ttf'),ExpandConstant('{app}\Uninstall\Symbol Font.ttf'),True);
    FileCopy(ExpandConstant('{tmp}\bahnschrift.ttf'),ExpandConstant('{app}\Uninstall\bahnschrift.ttf'),True);
    Unpack_Process(not RamLimitChk.IsChecked);
  end;
  if (CurStep = ssPostInstall) and ISDoneError then
  begin
    SetTaskBarProgressValue(100);
    SetTaskBarProgressState(TBPF_ERROR);
    Exec(ExpandConstant('{uninstallexe}'), '/VerySilent','', sw_Hide, ewWaitUntilTerminated, ResultCode);

  end;
  if (CurStep = ssPostInstall) and not ISDoneError then
  begin
    Exec2(ExpandConstant('{app}\WemTool.exe'), '-d')
  #ifdef Redist1


KaktoR 16-01-2022 04:16

Should be fine

fabrieunko 16-01-2022 04:22

Thank you very much for your help, I appreciate helping beginners like me. I have a last question about the executable Wemtool.exe where should I put it? next to my installer.ISS?

KaktoR 16-01-2022 04:34

You can either include it into your installer ([Files] section, DestDir: "{app}") or directly include it into game folder before compression.

Snake288 16-01-2022 05:18

WemTool help with usage
information about the way it is used as a video or image
The God of War (*.wem) How can I compress multiple files? and how to restore compressed files

KaktoR 16-01-2022 05:30

Quote:

Originally Posted by Snake288 (Post 495451)
WemTool help with usage
information about the way it is used as a video or image
The God of War (*.wem) How can I compress multiple files? and how to restore compressed files

Make backup of all *.wem files first.

Put WemTool.exe in GodofWar game folder
Create a batch file in same folder
Code:

"E:\Games\GodofWar\WemTool.exe" -e
Execute the batch file and wait for finish

Compress the game

After installing/unpacking with your installer, let the installer run WemTool.exe with -d parameter (explained a few posts above).

Finish

Snake288 16-01-2022 05:42

can you show me an example of how I can create a batch file ?

another request (https://fileforums.com/showthread.php?t=104867 ) it is located in the connection (installation.exe) how (WemTool.exe with -d parameter) (installation.can I add it to the exe)?

:( Sad8669 16-01-2022 06:03

Create a new text document, insert command WemTool.exe -d/e and rename ".txt" to ".bat".

Snake288 16-01-2022 10:07

Exec2(ExpandConstant('{app}\WemTool.exe'), '-d')

the above code is located below (Installer Script_3.0.0.1.b9_[2021.09.11].isp) I want to add can I get help?

InstallerScript_3.0.0.1.b9_[2021.09.11].iss

.iss.html]InstallerScript_3.0.0.1.b9_[2021.09.11].iss - 1.1 MB

Masquerade 16-01-2022 11:17

Quote:

Originally Posted by fabrieunko (Post 495449)
Thank you very much for your help, I appreciate helping beginners like me. I have a last question about the executable Wemtool.exe where should I put it? next to my installer.ISS?

Put WemTool in the archive which you are compressing or you can add it as a file in the inno script and extract it via ExtractTemporaryFile (you will need to make sure that you tell Inno to extract it to {app} in the [Files] section and not {tmp}).

fabrieunko 16-01-2022 11:56

thank you I will test in the next few days, but is it normal for lines of code to scroll at full speed with this version of wemtool? I didn't see this in the old version.

Masquerade 16-01-2022 13:44

Quote:

Originally Posted by fabrieunko (Post 495462)
thank you I will test in the next few days, but is it normal for lines of code to scroll at full speed with this version of wemtool? I didn't see this in the old version.

Yes, normal, mparallel is more verbose than mtp.

Dragonis40 11-05-2022 05:55

Hello everybody! Once all .wem files have been compressed by Wemtool, which is the best compression method for .ww and .dffz file? Do I have to use ogg encoder or what? Thank you for your answer!

Masquerade 11-05-2022 08:50

Quote:

Originally Posted by Dragonis40 (Post 496770)
Hello everybody! Once all .wem files have been compressed by Wemtool, which is the best compression method for .ww and .dffz file? Do I have to use ogg encoder or what? Thank you for your answer!

Just srep+lzma or something light + fast. The ww files are already compressed and so are the diffs (diffs are compressed with lzma2).

wareck 24-08-2024 13:22

hi
just a little tip...
At the end of its process, wemtool searches in its working folder for all “.DIFFZ” files and deletes them.
So if you have other patches to execute during the installation, think of renaming them otherwise...
It sounds silly, but I've been trying all day to find out why my batch processing was crashing the crc correction of the BK2 files...

(my batch first run wemtool -d, then bink_unpack and hpatchz crc for bad bk2 files. my crc diff was call video1.diffz before I understand ...)

KaktoR 25-08-2024 05:31

You don't need manual bink patching anymore since there is a xtool plugin for this.

wareck 01-09-2024 22:45

yes I know, but on the last game I converted one big video make some mess with xtool plugin (CRC error at decompress).
So I just work "outside" diskpangui to compress and diff patch this specific file.


All times are GMT -7. The time now is 05:38.

Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2026, vBulletin Solutions Inc.
FileForums @ https://fileforums.com