Exemple #1
0
        private static ExtractedSoundCustomPlayback ReadSoundCustomPlayback(IReader reader, byte version)
        {
            if (version > 0)
            {
                throw new InvalidOperationException("Unrecognized \"scpb\" block version");
            }

            var cplayback = new ExtractedSoundCustomPlayback();

            cplayback.OriginalIndex = reader.ReadInt32();

            cplayback.Version = (SoundCustomPlaybackVersion)reader.ReadByte();

            cplayback.Flags = reader.ReadInt32();

            cplayback.Unknown  = reader.ReadInt32();
            cplayback.Unknown1 = reader.ReadInt32();

            cplayback.Mixes = new System.Collections.Generic.List <SoundCustomPlaybackMix>();
            int mixcount = reader.ReadInt32();

            for (int i = 0; i < mixcount; i++)
            {
                SoundCustomPlaybackMix mix = new SoundCustomPlaybackMix();

                mix.Mixbin = reader.ReadInt32();
                mix.Gain   = reader.ReadFloat();

                cplayback.Mixes.Add(mix);
            }

            cplayback.Filters = new System.Collections.Generic.List <SoundCustomPlaybackFilter>();
            int filtercount = reader.ReadInt32();

            for (int i = 0; i < filtercount; i++)
            {
                SoundCustomPlaybackFilter filter = new SoundCustomPlaybackFilter();

                filter.Type  = reader.ReadInt32();
                filter.Width = reader.ReadInt32();

                filter.LeftFreqScaleMin       = reader.ReadFloat();
                filter.LeftFreqScaleMax       = reader.ReadFloat();
                filter.LeftFreqRandomBase     = reader.ReadFloat();
                filter.LeftFreqRandomVariance = reader.ReadFloat();

                filter.LeftGainScaleMin       = reader.ReadFloat();
                filter.LeftGainScaleMax       = reader.ReadFloat();
                filter.LeftGainRandomBase     = reader.ReadFloat();
                filter.LeftGainRandomVariance = reader.ReadFloat();

                filter.RightFreqScaleMin       = reader.ReadFloat();
                filter.RightFreqScaleMax       = reader.ReadFloat();
                filter.RightFreqRandomBase     = reader.ReadFloat();
                filter.RightFreqRandomVariance = reader.ReadFloat();

                filter.RightGainScaleMin       = reader.ReadFloat();
                filter.RightGainScaleMax       = reader.ReadFloat();
                filter.RightGainRandomBase     = reader.ReadFloat();
                filter.RightGainRandomVariance = reader.ReadFloat();

                cplayback.Filters.Add(filter);
            }

            cplayback.PitchLFOs = new System.Collections.Generic.List <SoundCustomPlaybackPitchLFO>();
            int pitchlfocount = reader.ReadInt32();

            for (int i = 0; i < pitchlfocount; i++)
            {
                SoundCustomPlaybackPitchLFO pitchlfo = new SoundCustomPlaybackPitchLFO();

                pitchlfo.DelayScaleMin       = reader.ReadFloat();
                pitchlfo.DelayScaleMax       = reader.ReadFloat();
                pitchlfo.DelayRandomBase     = reader.ReadFloat();
                pitchlfo.DelayRandomVariance = reader.ReadFloat();

                pitchlfo.FreqScaleMin       = reader.ReadFloat();
                pitchlfo.FreqScaleMax       = reader.ReadFloat();
                pitchlfo.FreqRandomBase     = reader.ReadFloat();
                pitchlfo.FreqRandomVariance = reader.ReadFloat();

                pitchlfo.PitchModScaleMin       = reader.ReadFloat();
                pitchlfo.PitchModScaleMax       = reader.ReadFloat();
                pitchlfo.PitchModRandomBase     = reader.ReadFloat();
                pitchlfo.PitchModRandomVariance = reader.ReadFloat();

                cplayback.PitchLFOs.Add(pitchlfo);
            }

            cplayback.FilterLFOs = new System.Collections.Generic.List <SoundCustomPlaybackFilterLFO>();
            int filterlfocount = reader.ReadInt32();

            for (int i = 0; i < filterlfocount; i++)
            {
                SoundCustomPlaybackFilterLFO filterlfo = new SoundCustomPlaybackFilterLFO();

                filterlfo.DelayScaleMin       = reader.ReadFloat();
                filterlfo.DelayScaleMax       = reader.ReadFloat();
                filterlfo.DelayRandomBase     = reader.ReadFloat();
                filterlfo.DelayRandomVariance = reader.ReadFloat();

                filterlfo.FreqScaleMin       = reader.ReadFloat();
                filterlfo.FreqScaleMax       = reader.ReadFloat();
                filterlfo.FreqRandomBase     = reader.ReadFloat();
                filterlfo.FreqRandomVariance = reader.ReadFloat();

                filterlfo.CutoffModScaleMin       = reader.ReadFloat();
                filterlfo.CutoffModScaleMax       = reader.ReadFloat();
                filterlfo.CutoffModRandomBase     = reader.ReadFloat();
                filterlfo.CutoffModRandomVariance = reader.ReadFloat();

                filterlfo.GainModScaleMin       = reader.ReadFloat();
                filterlfo.GainModScaleMax       = reader.ReadFloat();
                filterlfo.GainModRandomBase     = reader.ReadFloat();
                filterlfo.GainModRandomVariance = reader.ReadFloat();

                cplayback.FilterLFOs.Add(filterlfo);
            }

            //bug fix because I released this with the writer only writing half the datum, so the tag should be thrown out if it predates this commit
            cplayback.OriginalRadioEffect = new DatumIndex(reader.ReadUInt32());
            if (cplayback.OriginalRadioEffect.Salt == 0)
            {
                cplayback.OriginalRadioEffect = DatumIndex.Null;
            }

            cplayback.LowpassEffects = new System.Collections.Generic.List <SoundCustomPlaybackLowpassEffect>();
            int lowpasscount = reader.ReadInt32();

            for (int i = 0; i < lowpasscount; i++)
            {
                SoundCustomPlaybackLowpassEffect lp = new SoundCustomPlaybackLowpassEffect();

                lp.Attack          = reader.ReadFloat();
                lp.Release         = reader.ReadFloat();
                lp.CutoffFrequency = reader.ReadFloat();
                lp.OutputGain      = reader.ReadFloat();

                cplayback.LowpassEffects.Add(lp);
            }

            cplayback.Components = new System.Collections.Generic.List <ExtractedSoundCustomPlaybackComponent>();
            int compcount = reader.ReadInt32();

            for (int i = 0; i < compcount; i++)
            {
                ExtractedSoundCustomPlaybackComponent c = new ExtractedSoundCustomPlaybackComponent();

                //bug fix because I released this with the writer only writing half the datum, so the tag should be thrown out if it predates this commit
                c.OriginalSound = new DatumIndex(reader.ReadUInt32());
                if (c.OriginalSound.Salt == 0)
                {
                    c.OriginalSound = DatumIndex.Null;
                }

                c.Gain  = reader.ReadFloat();
                c.Flags = reader.ReadInt32();

                cplayback.Components.Add(c);
            }

            return(cplayback);
        }
Exemple #2
0
 /// <summary>
 ///     Adds information about a sound custom playback to the container.
 /// </summary>
 /// <param name="customPlayback">The custom playback to add.</param>
 public void AddSoundCustomPlayback(ExtractedSoundCustomPlayback customPlayback)
 {
     _soundCustomPlaybacksByIndex[customPlayback.OriginalIndex] = customPlayback;
 }