/// <summary> /// Convert wem archive entries to ogg files /// </summary> /// <param name="wems"></param> /// <param name="audioOggPath"></param> /// <param name="previewOggPath"></param> /// <returns></returns> public bool ConvertWemEntries(List <Entry> wems, string audioOggPath, string previewOggPath = "") { bool result = false; if (wems.Count > 1) { wems.Sort((e1, e2) => { if (e1.Length < e2.Length) { return(1); } if (e1.Length > e2.Length) { return(-1); } return(0); }); } if (wems.Count > 0) { var top = wems[0]; // wem audio with internal TOC path top.Data.Position = 0; using (var FS = File.Create(audioOggPath)) { WwiseToOgg w2o = new WwiseToOgg(top.Data, FS); result = w2o.ConvertToOgg(); } } if (!String.IsNullOrEmpty(previewOggPath) && result && wems.Count > 0) { var bottom = wems.Last(); bottom.Data.Position = 0; using (var FS = File.Create(previewOggPath)) { WwiseToOgg w2o = new WwiseToOgg(bottom.Data, FS); result = w2o.ConvertToOgg(); } } return(result); }
// old slower static method public static List <Entry> ExtractAudioEntry(string archiveName, string audioName, string previewName) { bool result = false; if (String.IsNullOrEmpty(audioName)) { return(null); // false; } GlobalExtension.ShowProgress("Extracting Audio ..."); List <Entry> wems; using (var archive = new PSARC(true)) using (var stream = File.OpenRead(archiveName)) { archive.Read(stream, true); wems = archive.TOC.Where(entry => entry.Name.StartsWith("audio/windows") && entry.Name.EndsWith(".wem")).ToList(); if (wems.Count > 1) { wems.Sort((e1, e2) => { if (e1.Length < e2.Length) { return(1); } if (e1.Length > e2.Length) { return(-1); } return(0); }); } if (wems.Count > 0) { var top = wems[0]; // wem audio with internal TOC path archive.InflateEntry(top); top.Data.Position = 0; using (var FS = File.Create(audioName)) { WwiseToOgg w2o = new WwiseToOgg(top.Data, FS); result = w2o.ConvertToOgg(); } } if (!String.IsNullOrEmpty(previewName) && result && wems.Count > 0) { var bottom = wems.Last(); archive.InflateEntry(bottom); bottom.Data.Position = 0; using (var FS = File.Create(previewName)) { WwiseToOgg w2o = new WwiseToOgg(bottom.Data, FS); result = w2o.ConvertToOgg(); } } } // confirmed this output is same as old exe converter method both are 44KHz VBR if (!result) { return(null); } return(wems); }
// old slower static method public static List<Entry> ExtractAudioEntry(string archiveName, string audioName, string previewName) { bool result = false; if (String.IsNullOrEmpty(audioName)) return null; // false; GlobalExtension.ShowProgress("Extracting Audio ..."); List<Entry> wems; using (var archive = new PSARC(true)) using (var stream = File.OpenRead(archiveName)) { archive.Read(stream, true); wems = archive.TOC.Where(entry => entry.Name.StartsWith("audio/windows") && entry.Name.EndsWith(".wem")).ToList(); if (wems.Count > 1) { wems.Sort((e1, e2) => { if (e1.Length < e2.Length) return 1; if (e1.Length > e2.Length) return -1; return 0; }); } if (wems.Count > 0) { var top = wems[0]; // wem audio with internal TOC path archive.InflateEntry(top); top.Data.Position = 0; using (var FS = File.Create(audioName)) { WwiseToOgg w2o = new WwiseToOgg(top.Data, FS); result = w2o.ConvertToOgg(); } } if (!String.IsNullOrEmpty(previewName) && result && wems.Count > 0) { var bottom = wems.Last(); archive.InflateEntry(bottom); bottom.Data.Position = 0; using (var FS = File.Create(previewName)) { WwiseToOgg w2o = new WwiseToOgg(bottom.Data, FS); result = w2o.ConvertToOgg(); } } } // confirmed this output is same as old exe converter method both are 44KHz VBR if (!result) return null; return wems; }
/// <summary> /// Convert wem archive entries to ogg files /// </summary> /// <param name="wems"></param> /// <param name="audioOggPath"></param> /// <param name="previewOggPath"></param> /// <returns></returns> public bool ConvertWemEntries(List<Entry> wems, string audioOggPath, string previewOggPath = "") { bool result = false; if (wems.Count > 1) { wems.Sort((e1, e2) => { if (e1.Length < e2.Length) return 1; if (e1.Length > e2.Length) return -1; return 0; }); } if (wems.Count > 0) { var top = wems[0]; // wem audio with internal TOC path top.Data.Position = 0; using (var FS = File.Create(audioOggPath)) { WwiseToOgg w2o = new WwiseToOgg(top.Data, FS); result = w2o.ConvertToOgg(); } } if (!String.IsNullOrEmpty(previewOggPath) && result && wems.Count > 0) { var bottom = wems.Last(); bottom.Data.Position = 0; using (var FS = File.Create(previewOggPath)) { WwiseToOgg w2o = new WwiseToOgg(bottom.Data, FS); result = w2o.ConvertToOgg(); } } return result; }
public static void Revorb(string file, string outputFileName, string appPath, WwiseVersion wwiseVersion) { // testing using dreddfoxx CFSM.AudioTool library. Thanks to DF. var CFSM_AUDIO_TOOLS = File.Exists(Path.Combine(appPath, "CFSM.AudioTools.dll")); #if !DEBUG CFSM_AUDIO_TOOLS = false; #endif if (CFSM_AUDIO_TOOLS) { using (var readStream = File.OpenRead(file)) using (var outStream = File.Create(outputFileName)) { WwiseToOgg ww2Ogg = new WwiseToOgg(readStream, outStream); ww2Ogg.ConvertToOgg(); } } else { var ww2oggPath = Path.Combine(appPath, "ww2ogg.exe"); var revorbPath = Path.Combine(appPath, "revorb.exe"); var codebooksPath = Path.Combine(appPath, "packed_codebooks.bin"); // Default var codebooks603Path = Path.Combine(appPath, "packed_codebooks_aoTuV_603.bin"); // RS2014 // Verifying if third part apps is in root application directory if (!File.Exists(ww2oggPath)) throw new FileNotFoundException("ww2ogg executable not found!"); if (!File.Exists(revorbPath)) throw new FileNotFoundException("revorb executable not found!"); if (!File.Exists(codebooksPath)) throw new FileNotFoundException("packed_codebooks.bin not found!"); if (!File.Exists(codebooks603Path)) throw new FileNotFoundException("packed_codebooks_aoTuV_603.bin not found!"); // Processing with ww2ogg Process ww2oggProcess = new Process(); ww2oggProcess.StartInfo.FileName = ww2oggPath; ww2oggProcess.StartInfo.WorkingDirectory = appPath; switch (wwiseVersion) { case WwiseVersion.Wwise2010: ww2oggProcess.StartInfo.Arguments = String.Format("\"{0}\" -o \"{1}\"", file, outputFileName); break; case WwiseVersion.Wwise2013: ww2oggProcess.StartInfo.Arguments = String.Format("\"{0}\" -o \"{1}\" --pcb \"{2}\"", file, outputFileName, codebooks603Path); break; default: throw new InvalidOperationException("Wwise version not supported or invalid input file."); } ww2oggProcess.StartInfo.UseShellExecute = false; ww2oggProcess.StartInfo.CreateNoWindow = true; ww2oggProcess.StartInfo.RedirectStandardOutput = true; ww2oggProcess.Start(); ww2oggProcess.WaitForExit(); string ww2oggResult = ww2oggProcess.StandardOutput.ReadToEnd(); if (ww2oggResult.IndexOf("error") > -1) throw new Exception("ww2ogg process error." + Environment.NewLine + ww2oggResult); // Processing with revorb Process revorbProcess = new Process(); revorbProcess.StartInfo.FileName = revorbPath; revorbProcess.StartInfo.WorkingDirectory = appPath; revorbProcess.StartInfo.Arguments = String.Format("\"{0}\"", outputFileName); revorbProcess.StartInfo.UseShellExecute = false; revorbProcess.StartInfo.CreateNoWindow = true; revorbProcess.StartInfo.RedirectStandardOutput = true; revorbProcess.Start(); revorbProcess.WaitForExit(); string revorbResult = revorbProcess.StandardOutput.ReadToEnd(); if (ww2oggResult.IndexOf("error") > -1) { if (File.Exists(outputFileName)) File.Delete(outputFileName); throw new Exception("revorb process error." + Environment.NewLine + revorbResult); } } }
public static void Revorb(string file, string outputFileName, string appPath, WwiseVersion wwiseVersion) { // testing using dreddfoxx CFSM.AudioTool library. Thanks to DF. var CFSM_AUDIO_TOOLS = File.Exists(Path.Combine(appPath, "CFSM.AudioTools.dll")); // TODO: comment out till there is time to debug/test // not working for RS1-RS2 ogg conversions ;( CFSM_AUDIO_TOOLS = false; if (CFSM_AUDIO_TOOLS) { using (var readStream = File.OpenRead(file)) using (var outStream = File.Create(outputFileName)) { WwiseToOgg ww2Ogg = new WwiseToOgg(readStream, outStream); ww2Ogg.ConvertToOgg(); } } else { var ww2oggPath = Path.Combine(appPath, "ww2ogg.exe"); var revorbPath = Path.Combine(appPath, "revorb.exe"); var codebooksPath = Path.Combine(appPath, "packed_codebooks.bin"); // Default var codebooks603Path = Path.Combine(appPath, "packed_codebooks_aoTuV_603.bin"); // RS2014 // Verifying if third part apps is in root application directory if (!File.Exists(ww2oggPath)) { throw new FileNotFoundException("ww2ogg executable not found!"); } if (!File.Exists(revorbPath)) { throw new FileNotFoundException("revorb executable not found!"); } if (!File.Exists(codebooksPath)) { throw new FileNotFoundException("packed_codebooks.bin not found!"); } if (!File.Exists(codebooks603Path)) { throw new FileNotFoundException("packed_codebooks_aoTuV_603.bin not found!"); } // Processing with ww2ogg Process ww2oggProcess = new Process(); ww2oggProcess.StartInfo.FileName = ww2oggPath; ww2oggProcess.StartInfo.WorkingDirectory = appPath; switch (wwiseVersion) { case WwiseVersion.Wwise2010: ww2oggProcess.StartInfo.Arguments = String.Format("\"{0}\" -o \"{1}\"", file, outputFileName); break; case WwiseVersion.Wwise2013: ww2oggProcess.StartInfo.Arguments = String.Format("\"{0}\" -o \"{1}\" --pcb \"{2}\"", file, outputFileName, codebooks603Path); break; default: throw new InvalidOperationException("Wwise version not supported or invalid input file."); } ww2oggProcess.StartInfo.UseShellExecute = false; ww2oggProcess.StartInfo.CreateNoWindow = true; ww2oggProcess.StartInfo.RedirectStandardOutput = true; ww2oggProcess.Start(); ww2oggProcess.WaitForExit(); string ww2oggResult = ww2oggProcess.StandardOutput.ReadToEnd(); if (ww2oggResult.IndexOf("error") > -1) { throw new Exception("ww2ogg process error." + Environment.NewLine + ww2oggResult); } // Processing with revorb Process revorbProcess = new Process(); revorbProcess.StartInfo.FileName = revorbPath; revorbProcess.StartInfo.WorkingDirectory = appPath; revorbProcess.StartInfo.Arguments = String.Format("\"{0}\"", outputFileName); revorbProcess.StartInfo.UseShellExecute = false; revorbProcess.StartInfo.CreateNoWindow = true; revorbProcess.StartInfo.RedirectStandardOutput = true; revorbProcess.Start(); revorbProcess.WaitForExit(); string revorbResult = revorbProcess.StandardOutput.ReadToEnd(); if (ww2oggResult.IndexOf("error") > -1) { if (File.Exists(outputFileName)) { File.Delete(outputFileName); } throw new Exception("revorb process error." + Environment.NewLine + revorbResult); } } }