Example #1
0
        public override void SetOn(Sample sample, float value)
        {
            AudioReverbFilter audioReverbFilter = ((Component)sample.source).GetComponent <AudioReverbFilter>();

            if ((UnityEngine.Object)audioReverbFilter == (UnityEngine.Object)null)
            {
                audioReverbFilter = sample.source.gameObject.AddComponent <AudioReverbFilter>();
            }
            ReverbSetup reverbSetup;

            if (value < 0.0010000000474974513)
            {
                reverbSetup = this.baseSetup;
            }
            reverbSetup = ((!(value > 0.99900001287460327)) ? ReverbSetup.Lerp(this.baseSetup, this.targetSetup, value) : this.targetSetup);
            reverbSetup.ApplyTo(audioReverbFilter);
        }
        public override void SetOn(Sample sample, float value)
        {
            AudioReverbFilter audioReverbFilter = sample.source.GetComponent <AudioReverbFilter>();

            if (audioReverbFilter == null)
            {
                audioReverbFilter = sample.source.gameObject.AddComponent <AudioReverbFilter>();
            }
            ReverbSetup reverbSetup;

            if (value < 0.001f)
            {
                reverbSetup = baseSetup;
            }
            reverbSetup = ((!(value > 0.999f)) ? ReverbSetup.Lerp(baseSetup, targetSetup, value) : targetSetup);
            reverbSetup.ApplyTo(audioReverbFilter);
        }
Example #3
0
 public static ReverbSetup Lerp(ReverbSetup A, ReverbSetup B, float t)
 {
     return(new ReverbSetup
     {
         dryLevel = Mathf.Lerp(A.dryLevel, B.dryLevel, t),
         room = Mathf.Lerp(A.room, B.room, t),
         roomHF = Mathf.Lerp(A.roomHF, B.roomHF, t),
         roomLF = Mathf.Lerp(A.roomLF, B.roomLF, t),
         decayTime = Mathf.Lerp(A.decayTime, B.decayTime, t),
         decayHFRatio = Mathf.Lerp(A.decayHFRatio, B.decayHFRatio, t),
         reflectionsLevel = Mathf.Lerp(A.reflectionsLevel, B.reflectionsLevel, t),
         reflectionsDelay = Mathf.Lerp(A.reflectionsDelay, B.reflectionsDelay, t),
         reverbLevel = Mathf.Lerp(A.reverbLevel, B.reverbLevel, t),
         reverbDelay = Mathf.Lerp(A.reverbDelay, B.reverbDelay, t),
         hfReference = Mathf.Lerp(A.hfReference, B.hfReference, t),
         lfReference = Mathf.Lerp(A.lfReference, B.lfReference, t),
         diffusion = Mathf.Lerp(A.diffusion, B.diffusion, t),
         density = Mathf.Lerp(A.density, B.density, t)
     });
 }
Example #4
0
        public static void SetupAs(this ReverbSetup setup, AudioReverbPreset preset)
        {
            GameObject gameObject = new GameObject("OneFrameTemp");

            gameObject.AddComponent <AudioSource>();
            AudioReverbFilter audioReverbFilter = gameObject.AddComponent <AudioReverbFilter>();

            audioReverbFilter.reverbPreset = preset;
            setup.dryLevel         = audioReverbFilter.dryLevel;
            setup.room             = audioReverbFilter.room;
            setup.roomHF           = audioReverbFilter.roomHF;
            setup.roomLF           = audioReverbFilter.roomLF;
            setup.decayTime        = audioReverbFilter.decayTime;
            setup.decayHFRatio     = audioReverbFilter.decayHFRatio;
            setup.reflectionsLevel = audioReverbFilter.reflectionsLevel;
            setup.reflectionsDelay = audioReverbFilter.reflectionsDelay;
            setup.reverbLevel      = audioReverbFilter.reverbLevel;
            setup.reverbDelay      = audioReverbFilter.reverbDelay;
            setup.hfReference      = audioReverbFilter.hfReference;
            setup.lfReference      = audioReverbFilter.lfReference;
            setup.diffusion        = audioReverbFilter.diffusion;
            setup.density          = audioReverbFilter.density;
            UnityEngine.Object.Destroy(audioReverbFilter);
        }