Inheritance: UnityEngine.MonoBehaviour
        private void Update()
        {
            AudioLoFiFilterSettings newSettings = sourceQualityFilterSettings[SourceQuality];

            if (newSettings != filterSettings)
            {
                // If we have an attached AudioInfluencerManager, we need to let it know
                // about our filter settings change.
                AudioEmitter influencerManager = gameObject.GetComponent <AudioEmitter>();
                if (influencerManager != null)
                {
                    influencerManager.SetNativeLowPassCutoffFrequency(newSettings.LowPassCutoff);
                    influencerManager.SetNativeHighPassCutoffFrequency(newSettings.HighPassCutoff);
                }

                filterSettings = newSettings;
                lowPassFilter.cutoffFrequency  = filterSettings.LowPassCutoff;
                highPassFilter.cutoffFrequency = filterSettings.HighPassCutoff;
            }
        }
Example #2
0
        /// <summary>
        /// Removes the previously applied audio effect.
        /// </summary>
        /// <param name="soundEmittingObject">The GameObject from which the effect is to be removed.</param>
        public void RemoveEffect(GameObject soundEmittingObject)
        {
            // Audio occlusion is performed using a low pass filter.
            AudioLowPassFilter lowPass = soundEmittingObject.GetComponent <AudioLowPassFilter>();

            if (lowPass == null)
            {
                return;
            }

            float        neutralFrequency  = AudioEmitter.NeutralHighFrequency;
            AudioEmitter influencerManager = soundEmittingObject.GetComponent <AudioEmitter>();

            if (influencerManager != null)
            {
                neutralFrequency = influencerManager.GetNativeLowPassCutoffFrequency();
            }

            lowPass.cutoffFrequency = neutralFrequency;
            lowPass.enabled         = false;

            // Note: Volume attenuation is reset in the AudioInfluencerManager, attached to the sound emitting object.
        }