Class 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.
-
Method Summary
Modifier and TypeMethodDescriptionstatic AudioBufferequalize(AudioBuffer source, float lowGain, float midGain, float highGain) Applies a simple three-band equalizer using default crossover points.static AudioBufferequalize(AudioBuffer source, float lowGain, float midGain, float highGain, float lowCutoffHz, float highCutoffHz) Applies a simple three-band equalizer.static AudioBuffergain(AudioBuffer source, float gain) Applies gain to a PCM buffer.static AudioBufferisolateCenter(AudioBuffer source) Isolates center-panned content in a stereo buffer.static booleanIndicates whetherAudioEffectsshould use SIMD-backed kernels when the current platform supports them.static AudioBuffermidSide(AudioBuffer source, float midGain, float sideGain) Applies mid/side processing to a stereo buffer.static AudioBuffernormalize(AudioBuffer source, float targetPeak) Normalizes a PCM buffer so its largest absolute sample reachestargetPeak.static AudioBufferremoveCenter(AudioBuffer source) Reduces center-panned content in a stereo buffer.static voidRestores the default SIMD optimization setting for this platform.static voidsetSimdOptimizationsEnabled(boolean enabled) Enables or disables SIMD-backedAudioEffectsoptimizations.
-
Method Details
-
isSimdOptimizationsEnabled
public static boolean isSimdOptimizationsEnabled()Indicates whether
AudioEffectsshould 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
AudioEffectsoptimizations.This only changes internal implementation choices. It doesn't change output format or API behavior.
Parameters
enabled: 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
Applies gain to a PCM buffer.
Parameters
source: The source buffer.gain: Gain multiplier.1.0fpreserves level.
Returns
a new buffer with gain applied and samples clipped to
[-1, 1]. -
normalize
Normalizes a PCM buffer so its largest absolute sample reaches
targetPeak.Parameters
source: The source buffer.targetPeak: 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: The source buffer.lowGain: Gain for the low band.midGain: Gain for the middle band.highGain: 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: The source buffer.lowGain: Gain for samples belowlowCutoffHz.midGain: Gain for samples between the crossover bands.highGain: Gain for samples abovehighCutoffHz.lowCutoffHz: Low/mid crossover frequency.highCutoffHz: Mid/high crossover frequency.
Returns
a new equalized buffer clipped to
[-1, 1]. -
removeCenter
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: A stereo source buffer.
Returns
a new stereo buffer with the center channel reduced.
-
isolateCenter
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: A stereo source buffer.
Returns
a new stereo buffer containing the center component.
-
midSide
Applies mid/side processing to a stereo buffer.
Use a larger
midGainand smallersideGainfor simple voice/dialog enhancement, ormidGain=0andsideGain=1for center removal.Parameters
source: A stereo source buffer.midGain: Gain for content common to left and right channels.sideGain: Gain for content that differs between channels.
Returns
a new stereo buffer.
-