예제 #1
0
        public void SaveTemp(int index)
        {
            var info = _perms[index];

            var fileName = Path.GetTempPath() + "temp_playback.wav";

            RIFX rifx = ReadRIFX(info);

            switch (info.Format)
            {
            case Composer.SoundFormat.XMA:
                SoundExtraction.ExtractXMAToWAV(info.Reader, info.Offset, rifx, fileName);
                break;

            case Composer.SoundFormat.WwiseOGG:
                throw new NotSupportedException("OGG preview not supported: extract it instead.");

            case Composer.SoundFormat.XWMA:
                SoundExtraction.ExtractXWMAToWAV(info.Reader, info.Offset, rifx, fileName);
                break;

            default:
                throw new Exception("no");
            }
        }
예제 #2
0
        private void btnSaveSelected_Click(object sender, EventArgs e)
        {
            var sfd = new SaveFileDialog()
            {
                AddExtension = false,
                FileName     = Path.GetFileName(tag.Filename), // tag.Filename.Substring(tag.Filename.LastIndexOf('\\') + 1),
                Filter       = "WAV Files|*.wav",              //|XMA Files|*.xma|Raw Data|*.bin",
                FilterIndex  = (int)DefaultSnd_Format + 1
            };

            if (sfd.ShowDialog() != DialogResult.OK)
            {
                return;
            }

            try
            {
                for (int i = 0; i < lstPerms.Items.Count; i++)
                {
                    if (!lstPerms.SelectedIndices.Contains(i))
                    {
                        continue;
                    }

                    var info = _perms[i];

                    var fileName = sfd.FileName.Substring(0, sfd.FileName.LastIndexOf("\\") + 1) + Path.GetFileNameWithoutExtension(sfd.FileName) + " [" + i.ToString() + "]" + Path.GetExtension(sfd.FileName);

                    RIFX rifx = ReadRIFX(info);

                    switch (info.Format)
                    {
                    case Composer.SoundFormat.XMA:
                        SoundExtraction.ExtractXMAToWAV(info.Reader, info.Offset, rifx, fileName);
                        break;

                    case Composer.SoundFormat.WwiseOGG:
                        SoundExtraction.ExtractWwiseToOGG(info.Reader, info.Offset, info.Size, fileName);
                        break;

                    case Composer.SoundFormat.XWMA:
                        SoundExtraction.ExtractXWMAToWAV(info.Reader, info.Offset, rifx, fileName);
                        break;

                    default:
                        throw new Exception("no");
                    }
                }

                //SaveSelected(sfd.FileName, cache, tag, (SoundFormat)(sfd.FilterIndex - 1), indices, true);
                TagExtracted(this, tag);
            }
            catch (Exception ex) { ErrorExtracting(this, tag, ex); }
        }
예제 #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.");
                }
            }
        }