AudioFormat

public final class AudioFormat implements Parcelable


Represents the format configuration of audio data used by the Studio Sound API.

This class defines the fundamental properties required to interpret and process raw PCM audio streams, including the sample rate in Hz (8,000 Hz to 48,000 Hz), the audio sample encoding format (ENCODING_PCM_FLOAT), and the number of audio channels (mono or stereo).

Instances of this class are immutable and safe to pass across IPC boundaries.

Summary

Nested types

public final class AudioFormat.Builder

Builder for constructing AudioFormat instances.

Constants

static final Parcelable.Creator<AudioFormat>

Public fields

final int
final int
final int

Public constructors

AudioFormat(int sampleRate, @AudioEncoding int encoding, int channelCount)

Constructs a new AudioFormat with the specified properties.

Public methods

boolean
int

Returns the number of audio channels.

int

Returns the audio encoding format constant.

int

Returns the audio sample rate in Hz.

int
String
void
writeToParcel(Parcel dest, int flags)

Inherited Constants

From android.os.Parcelable
static final int
static final int
static final int
static final int

Inherited methods

From android.os.Parcelable
abstract int
int

Constants

CREATOR

public static final Parcelable.Creator<AudioFormat> CREATOR

Public fields

channelCount

public final int channelCount

encoding

public final int encoding

sampleRate

public final int sampleRate

Public constructors

AudioFormat

public AudioFormat(int sampleRate, @AudioEncoding int encoding, int channelCount)

Constructs a new AudioFormat with the specified properties.

Parameters
int sampleRate

the sample rate in Hz (between 8,000 and 48,000 Hz, e.g., 44100, 48000)

@AudioEncoding int encoding

the audio encoding format constant (ENCODING_PCM_FLOAT)

int channelCount

the number of audio channels (1 for mono, 2 for stereo)

Public methods

equals

public boolean equals(@Nullable Object o)

getChannelCount

public int getChannelCount()

Returns the number of audio channels.

Returns
int

the channel count (1 for mono, 2 for stereo)

getEncoding

@AudioEncoding
public int getEncoding()

Returns the audio encoding format constant.

Returns
int

the encoding format (ENCODING_PCM_FLOAT)

getSampleRate

public int getSampleRate()

Returns the audio sample rate in Hz.

Returns
int

the sample rate in Hz

hashCode

public int hashCode()

toString

public String toString()

writeToParcel

public void writeToParcel(Parcel dest, int flags)