Beispiel #1
0
        private void LoadObjects(SoundPack pack, EndianReader reader, SoundScanner scanner)
        {
            foreach (SoundPackFolder folder in pack.Folders)
            {
                foreach (SoundPackFile file in folder.Files)
                {
                    reader.SeekTo(file.Offset);
                    int magic = reader.ReadInt32();

                    switch (magic)
                    {
                    case 0x52494658:     // RIFX - Embedded sound file
                        scanner.RegisterGlobalObject(file);
                        break;

                    case 0x424B4844:     // BKHD - Sound bank
                        reader.SeekTo(file.Offset);
                        SoundBank bank = new SoundBank(reader, file.Size);
                        scanner.RegisterSoundBank(bank);
                        _soundbanks.Add(bank);
                        break;
                    }
                }
            }
        }
Beispiel #2
0
        private void SoundExtractorH4_Load(object sender, EventArgs e)
        {
            scanner = new SoundScanner();
            scanner.FoundSoundBankFile += FoundSoundBankFile;
            scanner.FoundSoundPackFile += FoundSoundPackFile;

            isDisplay = true;
        }
Beispiel #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.");
                }
            }
        }