public static void Revorb(string file, string outputFileName, WwiseVersion wwiseVersion)
        {
            // Processing with ww2ogg
            Process ww2oggProcess = new Process();

            ww2oggProcess.StartInfo.FileName         = Path.Combine(ExternalApps.TOOLKIT_ROOT, ExternalApps.APP_WW2OGG);
            ww2oggProcess.StartInfo.WorkingDirectory = ExternalApps.TOOLKIT_ROOT;

            switch (wwiseVersion)
            {
            case WwiseVersion.Wwise2010:
                ww2oggProcess.StartInfo.Arguments = String.Format("\"{0}\" -o \"{1}\" --pcb \"{2}\"", file, outputFileName, Path.Combine(ExternalApps.TOOLKIT_ROOT, ExternalApps.APP_CODEBOOKS));
                break;

            case WwiseVersion.Wwise2013:
                ww2oggProcess.StartInfo.Arguments = String.Format("\"{0}\" -o \"{1}\" --pcb \"{2}\"", file, outputFileName, Path.Combine(ExternalApps.TOOLKIT_ROOT, ExternalApps.APP_CODEBOOKS_603));
                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 ", StringComparison.Ordinal) > -1 || ww2oggResult.IndexOf(" error:", StringComparison.Ordinal) > -1)
            {
                throw new Exception("ww2ogg process error or CDLC file name contains reserved word 'error'." + Environment.NewLine + ww2oggResult);
            }

            // Processing with revorb
            Process revorbProcess = new Process();

            revorbProcess.StartInfo.FileName               = Path.Combine(ExternalApps.TOOLKIT_ROOT, ExternalApps.APP_REVORB);
            revorbProcess.StartInfo.WorkingDirectory       = ExternalApps.TOOLKIT_ROOT;
            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();

            // TODO: ? should check revorbResult
            if (ww2oggResult.IndexOf("Error ", StringComparison.Ordinal) > -1 || ww2oggResult.IndexOf(" error:", StringComparison.Ordinal) > -1)
            {
                if (File.Exists(outputFileName))
                {
                    File.Delete(outputFileName);
                }

                throw new Exception("revorb process error or CDLC file name contains reserved word 'error'." + Environment.NewLine + revorbResult);
            }
        }
Exemplo n.º 2
0
        public static void Revorb(string file, string outputFileName, string appPath, WwiseVersion wwiseVersion)
        {
            string ww2oggPath       = Path.Combine(appPath, "ww2ogg.exe");
            string revorbPath       = Path.Combine(appPath, "revorb.exe");
            string codebooksPath    = Path.Combine(appPath, "packed_codebooks.bin"); // Default
            string codebooks603Path = Path.Combine(appPath, "packed_codebooks_aoTuV_603.bin");

            // 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)
        {
            string ww2oggPath = Path.Combine(appPath, "ww2ogg.exe");
            string revorbPath = Path.Combine(appPath, "revorb.exe");
            string codebooksPath = Path.Combine(appPath, "packed_codebooks.bin"); // Default
            string codebooks603Path = Path.Combine(appPath, "packed_codebooks_aoTuV_603.bin");

            // 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"));
            #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);
                }
            }
        }