예제 #1
0
        public void LoadSoundTag(CacheBase Cache, CacheBase.IndexItem Tag)
        {
            if (Cache.Version != DefinitionSet.Halo4Retail)
            {
                throw new Exception("This is for H4 ONLY");
            }

            cache = (CacheH4R)Cache;
            tag   = Tag;

            snd = (SoundH4R)DefinitionsManager.snd_(cache, tag);

            LoadCacheSoundPacks(cache);

            lstPerms.Items.Clear();
            _perms.Clear();
            _soundbanks.Clear();

            ObjectLoadWorker();

            if (lstPerms.Items.Count > 0)
            {
                Enabled = true;
                lstPerms.SelectedIndex = 0;
                label1.Text            = _perms[0].Format.ToString();
            }
            else
            {
                label1.Text = "";
                Enabled     = false;
            }
        }
예제 #2
0
        private static void LoadCacheSoundPacks(CacheH4R Cache)
        {
            if (Cache.SoundPacks == null)
            {
                Cache.SoundPacks = new List <Composer.SoundPackInfo>();

                var bank = new SoundPackInfo();
                bank.Name   = "SoundBank";
                bank.Reader = new EndianReader(File.OpenRead(Cache.FilePath + @"\soundbank.pck"), EndianFormat.BigEndian);
                bank.Pack   = new SoundPack(bank.Reader);
                Cache.SoundPacks.Add(bank);

                var stream = new SoundPackInfo();
                stream.Name   = "SoundStream";
                stream.Reader = new EndianReader(File.OpenRead(Cache.FilePath + @"\soundstream.pck"), EndianFormat.BigEndian);
                stream.Pack   = new SoundPack(stream.Reader);
                Cache.SoundPacks.Add(stream);
            }
        }
예제 #3
0
        /// <summary>
        /// Save all permutations of a sound tag as separate sound files.
        /// </summary>
        /// <param name="Folder">The base filename. Permutation names will be appended accordingly.</param>
        /// <param name="Cache">The CacheFile containing the tag.</param>
        /// <param name="Tag">The sound tag.</param>
        /// <param name="Format">The format in which to save the data.</param>
        public void SaveAllAsSeparate(string Folder, CacheBase Cache, CacheBase.IndexItem Tag, SoundFormat Format, bool Overwrite)
        {
            if (Format != SoundFormat.WAV)
            {
                throw new NotSupportedException("Halo4Retail only supports WAV.");
            }
            if (Cache.Version != DefinitionSet.Halo4Retail)
            {
                throw new Exception("This is for H4 ONLY");
            }

            if (scanner == null)
            {
                scanner = new SoundScanner();
                scanner.FoundSoundBankFile += FoundSoundBankFile;
                scanner.FoundSoundPackFile += FoundSoundPackFile;
            }

            cache = (CacheH4R)Cache;
            tag   = Tag;

            snd = (SoundH4R)DefinitionsManager.snd_(cache, tag);

            LoadCacheSoundPacks(cache);

            if (cache.SoundFiles == null)
            {
                cache.SoundFiles = new Dictionary <uint, List <SoundFileInfo> >();
                ObjectLoadWorker();
            }

            bool s1, s2;
            List <SoundFileInfo> sfi1, sfi2, sfi3;

            s1 = cache.SoundFiles.TryGetValue(snd.SoundAddress1, out sfi1);
            s2 = cache.SoundFiles.TryGetValue(snd.SoundAddress2, out sfi2);

            if (!s1 && !s2)
            {
                throw new Exception("No permutations found.");
            }

            sfi3 = new List <SoundFileInfo>();
            if (s1)
            {
                sfi3.AddRange(sfi1);
            }
            if (s2)
            {
                sfi3.AddRange(sfi2);
            }

            for (int i = 0; i < sfi3.Count; i++)
            {
                var info = sfi3[i];

                var fName = Path.GetFileName(tag.Filename);

                fName = Folder + "\\" + fName + " [" + i.ToString() + "]" + ".wav";

                if (File.Exists(fName) && !Overwrite)
                {
                    return;
                }

                RIFX rifx = ReadRIFX(info);

                switch (info.Format)
                {
                case Composer.SoundFormat.XMA:
                    if (!Directory.GetParent(fName).Exists)
                    {
                        Directory.GetParent(fName).Create();
                    }
                    SoundExtraction.ExtractXMAToWAV(info.Reader, info.Offset, rifx, fName);
                    break;

                case Composer.SoundFormat.WwiseOGG:
                    if (!Directory.GetParent(fName).Exists)
                    {
                        Directory.GetParent(fName).Create();
                    }
                    SoundExtraction.ExtractWwiseToOGG(info.Reader, info.Offset, info.Size, fName);
                    break;

                default:
                    throw new NotSupportedException(info.Format.ToString() + " not supported.");
                }
            }
        }