reckfellENGINE

AudioEffectDistortion

Adds a distortion audio effect to an audio bus. Remaps audio samples using a nonlinear function to achieve a distorted sound.

On this page
class AudioEffectDistortionReckfellSharpInherits AudioEffect

Adds a distortion audio effect to an audio bus. Remaps audio samples using a nonlinear function to achieve a distorted sound.

A "distortion" effect modifies the waveform via a nonlinear mathematical function (see available ones in AudioEffectDistortion.ModeEnum), 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 AudioEffectDistortion.Drive, the output sound will vary depending on the input's volume. To change the volume while maintaining the output waveform, use AudioEffectDistortion.PostGain. 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 AudioEffectDistortion.Drive is set to 0. This is not a bug. If this behavior is undesirable, consider disabling the effect using AudioServer.SetBusEffectEnabled.

Declarations checked against C# SDK 1.0.0. Expand a name to see declarations and documentation.

Constructors1

AudioEffectDistortionConstructor
# AudioEffectDistortion
C#
public AudioEffectDistortion();

Properties5

DriveProperty
# Drive
C#
public float Drive { get; set; }

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.

KeepHfHzProperty
# KeepHfHz
C#
public float KeepHfHz { get; set; }

High-pass filter, in Hz. Frequencies higher than this value will not be affected by the distortion. Value can range from 1 to 20000.

ModeProperty
# Mode
C#
public AudioEffectDistortion.ModeEnum Mode { get; set; }

Distortion type. Changes the nonlinear function used to distort the waveform. See AudioEffectDistortion.ModeEnum.

PostGainProperty
# PostGain
C#
public float PostGain { get; set; }

Gain after the effect, in dB. Value can range from -80 to 24.

PreGainProperty
# PreGain
C#
public float PreGain { get; set; }

Gain before the effect, in dB. Value can range from -60 to 60.

Methods10

GetDrivefloat
# GetDrive
C#
public float GetDrive();
Returns float
GetKeepHfHzfloat
# GetKeepHfHz
C#
public float GetKeepHfHz();
Returns float
GetModeAudioEffectDistortion.ModeEnum
# GetMode
C#
public AudioEffectDistortion.ModeEnum GetMode();
Returns AudioEffectDistortion.ModeEnum
GetPostGainfloat
# GetPostGain
C#
public float GetPostGain();
Returns float
GetPreGainfloat
# GetPreGain
C#
public float GetPreGain();
Returns float
SetDrivevoid
# SetDrive
C#
public void SetDrive(float drive);
Parameters
NameTypeDefault
drivefloat—
SetKeepHfHzvoid
# SetKeepHfHz
C#
public void SetKeepHfHz(float keepHfHz);
Parameters
NameTypeDefault
keepHfHzfloat—
SetModevoid
# SetMode
C#
public void SetMode(AudioEffectDistortion.ModeEnum mode);
Parameters
NameTypeDefault
modeAudioEffectDistortion.ModeEnum—
SetPostGainvoid
# SetPostGain
C#
public void SetPostGain(float postGain);
Parameters
NameTypeDefault
postGainfloat—
SetPreGainvoid
# SetPreGain
C#
public void SetPreGain(float preGain);
Parameters
NameTypeDefault
preGainfloat—

AudioEffectDistortion.ModeEnum

ValueDescription
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.

Clip = 0

Flattens the waveform at 0 dB in a sharp manner. AudioEffectDistortion.Drive increases amplitude of samples exponentially. This mode functions as a hard clipper if AudioEffectDistortion.Drive is set to 0, and is the only mode that clips audio signals at 0 dB.

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.

Overdrive = 3

Emulates the warm distortion produced by a field effect transistor, which is commonly used in solid-state musical instrument amplifiers. AudioEffectDistortion.Drive has no effect in this 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.

Reckfell Engine documentationBack to top ↑
QUICK LINKSGetting startedEntity hierarchyC# & .NET 10Scenes and prefabs
Reckfell guides and full API K
reckfellENGINE
RECKFELL ACCOUNT

Sign in

Sign in to your Reckfell account.

One account for the entire Reckfell platform.