Skip to content

Commit

Permalink
Initial upload
Browse files Browse the repository at this point in the history
  • Loading branch information
HW12Dev committed Sep 14, 2023
1 parent 58dcb7a commit 731d54c
Show file tree
Hide file tree
Showing 8 changed files with 460 additions and 0 deletions.
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
.vs/
bin/
obj/
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,2 +1,6 @@
# wwise_pd3
Open source tool to encode/decode PCM WAV files to WEM and vice versa. Intended for use in PAYDAY 3

Usage: `wwise_pd3 -decode/-encode <input> <output>`

**Currently does not support localised voice lines**
25 changes: 25 additions & 0 deletions wwise_pd3.sln
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 17
VisualStudioVersion = 17.7.34024.191
MinimumVisualStudioVersion = 10.0.40219.1
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "wwise_pd3", "wwise_pd3\wwise_pd3.csproj", "{1BB43D41-ACCB-45AC-B962-A49507DEE616}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Release|Any CPU = Release|Any CPU
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{1BB43D41-ACCB-45AC-B962-A49507DEE616}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{1BB43D41-ACCB-45AC-B962-A49507DEE616}.Debug|Any CPU.Build.0 = Debug|Any CPU
{1BB43D41-ACCB-45AC-B962-A49507DEE616}.Release|Any CPU.ActiveCfg = Release|Any CPU
{1BB43D41-ACCB-45AC-B962-A49507DEE616}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {BE90FE6C-DA03-4882-BB98-AE7F813D52B5}
EndGlobalSection
EndGlobal
6 changes: 6 additions & 0 deletions wwise_pd3/App.config
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<startup>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.8"/>
</startup>
</configuration>
182 changes: 182 additions & 0 deletions wwise_pd3/Program.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,182 @@
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Runtime.InteropServices;
using System.Text;
using System.Threading.Tasks;

namespace wwise_pd3
{
public class Program
{
public static void PrintHelp()
{
Console.WriteLine("Usage: wwise_pd3 -decode/-encode <input> <output>");
}

static void EncodeToWem(string[] args)
{
var input = args[1];
var output = args[2];

BinaryReader br = new BinaryReader(File.OpenRead(input));

var header = WAVE.ReadHeaderFromWAV(br);

if (header.type != 1)
{
Console.WriteLine(String.Format("PAYDAY 3 only supports PCM, not type {0}", header.type));
}

Console.WriteLine(String.Format("Format Length: {0}", header.lengthofformatdata));

Console.WriteLine(String.Format("Type: {0}", header.type == 1 ? "PCM" : "OTHER"));

Console.WriteLine(String.Format("Channels: {0}", header.channels));

Console.WriteLine(String.Format("Sample Rate: {0}", header.samplerate));

Console.WriteLine(String.Format("Avg. Bytes per second: {0}", header.averagebytespersecond));

Console.WriteLine(String.Format("Block Align: {0}", header.blockalign));

Console.WriteLine(String.Format("Bits per Sample: {0}", header.bitspersample));

//br.Read(data, (int)br.BaseStream.Position, (int)(br.BaseStream.Length - br.BaseStream.Position));
byte[] data = br.ReadBytes((int)(File.ReadAllBytes(input).LongLength - br.BaseStream.Position));
Console.WriteLine(File.ReadAllBytes(input).LongLength);
Console.WriteLine(br.BaseStream.Length);

Console.WriteLine(data.Length);

br.Close();

BinaryWriter bw = new BinaryWriter(File.OpenWrite(output));

WAVE.WriteWAVHeader(bw, header, wem: true);

bw.Write(data);

// write file size

var size = bw.BaseStream.Length;

Console.WriteLine($"{size} bytes written");

bw.BaseStream.Position = 0;

bw.Write((byte)0x52);
bw.Write((byte)0x49);
bw.Write((byte)0x46);
bw.Write((byte)0x46);

bw.Write(size);

bw.BaseStream.Position -= 4;

bw.Write((byte)0x57);
bw.Write((byte)0x41);
bw.Write((byte)0x56);
bw.Write((byte)0x45);

bw.Close();
}

static void DecodeFromWEM(string[] args)
{
var input = args[1];
var output = args[2];

BinaryReader br = new BinaryReader(File.OpenRead(input));

var header = WAVE.ReadWEMHeaderToWAVHeader(br);

Console.WriteLine(String.Format("Format Length: {0}", header.lengthofformatdata));

Console.WriteLine(String.Format("Type: {0}", header.type == 1 ? "PCM" : "OTHER"));

Console.WriteLine(String.Format("Channels: {0}", header.channels));

Console.WriteLine(String.Format("Sample Rate: {0}", header.samplerate));

Console.WriteLine(String.Format("Avg. Bytes per second: {0}", header.averagebytespersecond));

Console.WriteLine(String.Format("Block Align: {0}", header.blockalign));

Console.WriteLine(String.Format("Bits per Sample: {0}", header.bitspersample));

byte[] data = br.ReadBytes((int)(File.ReadAllBytes(input).LongLength - br.BaseStream.Position));
Console.WriteLine(File.ReadAllBytes(input).LongLength);
Console.WriteLine(br.BaseStream.Length);

Console.WriteLine(data.Length);

br.Close();

BinaryWriter bw = new BinaryWriter(File.OpenWrite(output));

WAVE.WriteWAVHeader(bw, header, wem: false);

bw.Write(data);

// write file size

var size = bw.BaseStream.Length;

Console.WriteLine($"{size} bytes written");

bw.BaseStream.Position = 0;

bw.Write((byte)0x52);
bw.Write((byte)0x49);
bw.Write((byte)0x46);
bw.Write((byte)0x46);

bw.Write(size);

bw.BaseStream.Position -= 4;

bw.Write((byte)0x57);
bw.Write((byte)0x41);
bw.Write((byte)0x56);
bw.Write((byte)0x45);

bw.Close();
}

public static void Main(string[] args)
{
if (args.Length == 0)
{
Console.WriteLine("Incorrect arguments!");
PrintHelp();
return;
}

bool encoding = false;

switch(args[0])
{
case "-encode":
encoding = true;
break;
case "-decode":
encoding = false;
break;
default:
Console.WriteLine("Please provide a method (encoding or decoding)"); ;
return;
}

if (encoding)
{
EncodeToWem(args);
} else
{
DecodeFromWEM(args);
//Console.WriteLine("Decoding is not supported");
}
}
}
}
36 changes: 36 additions & 0 deletions wwise_pd3/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;

// General Information about an assembly is controlled through the following
// set of attributes. Change these attribute values to modify the information
// associated with an assembly.
[assembly: AssemblyTitle("wwise_pd3")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("wwise_pd3")]
[assembly: AssemblyCopyright("Copyright © 2023")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]

// Setting ComVisible to false makes the types in this assembly not visible
// to COM components. If you need to access a type in this assembly from
// COM, set the ComVisible attribute to true on that type.
[assembly: ComVisible(false)]

// The following GUID is for the ID of the typelib if this project is exposed to COM
[assembly: Guid("1bb43d41-accb-45ac-b962-a49507dee616")]

// Version information for an assembly consists of the following four values:
//
// Major Version
// Minor Version
// Build Number
// Revision
//
// You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("1.0.0.0")]
[assembly: AssemblyFileVersion("1.0.0.0")]
Loading

0 comments on commit 731d54c

Please sign in to comment.