AudioMixingUtil


@UnstableApi
public final class AudioMixingUtil


Utility for mixing audio buffers.

Summary

Public methods

static boolean
static boolean
canMix(
    AudioProcessor.AudioFormat inputAudioFormat,
    AudioProcessor.AudioFormat outputAudioFormat
)
static ByteBuffer
mix(
    ByteBuffer inputBuffer,
    AudioProcessor.AudioFormat inputAudioFormat,
    ByteBuffer mixingBuffer,
    AudioProcessor.AudioFormat mixingAudioFormat,
    ChannelMixingMatrix matrix,
    int framesToMix,
    boolean accumulate,
    boolean clipFloatOutput
)

Mixes audio from the input buffer into the mixing buffer.

Public methods

canMix

public static boolean canMix(AudioProcessor.AudioFormat audioFormat)

canMix

public static boolean canMix(
    AudioProcessor.AudioFormat inputAudioFormat,
    AudioProcessor.AudioFormat outputAudioFormat
)

mix

public static ByteBuffer mix(
    ByteBuffer inputBuffer,
    AudioProcessor.AudioFormat inputAudioFormat,
    ByteBuffer mixingBuffer,
    AudioProcessor.AudioFormat mixingAudioFormat,
    ChannelMixingMatrix matrix,
    int framesToMix,
    boolean accumulate,
    boolean clipFloatOutput
)

Mixes audio from the input buffer into the mixing buffer.

canMix must return true for the formats.

Parameters
ByteBuffer inputBuffer

Input audio ByteBuffer, the position is advanced by the amount of bytes read and mixed.

AudioProcessor.AudioFormat inputAudioFormat

AudioFormat of the inputBuffer.

ByteBuffer mixingBuffer

Mixing audio ByteBuffer, the position is advanced by the amount of bytes written.

AudioProcessor.AudioFormat mixingAudioFormat

AudioFormat of the mixingBuffer.

ChannelMixingMatrix matrix

Scaled channel mapping from input to output.

int framesToMix

Number of audio frames to mix. Must be within the bounds of both buffers.

boolean accumulate

Whether to accumulate with the existing samples in the mixing buffer.

boolean clipFloatOutput

Whether to clip the output signal to be in the [-1.0, 1.0] range if the output encoding is ENCODING_PCM_FLOAT.

Returns
ByteBuffer

The mixingBuffer, for convenience.