Files
godot-docs/classes/class_audioeffectcompressor.rst
2026-02-28 03:51:57 +00:00

202 lines
8.3 KiB
ReStructuredText

:github_url: hide
.. DO NOT EDIT THIS FILE!!!
.. Generated automatically from Godot engine sources.
.. Generator: https://github.com/godotengine/godot/tree/master/doc/tools/make_rst.py.
.. XML source: https://github.com/godotengine/godot/tree/master/doc/classes/AudioEffectCompressor.xml.
.. _class_AudioEffectCompressor:
AudioEffectCompressor
=====================
**Inherits:** :ref:`AudioEffect<class_AudioEffect>` **<** :ref:`Resource<class_Resource>` **<** :ref:`RefCounted<class_RefCounted>` **<** :ref:`Object<class_Object>`
Adds a downward compressor audio effect to an audio bus.
Allows control of the dynamic range via a volume threshold and timing controls.
.. rst-class:: classref-introduction-group
Description
-----------
A "compressor" decreases the volume of sounds when it exceeds a certain volume threshold level.
A compressor can have many uses in a mix:
- To compress the whole volume in the Master bus (although an :ref:`AudioEffectHardLimiter<class_AudioEffectHardLimiter>` is probably better).
- To ensure balance of voice audio clips.
- To sidechain, using another bus as a trigger. This decreases the volume of the bus it is attached to, by using the volume from another audio bus for threshold detection. This technique is common in video game mixing to decrease the volume of music and SFX while voices are being heard. This effect is also known as "ducking".
- To accentuate transients by using a long attack, letting sounds exceed the volume threshold level for a short period before compressing them. This can be used to make SFX more punchy.
.. rst-class:: classref-introduction-group
Tutorials
---------
- :doc:`Audio buses <../tutorials/audio/audio_buses>`
- :doc:`Audio effects <../tutorials/audio/audio_effects>`
.. rst-class:: classref-reftable-group
Properties
----------
.. table::
:widths: auto
+-------------------------------------+--------------------------------------------------------------------+-----------+
| :ref:`float<class_float>` | :ref:`attack_us<class_AudioEffectCompressor_property_attack_us>` | ``20.0`` |
+-------------------------------------+--------------------------------------------------------------------+-----------+
| :ref:`float<class_float>` | :ref:`gain<class_AudioEffectCompressor_property_gain>` | ``0.0`` |
+-------------------------------------+--------------------------------------------------------------------+-----------+
| :ref:`float<class_float>` | :ref:`mix<class_AudioEffectCompressor_property_mix>` | ``1.0`` |
+-------------------------------------+--------------------------------------------------------------------+-----------+
| :ref:`float<class_float>` | :ref:`ratio<class_AudioEffectCompressor_property_ratio>` | ``4.0`` |
+-------------------------------------+--------------------------------------------------------------------+-----------+
| :ref:`float<class_float>` | :ref:`release_ms<class_AudioEffectCompressor_property_release_ms>` | ``250.0`` |
+-------------------------------------+--------------------------------------------------------------------+-----------+
| :ref:`StringName<class_StringName>` | :ref:`sidechain<class_AudioEffectCompressor_property_sidechain>` | ``&""`` |
+-------------------------------------+--------------------------------------------------------------------+-----------+
| :ref:`float<class_float>` | :ref:`threshold<class_AudioEffectCompressor_property_threshold>` | ``0.0`` |
+-------------------------------------+--------------------------------------------------------------------+-----------+
.. rst-class:: classref-section-separator
----
.. rst-class:: classref-descriptions-group
Property Descriptions
---------------------
.. _class_AudioEffectCompressor_property_attack_us:
.. rst-class:: classref-property
:ref:`float<class_float>` **attack_us** = ``20.0`` :ref:`🔗<class_AudioEffectCompressor_property_attack_us>`
.. rst-class:: classref-property-setget
- |void| **set_attack_us**\ (\ value\: :ref:`float<class_float>`\ )
- :ref:`float<class_float>` **get_attack_us**\ (\ )
Compressor's reaction time when the audio exceeds the volume threshold level, in microseconds. Value can range from 20 to 2000.
.. rst-class:: classref-item-separator
----
.. _class_AudioEffectCompressor_property_gain:
.. rst-class:: classref-property
:ref:`float<class_float>` **gain** = ``0.0`` :ref:`🔗<class_AudioEffectCompressor_property_gain>`
.. rst-class:: classref-property-setget
- |void| **set_gain**\ (\ value\: :ref:`float<class_float>`\ )
- :ref:`float<class_float>` **get_gain**\ (\ )
Gain of the audio signal, in dB. Value can range from -20 to 20.
.. rst-class:: classref-item-separator
----
.. _class_AudioEffectCompressor_property_mix:
.. rst-class:: classref-property
:ref:`float<class_float>` **mix** = ``1.0`` :ref:`🔗<class_AudioEffectCompressor_property_mix>`
.. rst-class:: classref-property-setget
- |void| **set_mix**\ (\ value\: :ref:`float<class_float>`\ )
- :ref:`float<class_float>` **get_mix**\ (\ )
Balance between the original audio and the compressed audio. Value can range from 0 (totally dry) to 1 (totally wet).
.. rst-class:: classref-item-separator
----
.. _class_AudioEffectCompressor_property_ratio:
.. rst-class:: classref-property
:ref:`float<class_float>` **ratio** = ``4.0`` :ref:`🔗<class_AudioEffectCompressor_property_ratio>`
.. rst-class:: classref-property-setget
- |void| **set_ratio**\ (\ value\: :ref:`float<class_float>`\ )
- :ref:`float<class_float>` **get_ratio**\ (\ )
Amount of compression applied to the audio once it passes the volume threshold level. The higher the ratio, the stronger the compression applied to audio signals that pass the volume threshold level. Value can range from 1 to 48.
.. rst-class:: classref-item-separator
----
.. _class_AudioEffectCompressor_property_release_ms:
.. rst-class:: classref-property
:ref:`float<class_float>` **release_ms** = ``250.0`` :ref:`🔗<class_AudioEffectCompressor_property_release_ms>`
.. rst-class:: classref-property-setget
- |void| **set_release_ms**\ (\ value\: :ref:`float<class_float>`\ )
- :ref:`float<class_float>` **get_release_ms**\ (\ )
Compressor's delay time to stop decreasing the volume after the it falls below the volume threshold level, in milliseconds. Value can range from 20 to 2000.
.. rst-class:: classref-item-separator
----
.. _class_AudioEffectCompressor_property_sidechain:
.. rst-class:: classref-property
:ref:`StringName<class_StringName>` **sidechain** = ``&""`` :ref:`🔗<class_AudioEffectCompressor_property_sidechain>`
.. rst-class:: classref-property-setget
- |void| **set_sidechain**\ (\ value\: :ref:`StringName<class_StringName>`\ )
- :ref:`StringName<class_StringName>` **get_sidechain**\ (\ )
Audio bus to use for the volume threshold detection.
.. rst-class:: classref-item-separator
----
.. _class_AudioEffectCompressor_property_threshold:
.. rst-class:: classref-property
:ref:`float<class_float>` **threshold** = ``0.0`` :ref:`🔗<class_AudioEffectCompressor_property_threshold>`
.. rst-class:: classref-property-setget
- |void| **set_threshold**\ (\ value\: :ref:`float<class_float>`\ )
- :ref:`float<class_float>` **get_threshold**\ (\ )
The volume level above which compression is applied to the audio, in dB. Value can range from -60 to 0.
.. |virtual| replace:: :abbr:`virtual (This method should typically be overridden by the user to have any effect.)`
.. |required| replace:: :abbr:`required (This method is required to be overridden when extending its base class.)`
.. |const| replace:: :abbr:`const (This method has no side effects. It doesn't modify any of the instance's member variables.)`
.. |vararg| replace:: :abbr:`vararg (This method accepts any number of arguments after the ones described here.)`
.. |constructor| replace:: :abbr:`constructor (This method is used to construct a type.)`
.. |static| replace:: :abbr:`static (This method doesn't need an instance to be called, so it can be called directly using the class name.)`
.. |operator| replace:: :abbr:`operator (This method describes a valid operator to use with this type as left-hand operand.)`
.. |bitfield| replace:: :abbr:`BitField (This value is an integer composed as a bitmask of the following flags.)`
.. |void| replace:: :abbr:`void (No return value.)`