PcmAudioUtil
@UnstableApi
public final class PcmAudioUtil
Utility methods for PCM audio data.
Summary
Public methods |
|
|---|---|
static ByteBuffer |
rampUpVolume(Returns a new |
static int |
readAs32BitIntPcm(ByteBuffer buffer, @C.Encoding int pcmEncoding)Reads a single-channel PCM value from the buffer and returns it as a 32-bit integer PCM value. |
static void |
write32BitIntPcm(Writes a 32-bit integer PCM value to a buffer in the given target PCM encoding. |
Public methods
rampUpVolume
public static ByteBuffer rampUpVolume(
ByteBuffer buffer,
@C.Encoding int pcmEncoding,
int pcmFrameSize,
int startFrameIndex,
int rampFrameCount
)
Returns a new ByteBuffer with linear volume ramping applied.
| Parameters | |
|---|---|
ByteBuffer buffer |
The input buffer containing PCM frames. The buffer will be fully consumed by this method. |
@C.Encoding int pcmEncoding |
The |
int pcmFrameSize |
The overall frame size of one PCM frame (including all channels). |
int startFrameIndex |
The index of the first frame within the audio ramp duration (as specified by |
int rampFrameCount |
The overall ramp duration in number of frames. |
| Returns | |
|---|---|
ByteBuffer |
The |
readAs32BitIntPcm
public static int readAs32BitIntPcm(ByteBuffer buffer, @C.Encoding int pcmEncoding)
Reads a single-channel PCM value from the buffer and returns it as a 32-bit integer PCM value.
| Parameters | |
|---|---|
ByteBuffer buffer |
The |
@C.Encoding int pcmEncoding |
The |
| Returns | |
|---|---|
int |
The 32-bit PCM value of the read buffer. |
write32BitIntPcm
public static void write32BitIntPcm(
ByteBuffer buffer,
int pcm32bit,
@C.Encoding int pcmEncoding
)
Writes a 32-bit integer PCM value to a buffer in the given target PCM encoding.
| Parameters | |
|---|---|
ByteBuffer buffer |
The |
int pcm32bit |
The 32-bit PCM value. |
@C.Encoding int pcmEncoding |
The target |