Android APIs
public class

AudioFormat

extends Object
java.lang.Object
   ↳ android.media.AudioFormat

Class Overview

The AudioFormat class is used to access a number of audio format and channel configuration constants. They are for instance used in AudioTrack and AudioRecord.

Summary

Nested Classes
class AudioFormat.Builder Builder class for AudioFormat objects. 
Constants
int CHANNEL_CONFIGURATION_DEFAULT This constant was deprecated in API level 5. use CHANNEL_OUT_DEFAULT or CHANNEL_IN_DEFAULT instead
int CHANNEL_CONFIGURATION_INVALID This constant was deprecated in API level 5. use CHANNEL_INVALID instead
int CHANNEL_CONFIGURATION_MONO This constant was deprecated in API level 5. use CHANNEL_OUT_MONO or CHANNEL_IN_MONO instead
int CHANNEL_CONFIGURATION_STEREO This constant was deprecated in API level 5. use CHANNEL_OUT_STEREO or CHANNEL_IN_STEREO instead
int CHANNEL_INVALID Invalid audio channel mask
int CHANNEL_IN_BACK
int CHANNEL_IN_BACK_PROCESSED
int CHANNEL_IN_DEFAULT
int CHANNEL_IN_FRONT
int CHANNEL_IN_FRONT_PROCESSED
int CHANNEL_IN_LEFT
int CHANNEL_IN_LEFT_PROCESSED
int CHANNEL_IN_MONO
int CHANNEL_IN_PRESSURE
int CHANNEL_IN_RIGHT
int CHANNEL_IN_RIGHT_PROCESSED
int CHANNEL_IN_STEREO
int CHANNEL_IN_VOICE_DNLINK
int CHANNEL_IN_VOICE_UPLINK
int CHANNEL_IN_X_AXIS
int CHANNEL_IN_Y_AXIS
int CHANNEL_IN_Z_AXIS
int CHANNEL_OUT_5POINT1
int CHANNEL_OUT_7POINT1
int CHANNEL_OUT_BACK_CENTER
int CHANNEL_OUT_BACK_LEFT
int CHANNEL_OUT_BACK_RIGHT
int CHANNEL_OUT_DEFAULT Default audio channel mask
int CHANNEL_OUT_FRONT_CENTER
int CHANNEL_OUT_FRONT_LEFT
int CHANNEL_OUT_FRONT_LEFT_OF_CENTER
int CHANNEL_OUT_FRONT_RIGHT
int CHANNEL_OUT_FRONT_RIGHT_OF_CENTER
int CHANNEL_OUT_LOW_FREQUENCY
int CHANNEL_OUT_MONO
int CHANNEL_OUT_QUAD
int CHANNEL_OUT_SIDE_LEFT
int CHANNEL_OUT_SIDE_RIGHT
int CHANNEL_OUT_STEREO
int CHANNEL_OUT_SURROUND
int ENCODING_AC3 Audio data format: AC-3 compressed
int ENCODING_DEFAULT Default audio data format
int ENCODING_E_AC3 Audio data format: E-AC-3 compressed
int ENCODING_INVALID Invalid audio data format
int ENCODING_PCM_16BIT Audio data format: PCM 16 bit per sample.
int ENCODING_PCM_8BIT Audio data format: PCM 8 bit per sample.
int ENCODING_PCM_FLOAT Audio data format: single-precision floating-point per sample
Public Methods
int getChannelMask()
Return the channel mask.
int getEncoding()
Return the encoding.
int getSampleRate()
Return the sample rate.
String toString()
Returns a string containing a concise, human-readable description of this object.
[Expand]
Inherited Methods
From class java.lang.Object

Constants

public static final int CHANNEL_CONFIGURATION_DEFAULT

Added in API level 3

This constant was deprecated in API level 5.
use CHANNEL_OUT_DEFAULT or CHANNEL_IN_DEFAULT instead

Constant Value: 1 (0x00000001)

public static final int CHANNEL_CONFIGURATION_INVALID

Added in API level 3

This constant was deprecated in API level 5.
use CHANNEL_INVALID instead

Constant Value: 0 (0x00000000)

public static final int CHANNEL_CONFIGURATION_MONO

Added in API level 3

This constant was deprecated in API level 5.
use CHANNEL_OUT_MONO or CHANNEL_IN_MONO instead

Constant Value: 2 (0x00000002)

public static final int CHANNEL_CONFIGURATION_STEREO

Added in API level 3

This constant was deprecated in API level 5.
use CHANNEL_OUT_STEREO or CHANNEL_IN_STEREO instead

Constant Value: 3 (0x00000003)

public static final int CHANNEL_INVALID

Added in API level 5

Invalid audio channel mask

Constant Value: 0 (0x00000000)

public static final int CHANNEL_IN_BACK

Added in API level 5

Constant Value: 32 (0x00000020)

public static final int CHANNEL_IN_BACK_PROCESSED

Added in API level 5

Constant Value: 512 (0x00000200)

public static final int CHANNEL_IN_DEFAULT

Added in API level 5

Constant Value: 1 (0x00000001)

public static final int CHANNEL_IN_FRONT

Added in API level 5

Constant Value: 16 (0x00000010)

public static final int CHANNEL_IN_FRONT_PROCESSED

Added in API level 5

Constant Value: 256 (0x00000100)

public static final int CHANNEL_IN_LEFT

