@UnstableApi
class PcmAudioUtil


Utility methods for PCM audio data.

Summary

Public functions

java-static ByteBuffer!
rampUpVolume(
    buffer: ByteBuffer!,
    @C.Encoding pcmEncoding: Int,
    pcmFrameSize: Int,
    startFrameIndex: Int,
    rampFrameCount: Int
)

Returns a new ByteBuffer with linear volume ramping applied.

java-static Int
readAs32BitIntPcm(buffer: ByteBuffer!, @C.Encoding pcmEncoding: Int)

Reads a single-channel PCM value from the buffer and returns it as a 32-bit integer PCM value.

java-static Unit
write32BitIntPcm(
    buffer: ByteBuffer!,
    pcm32bit: Int,
    @C.Encoding pcmEncoding: Int
)

Writes a 32-bit integer PCM value to a buffer in the given target PCM encoding.

Public functions

rampUpVolume

java-static fun rampUpVolume(
    buffer: ByteBuffer!,
    @C.Encoding pcmEncoding: Int,
    pcmFrameSize: Int,
    startFrameIndex: Int,
    rampFrameCount: Int
): ByteBuffer!

Returns a new ByteBuffer with linear volume ramping applied.

Parameters
buffer: ByteBuffer!

The input buffer containing PCM frames. The buffer will be fully consumed by this method.

@C.Encoding pcmEncoding: Int

The C.Encoding of the PCM frames.

pcmFrameSize: Int

The overall frame size of one PCM frame (including all channels).

startFrameIndex: Int

The index of the first frame within the audio ramp duration (as specified by rampFrameCount).

rampFrameCount: Int

The overall ramp duration in number of frames.

Returns
ByteBuffer!

The ByteBuffer containing the modified PCM data.

readAs32BitIntPcm

java-static fun readAs32BitIntPcm(buffer: ByteBuffer!, @C.Encoding pcmEncoding: Int): Int

Reads a single-channel PCM value from the buffer and returns it as a 32-bit integer PCM value.

Parameters
buffer: ByteBuffer!

The ByteBuffer to read from.

@C.Encoding pcmEncoding: Int

The C.Encoding of the PCM data in the buffer.

Returns
Int

The 32-bit PCM value of the read buffer.

write32BitIntPcm

java-static fun write32BitIntPcm(
    buffer: ByteBuffer!,
    pcm32bit: Int,
    @C.Encoding pcmEncoding: Int
): Unit

Writes a 32-bit integer PCM value to a buffer in the given target PCM encoding.

Parameters
buffer: ByteBuffer!

The ByteBuffer to write to.

pcm32bit: Int

The 32-bit PCM value.

@C.Encoding pcmEncoding: Int

The target C.Encoding of the PCM data in the buffer.