Version: Unity 6.5 (6000.5)
LanguageEnglish
  • C#

AudioLowPassFilter.cutoffFrequency

Suggest a change

Success!

Thank you for helping us improve the quality of Unity Documentation. Although we cannot accept all submissions, we do read each suggested change from our users and will make updates where applicable.

Close

Submission failed

For some reason your suggested change could not be submitted. Please <a>try again</a> in a few minutes. And thank you for taking the time to help us improve the quality of Unity Documentation.

Close

Cancel

Switch to Manual
public float cutoffFrequency;

Description

Cutoff frequency in hertz for the low-pass filter.

The cutoff frequency is usually defined by the point on the smooth curve where attenuation hits -3 dB (~0.71) and is also the center frequency where high values of AudioLowPassFilter.lowpassResonanceQ causes a boost. Frequencies at and below this value are gradually much less affected by the filter. A lower cutoff frequency attenuates more high-frequency content. A higher cutoff frequency attenuates less high-frequency content.

The value ranges from 10.0 to 22000.0. The default is 5000.0. Values outside this range are clamped.

Setting this property replaces any custom cutoff curve with a single constant cutoff frequency. To change the cutoff frequency based on distance, use AudioLowPassFilter.customCutoffCurve.

using UnityEngine;

[RequireComponent(typeof(AudioSource))] [RequireComponent(typeof(AudioLowPassFilter))] public class LowPassCutoffExample : MonoBehaviour { const float lowCutoffHz = 800f; const float highCutoffHz = 22000f;

AudioLowPassFilter lowPass;

void Awake() { lowPass = GetComponent<AudioLowPassFilter>(); }

void Update() { // Mathf.Sin(Time.time) ranges from -1 to 1. Add 1 to get 0 to 2, then multiply by 0.5 // to get an interpolation factor t in the range 0 to 1 that changes smoothly over time. float t = (Mathf.Sin(Time.time) + 1f) * 0.5f; lowPass.cutoffFrequency = Mathf.Lerp(lowCutoffHz, highCutoffHz, t); } }