Added in API level 5

Constant Value: 4 (0x00000004)

public static final int CHANNEL_IN_LEFT_PROCESSED

Added in API level 5

Constant Value: 64 (0x00000040)

public static final int CHANNEL_IN_MONO

Added in API level 5

Constant Value: 16 (0x00000010)

public static final int CHANNEL_IN_PRESSURE

Added in API level 5

Constant Value: 1024 (0x00000400)

public static final int CHANNEL_IN_RIGHT

Added in API level 5

Constant Value: 8 (0x00000008)

public static final int CHANNEL_IN_RIGHT_PROCESSED

Added in API level 5

Constant Value: 128 (0x00000080)

public static final int CHANNEL_IN_STEREO

Added in API level 5

Constant Value: 12 (0x0000000c)

public static final int CHANNEL_IN_VOICE_DNLINK

Added in API level 5

Constant Value: 32768 (0x00008000)

public static final int CHANNEL_IN_VOICE_UPLINK

Added in API level 5

Constant Value: 16384 (0x00004000)

public static final int CHANNEL_IN_X_AXIS

Added in API level 5

Constant Value: 2048 (0x00000800)

public static final int CHANNEL_IN_Y_AXIS

Added in API level 5

Constant Value: 4096 (0x00001000)

public static final int CHANNEL_IN_Z_AXIS

Added in API level 5

Constant Value: 8192 (0x00002000)

public static final int CHANNEL_OUT_5POINT1

Added in API level 5

Constant Value: 252 (0x000000fc)

public static final int CHANNEL_OUT_7POINT1

Added in API level 5

Constant Value: 1020 (0x000003fc)

public static final int CHANNEL_OUT_BACK_CENTER

Added in API level 5

Constant Value: 1024 (0x00000400)

public static final int CHANNEL_OUT_BACK_LEFT

Added in API level 5

Constant Value: 64 (0x00000040)

public static final int CHANNEL_OUT_BACK_RIGHT

Added in API level 5

Constant Value: 128 (0x00000080)

public static final int CHANNEL_OUT_DEFAULT

Added in API level 5

Default audio channel mask

Constant Value: 1 (0x00000001)

public static final int CHANNEL_OUT_FRONT_CENTER

Added in API level 5

Constant Value: 16 (0x00000010)

public static final int CHANNEL_OUT_FRONT_LEFT

Added in API level 5

Constant Value: 4 (0x00000004)

public static final int CHANNEL_OUT_FRONT_LEFT_OF_CENTER

Added in API level 5

Constant Value: 256 (0x00000100)

public static final int CHANNEL_OUT_FRONT_RIGHT

Added in API level 5

Constant Value: 8 (0x00000008)

public static final int CHANNEL_OUT_FRONT_RIGHT_OF_CENTER

Added in API level 5

Constant Value: 512 (0x00000200)

public static final int CHANNEL_OUT_LOW_FREQUENCY

Added in API level 5

Constant Value: 32 (0x00000020)

public static final int CHANNEL_OUT_MONO

Added in API level 5

Constant Value: 4 (0x00000004)

public static final int CHANNEL_OUT_QUAD

Added in API level 5

Constant Value: 204 (0x000000cc)

public static final int CHANNEL_OUT_SIDE_LEFT

Added in API level 21

Constant Value: 2048 (0x00000800)

public static final int CHANNEL_OUT_SIDE_RIGHT

Added in API level 21

Constant Value: 4096 (0x00001000)

public static final int CHANNEL_OUT_STEREO

Added in API level 5

Constant Value: 12 (0x0000000c)

public static final int CHANNEL_OUT_SURROUND

Added in API level 5

Constant Value: 1052 (0x0000041c)

public static final int ENCODING_AC3

Added in API level 21

Audio data format: AC-3 compressed

Constant Value: 5 (0x00000005)

public static final int ENCODING_DEFAULT

Added in API level 3

Default audio data format

Constant Value: 1 (0x00000001)

public static final int ENCODING_E_AC3

Added in API level 21

Audio data format: E-AC-3 compressed

Constant Value: 6 (0x00000006)

public static final int ENCODING_INVALID

Added in API level 3

Invalid audio data format

Constant Value: 0 (0x00000000)

public static final int ENCODING_PCM_16BIT

Added in API level 3

Audio data format: PCM 16 bit per sample. Guaranteed to be supported by devices.

Constant Value: 2 (0x00000002)

public static final int ENCODING_PCM_8BIT

Added in API level 3

Audio data format: PCM 8 bit per sample. Not guaranteed to be supported by devices.

Constant Value: 3 (0x00000003)

public static final int ENCODING_PCM_FLOAT

Added in API level 21

Audio data format: single-precision floating-point per sample

Constant Value: 4 (0x00000004)

Public Methods

public int getChannelMask ()

Added in API level 21

Return the channel mask.

Returns

public int getEncoding ()

Added in API level 21

Return the encoding.

Returns

public int getSampleRate ()

Added in API level 21

Return the sample rate.

Returns

public String toString ()

Added in API level 3

Returns a string containing a concise, human-readable description of this object. Subclasses are encouraged to override this method and provide an implementation that takes into account the object's type and data. The default implementation is equivalent to the following expression:

   getClass().getName() + '@' + Integer.toHexString(hashCode())

See Writing a useful toString method if you intend implementing your own toString method.

Returns
  • a printable representation of this object.