Attention: Here be dragons
This is the latest
(unstable) version of this documentation, which may document features
not available in or compatible with released stable versions of Godot.
Checking the stable version of the documentation...
AudioEffectDistortion
Inherits: AudioEffect < Resource < RefCounted < Object
Adds a distortion audio effect to an audio bus.
Remaps audio samples using a nonlinear function to achieve a distorted sound.
Description
A "distortion" effect modifies the waveform via a nonlinear mathematical function (see available ones in Mode), based on the amplitude of the waveform's samples.
Note: In a nonlinear function, an input sample at x amplitude value, will either have its amplitude increased or decreased to a y value, based on the function value at x, which is why even at the same drive, the output sound will vary depending on the input's volume. To change the volume while maintaining the output waveform, use post_gain.
In this effect, each type is a different nonlinear function. The different types available are: clip, atan, lofi (bitcrush), overdrive, and waveshape. Every distortion type available here is symmetric: negative amplitude values are affected the same way as positive ones.
Although distortion will always change frequency content, usually by introducing high harmonics, different distortion types offer a range of sound qualities; from "soft" and "warm", to "crunchy" and "abrasive".
For games, it can help simulate sound coming from some saturated device or speaker very efficiently. It can also help the audio stand out in a mix, by introducing higher frequencies and increasing the volume.
Note: Although usually imperceptible, an enabled distortion effect still changes the sound even when drive is set to 0. This is not a bug. If this behavior is undesirable, consider disabling the effect using AudioServer.set_bus_effect_enabled().
Tutorials
Properties
|
||
|
||
|
||
|
||
|
Enumerations
enum Mode: 🔗
Mode MODE_CLIP = 0
Flattens the waveform at 0 dB in a sharp manner. drive increases amplitude of samples exponentially. This mode functions as a hard clipper if drive is set to 0, and is the only mode that clips audio signals at 0 dB.
Mode MODE_ATAN = 1
Flattens the waveform in a smooth manner, following an arctangent curve. The audio decreases in volume, before flattening peaks to PI * 4.0 (linear value), if it was normalized beforehand.
Mode MODE_LOFI = 2
Decreases audio bit depth to achieve a low-resolution audio signal, going from 16-bit to 2-bit. Can be used to emulate the sound of early digital audio devices.
Mode MODE_OVERDRIVE = 3
Emulates the warm distortion produced by a field effect transistor, which is commonly used in solid-state musical instrument amplifiers. drive has no effect in this mode.
Mode MODE_WAVESHAPE = 4
Flattens the waveform in a smooth manner, until it reaches a sharp peak at drive = 1, following a generic absolute sigmoid function.
Property Descriptions
Distortion intensity. Controls how much of the input audio is affected by the distortion curve by moving from a linear function to a nonlinear one. Value can range from 0 to 1.
High-pass filter, in Hz. Frequencies higher than this value will not be affected by the distortion. Value can range from 1 to 20000.
Distortion type. Changes the nonlinear function used to distort the waveform. See Mode.
Gain after the effect, in dB. Value can range from -80 to 24.
Gain before the effect, in dB. Value can range from -60 to 60.