Exemplo n.º 1
0
 public ExtractedSoundPitchRange(int index, string name, SoundPitchRange orig, List <ExtractedSoundPermutation> perms)
 {
     OriginalIndex            = index;
     Name                     = name;
     Parameter                = orig.Parameter;
     HasEncodedData           = orig.HasEncodedData;
     RequiredPermutationCount = orig.RequiredPermutationCount;
     Permutations             = perms;
 }
Exemplo n.º 2
0
        private void FixSoundReference_PitchRange(int originalIndex, int count, IWriter buffer)
        {
            for (int i = 0; i < count; i++)
            {
                var pRange = _container.FindSoundPitchRange(originalIndex + i);

                int newIndex;
                if (!_soundPitchRanges.TryGetValue(pRange, out newIndex))
                {
                    newIndex = _soundResources.PitchRanges.Count;

                    SoundPitchRange newPRange = new SoundPitchRange();

                    newPRange.Name = InjectSoundStringID(pRange.Name);

                    newPRange.Parameter = pRange.Parameter;

                    newPRange.HasEncodedData           = pRange.HasEncodedData;
                    newPRange.RequiredPermutationCount = pRange.RequiredPermutationCount;

                    var permutations = new List <SoundPermutation>();
                    foreach (var perm in pRange.Permutations)
                    {
                        SoundPermutation newPerm = new SoundPermutation();

                        newPerm.Name = InjectSoundStringID(perm.Name);

                        newPerm.EncodedSkipFraction         = perm.EncodedSkipFraction;
                        newPerm.EncodedGain                 = perm.EncodedGain;
                        newPerm.EncodedPermutationInfoIndex = perm.EncodedPermutationInfoIndex;
                        newPerm.SampleSize = perm.SampleSize;

                        newPerm.FSBInfo = perm.FSBInfo;

                        var chunks = new List <SoundChunk>();

                        foreach (var chunk in perm.Chunks)
                        {
                            SoundChunk src = chunk.Source;
                            src.FModBankSuffix = InjectSoundStringID(chunk.FModBankSuffix);
                            chunks.Add(src);
                        }


                        if (perm.Languages != null)
                        {
                            var languages = new List <SoundPermutationLanguage>();

                            foreach (var lang in perm.Languages)
                            {
                                var newPL = new SoundPermutationLanguage();

                                newPL.LanguageIndex = lang.LanguageIndex;
                                newPL.SampleSize    = lang.SampleSize;

                                if (lang.Chunks != null && lang.Chunks.Count > 0)
                                {
                                    var lChunks = new List <SoundChunk>();

                                    foreach (var chunk in lang.Chunks)
                                    {
                                        SoundChunk src = chunk.Source;
                                        src.FModBankSuffix = InjectSoundStringID(chunk.FModBankSuffix);
                                        lChunks.Add(src);
                                    }

                                    newPL.Chunks = lChunks.ToArray();
                                }
                            }

                            newPerm.Languages = languages.ToArray();
                        }

                        if (perm.LayerMarkers != null)
                        {
                            newPerm.LayerMarkers = perm.LayerMarkers.ToArray();
                        }

                        newPerm.Chunks = chunks.ToArray();


                        permutations.Add(newPerm);
                    }

                    newPRange.Permutations = permutations.ToArray();

                    _soundResources.PitchRanges.Add(newPRange);
                    _soundPitchRanges[pRange] = newIndex;
                }
                if (i == 0)
                {
                    var test = _soundLayout.GetFieldOffset("first pitch range index");
                    buffer.SeekTo(test);
                    buffer.WriteInt16((short)newIndex);
                }
            }
        }