AudioFormat
AudioFormat 用于访问 一系列语音格式和通道配置常量
例如用于AudioTrack 和AudioRecord中
The AudioFormat class is used to access a number of audio format and
* channel configuration constants. They are for instance used
* in {@link AudioTrack} and {@link AudioRecord}.
//---------------------------------------------------------
// Constants
//--------------------
/** Invalid audio data format */ 非法音频数据格式
public static final int ENCODING_INVALID = 0;
/** Default audio data format */ 默认音频数据格式
public static final int ENCODING_DEFAULT = 1;
// These two values must be kept in sync with JNI code for AudioTrack, AudioRecord
/** Audio data format: PCM 16 bit per sample. Guaranteed to be supported by devices. */ 音频数据格式 16bit取样 保证设备支持
public static final int ENCODING_PCM_16BIT = 2;
/** Audio data format: PCM 8 bit per sample. Not guaranteed to be supported by devices. */ 8bit 不保证设备支持
public static final int ENCODING_PCM_8BIT = 3;
/** Invalid audio channel configuration */
/** @deprecated use CHANNEL_INVALID instead */
@Deprecated public static final int CHANNEL_CONFIGURATION_INVALID = 0;
/** Default audio channel configuration */
/** @deprecated use CHANNEL_OUT_DEFAULT or CHANNEL_IN_DEFAULT instead */
@Deprecated public static final int CHANNEL_CONFIGURATION_DEFAULT = 1;
/** Mono audio configuration */
/** @deprecated use CHANNEL_OUT_MONO or CHANNEL_IN_MONO instead */
@Deprecated public static final int CHANNEL_CONFIGURATION_MONO = 2;
/** Stereo (2 channel) audio configuration */
/** @deprecated use CHANNEL_OUT_STEREO or CHANNEL_IN_STEREO instead */
@Deprecated public static final int CHANNEL_CONFIGURATION_STEREO = 3;
/** Invalid audio channel mask */ 不可用的音频通道
public static final int CHANNEL_INVALID = 0;
/** Default audio channel mask */ 默认音频通道
public static final int CHANNEL_OUT_DEFAULT = 1;
// Channel mask definitions below are translated to the native values defined in
// in /system/core/include/system/audio.h in the JNI code of AudioTrack
public static final int CHANNEL_OUT_FRONT_LEFT = 0x4; 前置左 0100
public static final int CHANNEL_OUT_FRONT_RIGHT = 0x8; 前置右 1000
public static final int CHANNEL_OUT_FRONT_CENTER = 0x10; 中央 10000
public static final int CHANNEL_OUT_LOW_FREQUENCY = 0x20; 低频 100000
public static final int CHANNEL_OUT_BACK_LEFT = 0x40; 后置左 1000000
public static final int CHANNEL_OUT_BACK_RIGHT = 0x80; 后置右 10000000
public static final int CHANNEL_OUT_FRONT_LEFT_OF_CENTER = 0x100; 中央前置左 100000000
public static final int CHANNEL_OUT_FRONT_RIGHT_OF_CENTER = 0x200; 中央前置右 1000000000
public static final int CHANNEL_OUT_BACK_CENTER = 0x400; 中央后置 10000000000
/** @hide */
public static final int CHANNEL_OUT_SIDE_LEFT = 0x800; 左声道
/** @hide */
public static final int CHANNEL_OUT_SIDE_RIGHT = 0x1000; 右声道
/** @hide */
public static final int CHANNEL_OUT_TOP_CENTER = 0x2000; 上中央
/** @hide */
public static final int CHANNEL_OUT_TOP_FRONT_LEFT = 0x4000; 上左前置
/** @hide */
public static final int CHANNEL_OUT_TOP_FRONT_CENTER = 0x8000; 上中央前置
/** @hide */
public static final int CHANNEL_OUT_TOP_FRONT_RIGHT = 0x10000; 上右前置
/** @hide */
public static final int CHANNEL_OUT_TOP_BACK_LEFT = 0x20000; 上左后置
/** @hide */
public static final int CHANNEL_OUT_TOP_BACK_CENTER = 0x40000; 上中后置
/** @hide */
public static final int CHANNEL_OUT_TOP_BACK_RIGHT = 0x80000; 上右后置
public static final int CHANNEL_OUT_MONO = CHANNEL_OUT_FRONT_LEFT; 单声道
public static final int CHANNEL_OUT_STEREO = (CHANNEL_OUT_FRONT_LEFT | CHANNEL_OUT_FRONT_RIGHT); 立体声道
public static final int CHANNEL_OUT_QUAD = (CHANNEL_OUT_FRONT_LEFT | CHANNEL_OUT_FRONT_RIGHT | 四声道
CHANNEL_OUT_BACK_LEFT | CHANNEL_OUT_BACK_RIGHT);
public static final int CHANNEL_OUT_SURROUND = (CHANNEL_OUT_FRONT_LEFT | CHANNEL_OUT_FRONT_RIGHT | 环绕
CHANNEL_OUT_FRONT_CENTER | CHANNEL_OUT_BACK_CENTER);
5.1声道是指中央声道,前置左、右声道、后置左、右环绕声道,及所谓的0.1声道重低音声道。一套系统总共可连接6个喇叭。5.1声道已广泛运用于各类传统影院和家庭影院中
public static final int CHANNEL_OUT_5POINT1 = (CHANNEL_OUT_FRONT_LEFT | CHANNEL_OUT_FRONT_RIGHT |
CHANNEL_OUT_FRONT_CENTER | CHANNEL_OUT_LOW_FREQUENCY | CHANNEL_OUT_BACK_LEFT | CHANNEL_OUT_BACK_RIGHT);
7.1声道系统的作用简单来说就是在听者的周围建立起一套前后声场相对平衡的声场,不同于5.1声道声场的是,它在原有的基础上增加了后中声场声道,同时它也不同于普通6.1声道声场,因为7.1声道有双路后中置,而这双路后中置的最大作用就是为了防止听者因为没有坐在皇帝位而在听觉上产生声场的偏差。
public static final int CHANNEL_OUT_7POINT1 = (CHANNEL_OUT_FRONT_LEFT | CHANNEL_OUT_FRONT_RIGHT |
CHANNEL_OUT_FRONT_CENTER | CHANNEL_OUT_LOW_FREQUENCY | CHANNEL_OUT_BACK_LEFT | CHANNEL_OUT_BACK_RIGHT |
CHANNEL_OUT_FRONT_LEFT_OF_CENTER | CHANNEL_OUT_FRONT_RIGHT_OF_CENTER);
/** @hide */
public static final int CHANNEL_OUT_7POINT1_SURROUND = (
CHANNEL_OUT_FRONT_LEFT | CHANNEL_OUT_FRONT_CENTER | CHANNEL_OUT_FRONT_RIGHT |
CHANNEL_OUT_SIDE_LEFT | CHANNEL_OUT_SIDE_RIGHT |
CHANNEL_OUT_BACK_LEFT | CHANNEL_OUT_BACK_RIGHT |
CHANNEL_OUT_LOW_FREQUENCY);
注意在这里不是逻辑或||,而是按位或|,因为按之前的描述。每一种声道模式的二进制编码。1的位置都是错开的
所以进行 | 操作后。得到的就是支持的所有模式。
而其中1的位数总和。就是支持声道模式的个数
public static final int CHANNEL_IN_DEFAULT = 1;
public static final int CHANNEL_IN_LEFT = 0x4;
public static final int CHANNEL_IN_RIGHT = 0x8;
public static final int CHANNEL_IN_FRONT = 0x10;
public static final int CHANNEL_IN_BACK = 0x20;
public static final int CHANNEL_IN_LEFT_PROCESSED = 0x40;
public static final int CHANNEL_IN_RIGHT_PROCESSED = 0x80;
public static final int CHANNEL_IN_FRONT_PROCESSED = 0x100;
public static final int CHANNEL_IN_BACK_PROCESSED = 0x200;
public static final int CHANNEL_IN_PRESSURE = 0x400;
public static final int CHANNEL_IN_X_AXIS = 0x800;
public static final int CHANNEL_IN_Y_AXIS = 0x1000;
public static final int CHANNEL_IN_Z_AXIS = 0x2000;
public static final int CHANNEL_IN_VOICE_UPLINK = 0x4000;
public static final int CHANNEL_IN_VOICE_DNLINK = 0x8000;
public static final int CHANNEL_IN_MONO = CHANNEL_IN_FRONT;
public static final int CHANNEL_IN_STEREO = (CHANNEL_IN_LEFT | CHANNEL_IN_RIGHT);