public final class AudioEffects

  1. Object
  2. AudioEffects

Small PCM effects that operate on AudioBuffer data.

The methods in this class are platform-neutral and work on interleaved normalized float PCM samples in the [-1, 1] range. They return new AudioBuffer instances and leave the source buffer unchanged.

Methods

public static boolean isSimdOptimizationsEnabled()Indicates whether AudioEffects should use SIMD-backed kernels when the current platform supports them.
public static void setSimdOptimizationsEnabled(boolean enabled)Enables or disables SIMD-backed AudioEffects optimizations.
public static void resetSimdOptimizationsEnabled()Restores the default SIMD optimization setting for this platform.
public static AudioBuffer gain(AudioBuffer source, float gain)Applies gain to a PCM buffer.
public static AudioBuffer normalize(AudioBuffer source, float targetPeak)Normalizes a PCM buffer so its largest absolute sample reaches targetPeak.
public static AudioBuffer equalize(AudioBuffer source, float lowGain, float midGain, float highGain)Applies a simple three-band equalizer using default crossover points.
public static AudioBuffer equalize(AudioBuffer source, float lowGain, float midGain, float highGain, float lowCutoffHz, float highCutoffHz)Applies a simple three-band equalizer.
public static AudioBuffer removeCenter(AudioBuffer source)Reduces center-panned content in a stereo buffer.
public static AudioBuffer isolateCenter(AudioBuffer source)Isolates center-panned content in a stereo buffer.
public static AudioBuffer midSide(AudioBuffer source, float midGain, float sideGain)Applies mid/side processing to a stereo buffer.

Inherited methods

Method details

isSimdOptimizationsEnabled

public static boolean isSimdOptimizationsEnabled()
Indicates whether AudioEffects should use SIMD-backed kernels when the current platform supports them. Scalar fallbacks are always used for effects whose stateful filters don’t map to the current SIMD API.

Returns

true when SIMD optimizations are enabled.

setSimdOptimizationsEnabled

public static void setSimdOptimizationsEnabled(boolean enabled)

Enables or disables SIMD-backed AudioEffects optimizations.

This only changes internal implementation choices. It doesn’t change output format or API behavior.

Parameters

enabled boolean
true to use SIMD where supported, false to force scalar loops.

resetSimdOptimizationsEnabled

public static void resetSimdOptimizationsEnabled()
Restores the default SIMD optimization setting for this platform.

gain

public static AudioBuffer gain(AudioBuffer source, float gain)
Applies gain to a PCM buffer.

Parameters

source AudioBuffer
The source buffer.
gain float
Gain multiplier. 1.0f preserves level.

Returns

a new buffer with gain applied and samples clipped to [-1, 1].

normalize

public static AudioBuffer normalize(AudioBuffer source, float targetPeak)
Normalizes a PCM buffer so its largest absolute sample reaches targetPeak.

Parameters

source AudioBuffer
The source buffer.
targetPeak float
Desired peak amplitude in the range [0, 1].

Returns

a new normalized buffer. Silent buffers are returned unchanged.

equalize

public static AudioBuffer equalize(AudioBuffer source, float lowGain, float midGain, float highGain)

Applies a simple three-band equalizer using default crossover points.

Low frequencies are shaped below roughly 250 Hz, high frequencies above roughly 4 kHz, and the middle band contains the remaining signal.

Parameters

source AudioBuffer
The source buffer.
lowGain float
Gain for the low band.
midGain float
Gain for the middle band.
highGain float
Gain for the high band.

Returns

a new equalized buffer clipped to [-1, 1].

equalize

public static AudioBuffer equalize(AudioBuffer source, float lowGain, float midGain, float highGain, float lowCutoffHz, float highCutoffHz)

Applies a simple three-band equalizer.

This is intended for lightweight tone shaping and demos, not as a mastering-grade parametric equalizer.

Parameters

source AudioBuffer
The source buffer.
lowGain float
Gain for samples below lowCutoffHz.
midGain float
Gain for samples between the crossover bands.
highGain float
Gain for samples above highCutoffHz.
lowCutoffHz float
Low/mid crossover frequency.
highCutoffHz float
Mid/high crossover frequency.

Returns

a new equalized buffer clipped to [-1, 1].

removeCenter

public static AudioBuffer removeCenter(AudioBuffer source)

Reduces center-panned content in a stereo buffer.

This is the classic mid/side “vocal remover” technique. It only works when the content to remove is centered and similar in both channels.

Parameters

source AudioBuffer
A stereo source buffer.

Returns

a new stereo buffer with the center channel reduced.

isolateCenter

public static AudioBuffer isolateCenter(AudioBuffer source)

Isolates center-panned content in a stereo buffer.

This can be useful for centered dialog or vocals, but it isn’t true speech separation. It preserves only content common to the left and right channels, so it requires a stereo source where the target content is actually centered.

Parameters

source AudioBuffer
A stereo source buffer.

Returns

a new stereo buffer containing the center component.

midSide

public static AudioBuffer midSide(AudioBuffer source, float midGain, float sideGain)

Applies mid/side processing to a stereo buffer.

Use a larger midGain and smaller sideGain for simple voice/dialog enhancement, or midGain=0 and sideGain=1 for center removal.

Parameters

source AudioBuffer
A stereo source buffer.
midGain float
Gain for content common to left and right channels.
sideGain float
Gain for content that differs between channels.

Returns

a new stereo buffer.