# Class AudioEffects

java.lang.Object
com.codename1.media.AudioEffects

public final class AudioEffects extends Object

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

  ### Methods inherited from class Object

  `clone, equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- ## 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`: 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`: The source buffer.
    - `gain`: 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`: 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 below `lowCutoffHz`.
    - `midGain`: Gain for samples between the crossover bands.
    - `highGain`: Gain for samples above `highCutoffHz`.
    - `lowCutoffHz`: Low/mid crossover frequency.
    - `highCutoffHz`: 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`: 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`: 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`: 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.