Version: Unity 6.7 Alpha (6000.7)
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 or AudioLowPassFilter.AudioLowPassFilter.

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); } }
Copyright © 2023 Unity Technologies
优美缔软件(上海)有限公司 版权所有
"Unity"、Unity 徽标及其他 Unity 商标是 Unity Technologies 或其附属机构在美国及其他地区的商标或注册商标。其他名称或品牌是其各自所有者的商标。
公安部备案号:
31010902002961