private void Update() { AudioLoFiFilterSettings newSettings = sourceQualityFilterSettings[SourceQuality]; if (newSettings != filterSettings) { // If we have an attached AudioInfluencerController, we need to let it know // about our filter settings change. AudioInfluencerController influencerController = gameObject.GetComponent <AudioInfluencerController>(); if (influencerController != null) { influencerController.SetNativeLowPassCutoffFrequency(newSettings.LowPassCutoff); influencerController.SetNativeHighPassCutoffFrequency(newSettings.HighPassCutoff); } filterSettings = newSettings; lowPassFilter.cutoffFrequency = filterSettings.LowPassCutoff; highPassFilter.cutoffFrequency = filterSettings.HighPassCutoff; } }
/// <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 = AudioInfluencerController.NeutralHighFrequency; AudioInfluencerController influencerController = soundEmittingObject.GetComponent <AudioInfluencerController>(); if (influencerController != null) { neutralFrequency = influencerController.GetNativeLowPassCutoffFrequency(); } lowPass.cutoffFrequency = neutralFrequency; lowPass.enabled = false; // Note: Volume attenuation is reset in the AudioInfluencerController, attached to the sound emitting object. }