27 [Tooltip(
"Frequency above which sound will not be heard after applying occlusion.")]
28 [Range(10.0f, 22000.0f)]
30 private float cutoffFrequency = 5000.0f;
31 public float CutoffFrequency
33 get {
return cutoffFrequency; }
39 cutoffFrequency = 10.0f;
41 else if (value > 22000.0f)
43 cutoffFrequency = 22000.0f;
47 cutoffFrequency = value;
61 [Tooltip(
"Percentage of the audio source volume that will be heard after applying occlusion.")]
64 private float volumePassThrough = 1.0f;
65 public float VolumePassThrough
67 get {
return volumePassThrough; }
73 volumePassThrough = 10.0f;
75 else if (value > 22000.0f)
77 volumePassThrough = 22000.0f;
81 volumePassThrough = value;
87 private void Update() { }
98 public void ApplyEffect(GameObject soundEmittingObject, AudioSource audioSource)
103 ApplyEffect(soundEmittingObject);
112 if (!isActiveAndEnabled)
115 AudioSource audioSource = soundEmittingObject.GetComponent<AudioSource>();
116 if (audioSource == null)
118 Debug.LogWarning(
"The specified emitter does not have an attached AudioSource component.");
123 AudioLowPassFilter lowPass = soundEmittingObject.GetComponent<AudioLowPassFilter>();
126 lowPass = soundEmittingObject.AddComponent<AudioLowPassFilter>();
128 lowPass.enabled =
true;
132 lowPass.cutoffFrequency = Mathf.Min(lowPass.cutoffFrequency, CutoffFrequency);
135 audioSource.volume *= VolumePassThrough;
147 public void RemoveEffect(GameObject soundEmittingObject, AudioSource audioSource)
151 RemoveEffect(soundEmittingObject);
161 AudioLowPassFilter lowPass = soundEmittingObject.GetComponent<AudioLowPassFilter>();
162 if (lowPass == null) {
return; }
166 if (influencerManager != null)
171 lowPass.cutoffFrequency = neutralFrequency;
172 lowPass.enabled =
false;