Ejemplo n.º 1
0
        public void HaloWars_WwiseTest()
        {
            const string k_sound_table_xml = kGameRoot + @"data\soundtable.xml";
            const string k_sounds_path     = @"D:\HW\test\";
            const string k_sounds_pck      = @"C:\Mount\A\Xbox\Xbox360\Games\Halo Wars\sound\wwise_material\GeneratedSoundBanks\xbox360\sounds.pck";
//			const string k_output_file = kTestResultsPath + @"sounds_pck.xml";

            var sound_table = new Phx.BSoundTable();

            using (var s = new IO.XmlElementStream(k_sound_table_xml, FA.Read))
            {
                s.StreamMode = FA.Read;
                s.InitializeAtRootElement();
                sound_table.Serialize(s);
            }

            var pck_settings = new Wwise.FilePackage.AkFilePackageSettings()
            {
                Platform        = Shell.Platform.Xbox360,
                SdkVersion      = Wwise.AkVersion.k2009.Id,
                UseAsciiStrings = false,
            };
            var pck = new Wwise.FilePackage.AkFilePackage(pck_settings);

            using (var fs = System.IO.File.OpenRead(k_sounds_pck))
                using (var s = new IO.EndianStream(fs, Shell.EndianFormat.Big))
                {
                    s.StreamMode = FA.Read;
                    pck.Serialize(s);
                    pck.SerializeSoundBanks(s);
                }

            var extractor = new Wwise.FilePackage.AkFilePackageExtractor(k_sounds_pck, pck, sound_table.EventsMap);

            extractor.PrepareForExtraction();

#if false
            using (var s = IO.XmlElementStream.CreateForWrite("soundsPack"))
            {
                pck.Serialize(s);

                s.Document.Save(k_output_file);
            }
#endif

            using (var fs = System.IO.File.OpenRead(k_sounds_pck))
                using (var s = new IO.EndianStream(fs, Shell.EndianFormat.Big))
                    using (var towav = new System.IO.StreamWriter(k_sounds_path + "towav.bat"))
                        extractor.ExtractSounds(k_sounds_path, towav, s.Reader);
        }
Ejemplo n.º 2
0
        static void Serialize <TDoc, TCursor>(IO.TagElementTextStream <TDoc, TCursor> s, Wwise.FilePackage.AkFilePackageExtractor extractor)
            where TDoc : class
            where TCursor : class
        {
            using (s.EnterOwnerBookmark(extractor))
            {
#if false // #TODO
                using (s.EnterCursorBookmark("languageMap"))
                    mLangMap.Serialize(s);
                using (s.EnterCursorBookmark("banks"))
                    mSoundBanksTable.Serialize(s);
                using (s.EnterCursorBookmark("streams"))
                    mStreamedFilesTable.Serialize(s);
                if (mExternalFilesTable != null)
                {
                    using (s.EnterCursorBookmark("externalFiles"))
                        mExternalFilesTable.Serialize(s);
                }

                if (s.IsWriting)
                {
                    extractor.PrepareForExtraction();

                    using (s.EnterCursorBookmark("bankInfo"))
                        foreach (var bank in extractor.Package.SoundBanks)
                        {
                            using (s.EnterCursorBookmark("bank"))
                            {
                                s.WriteAttribute("id", bank.Id, NumeralBase.Hex);

                                string name;
                                if (mIdToName.TryGetValue(bank.Id, out name))
                                {
                                    s.WriteAttribute("name", name);
                                }

                                //bank.Serialize(s);
                            }
                        }
                }
#endif
            }
        }
Ejemplo n.º 3
0
        void Extract(string banksPath, string outputPath)
        {
            if (!System.IO.File.Exists(kSoundTablePath))
            {
                Console.WriteLine("Error: Couldn't load '{0}'. I need this file to perform extraction",
                                  kSoundTablePath);
                return;
            }

            ExtractSwitches switches;

            ExtractParseSwitches(mSwitches, out switches);

            var stopwatch = mTimeOperation ? System.Diagnostics.Stopwatch.StartNew() : null;

            #region Read game's soundtable.xml
            Console.WriteLine("\t" + "Initializing...");
            var sound_table = new BPhoenix.Phx.BSoundTable();
            using (var s = new IO.XmlElementStream(kSoundTablePath, FileAccess.Read))
            {
                s.StreamMode = FileAccess.Read;
                s.InitializeAtRootElement();
                sound_table.Serialize(s);
            }

            if (mTimeOperation)
            {
                stopwatch.Stop();
                Console.WriteLine("\t\tPerf: {0}", stopwatch.Elapsed);
                stopwatch.Restart();
            }
            #endregion

            #region setup pck_settings
            var pck_settings = new KSoft.Wwise.FilePackage.AkFilePackageSettings()
            {
                Platform        = Shell.Platform.Xbox360,
                SdkVersion      = KSoft.Wwise.AkVersion.k2009.Id,
                UseAsciiStrings = false,
            };
            var pck = new KSoft.Wwise.FilePackage.AkFilePackage(pck_settings);
            #endregion

            #region Process sounds.pck
            Console.WriteLine("\t" + "Processing pck...");
            string sounds_pck_filename = Path.Combine(banksPath, "sounds.pck");

            using (var fs = File.OpenRead(sounds_pck_filename))
                using (var s = new IO.EndianStream(fs, Shell.EndianFormat.Big))
                {
                    s.StreamMode = FileAccess.Read;
                    pck.Serialize(s);
                    pck.SerializeSoundBanks(s);
                }

            if (mTimeOperation)
            {
                stopwatch.Stop();
                Console.WriteLine("\t\tPerf: {0}", stopwatch.Elapsed);
                stopwatch.Restart();
            }
            #endregion

            var pck_extractor = new Wwise.FilePackage.AkFilePackageExtractor(sounds_pck_filename, pck, sound_table.EventsMap);

            Console.WriteLine("\t" + "Postprocessing bank data...");
            pck_extractor.PrepareForExtraction();
            if (mTimeOperation)
            {
                stopwatch.Stop();
                Console.WriteLine("\t\tPerf: {0}", stopwatch.Elapsed);
                stopwatch.Restart();
            }

            #region DumpSoundPackToXml
            if ((switches & ExtractSwitches.DumpSoundPackToXml) != 0)
            {
                using (var s = IO.XmlElementStream.CreateForWrite("soundsPack"))
                {
                    Console.WriteLine("\t" + "Taking a dump...");
                    Serialize(s, pck_extractor);
                    Console.WriteLine("\t\t" + "flushing...");
                    s.Document.Save(Path.Combine(mOutputPath, kSoundsPackListingName));

                    if (mTimeOperation)
                    {
                        stopwatch.Stop();
                        Console.WriteLine("\t\tPerf: {0}", stopwatch.Elapsed);
                        stopwatch.Restart();
                    }
                }
            }
            #endregion

            #region Extract
            Console.WriteLine("\t" + "Extracting...(this normally takes a while)");

            using (var fs = File.OpenRead(sounds_pck_filename))
                using (var s = new IO.EndianStream(fs, Shell.EndianFormat.Big))
                    using (var towav = new StreamWriter(Path.Combine(mOutputPath, "HaloWars_towav.bat")))
                        pck_extractor.ExtractSounds(mOutputPath, towav, s.Reader, (switches & ExtractSwitches.OverwriteExisting) != 0);
            #endregion

            if (mTimeOperation)
            {
                stopwatch.Stop();
                Console.WriteLine("Perf: {0}", stopwatch.Elapsed);
            }

            Console.WriteLine("Done");
        }