Most visited

Recently visited

Added in API level 9

Equalizer

public class Equalizer
extends AudioEffect

java.lang.Object
    android.media.audiofx.AudioEffect
      android.media.audiofx.Equalizer


均衡器用于改变特定音乐源或主输出混合的频率响应。

应用程序创建一个Equalizer对象来实例化和控制音频框架中的均衡器引擎。 应用程序可以简单地使用预定义的预设或者对由均衡器控制的每个频带中的增益进行更精确的控制。

由Equalizer实现公开的方法,参数类型和单元直接映射由SLEqualizerItf接口的OpenSL ES 1.0.1规范(http://www.khronos.org/opensles/)定义的那些方法,参数类型和单元。 有关更多详细信息,请参阅此规范。

要将均衡器附加到特定的AudioTrack或MediaPlayer,请在构建均衡器时指定此AudioTrack或MediaPlayer的音频会话ID。

注:不建议使用会话0将全球音频输出混合连接到均衡器。

有关音频会话的详细信息,请参阅 getAudioSessionId()

有关控制音频效果的更多详细信息,请参见 AudioEffect类。

摘要(Summary)

Nested classes

interface Equalizer.OnParameterChangeListener

OnParameterChangeListener接口定义了当参数值发生变化时由均衡器调用的方法。

class Equalizer.Settings

Settings类重新组合所有均衡器参数。

常量(Constants)

int PARAM_BAND_FREQ_RANGE

波段频率范围。

int PARAM_BAND_LEVEL

乐队级别。

int PARAM_CENTER_FREQ

频带中心频率。

int PARAM_CURRENT_PRESET

当前预设。

int PARAM_GET_BAND

给定频率的频带。

int PARAM_GET_NUM_OF_PRESETS

请求预设数量。

int PARAM_GET_PRESET_NAME

请求预设名称。

int PARAM_LEVEL_RANGE

乐队等级范围。

int PARAM_NUM_BANDS

带数。

int PARAM_STRING_SIZE_MAX

预设名称的最大大小

Inherited constants

From class android.media.audiofx.AudioEffect

Inherited fields

From class android.media.audiofx.AudioEffect

Public constructors

Equalizer(int priority, int audioSession)

类构造函数。

公共方法(Public methods)

short getBand(int frequency)

获得对给定频率影响最大的频段。

int[] getBandFreqRange(short band)

获取给定频段的频率范围。

short getBandLevel(short band)

获取给定均衡器频段的增益集。

short[] getBandLevelRange()

获取 setBandLevel(short, short)使用的等级范围。

int getCenterFreq(short band)

获取给定乐队的中心频率。

short getCurrentPreset()

获取当前预设。

short getNumberOfBands()

获取均衡器引擎支持的频段数量。

short getNumberOfPresets()

获取均衡器支持的预设总数。

String getPresetName(short preset)

根据索引获取预设名称。

Equalizer.Settings getProperties()

获取均衡器属性。

void setBandLevel(short band, short level)

将给定的均衡器频段设置为给定的增益值。

void setParameterListener(Equalizer.OnParameterChangeListener listener)

注册OnParameterChangeListener接口。

void setProperties(Equalizer.Settings settings)

设置均衡器属性。

void usePreset(short preset)

根据给定的预设设置均衡器。

继承方法(Inherited methods)

From class android.media.audiofx.AudioEffect
From class java.lang.Object

常量(Constants)

PARAM_BAND_FREQ_RANGE

Added in API level 9
int PARAM_BAND_FREQ_RANGE

波段频率范围。 参数ID为Equalizer.OnParameterChangeListener

常量值:4(0x00000004)

PARAM_BAND_LEVEL

Added in API level 9
int PARAM_BAND_LEVEL

乐队级别。 OnParameterChangeListener的参数ID

常量值:2(0x00000002)

PARAM_CENTER_FREQ

Added in API level 9
int PARAM_CENTER_FREQ

频带中心频率。 OnParameterChangeListener的参数ID

常量值:3(0x00000003)

PARAM_CURRENT_PRESET

Added in API level 9
int PARAM_CURRENT_PRESET

当前预设。 OnParameterChangeListener的参数ID

常数值:6(0x00000006)

PARAM_GET_BAND

Added in API level 9
int PARAM_GET_BAND

给定频率的频带。 OnParameterChangeListener的参数ID

常量值:5(0x00000005)

PARAM_GET_NUM_OF_PRESETS

Added in API level 9
int PARAM_GET_NUM_OF_PRESETS

请求预设数量。 OnParameterChangeListener的参数ID

常量值:7(0x00000007)

PARAM_GET_PRESET_NAME

Added in API level 9
int PARAM_GET_PRESET_NAME

请求预设名称。 OnParameterChangeListener的参数ID

常量值:8(0x00000008)

PARAM_LEVEL_RANGE

Added in API level 9
int PARAM_LEVEL_RANGE

乐队等级范围。 OnParameterChangeListener的参数ID

常数值:1(0x00000001)

PARAM_NUM_BANDS

Added in API level 9
int PARAM_NUM_BANDS

带数。 OnParameterChangeListener的参数ID

常量值:0(0x00000000)

PARAM_STRING_SIZE_MAX

Added in API level 9
int PARAM_STRING_SIZE_MAX

预设名称的最大大小

常量值:32(0x00000020)

Public constructors

Equalizer

Added in API level 9
Equalizer (int priority, 
                int audioSession)

类构造函数。

参数(Parameters)
priority int: the priority level requested by the application for controlling the Equalizer engine. As the same engine can be shared by several applications, this parameter indicates how much the requesting application needs control of effect parameters. The normal priority is 0, above normal is a positive number, below normal a negative number.
audioSession int: system wide unique audio session identifier. The Equalizer will be attached to the MediaPlayer or AudioTrack in the same audio session.
抛出异常(Throws)
java.lang.IllegalStateException
java.lang.IllegalArgumentException
java.lang.UnsupportedOperationException
RuntimeException
IllegalStateException
IllegalArgumentException
UnsupportedOperationException

公共方法(Public methods)

getBand

Added in API level 9
short getBand (int frequency)

获得对给定频率影响最大的频段。

参数(Parameters)
frequency int: frequency in milliHertz which is to be equalized via the returned band.
返回(Returns)
short the frequency band that has most effect on the given frequency.
抛出异常(Throws)
IllegalStateException
IllegalArgumentException
UnsupportedOperationException
IllegalStateException
IllegalArgumentException

getBandFreqRange

Added in API level 9
int[] getBandFreqRange (short band)

获取给定频段的频率范围。

参数(Parameters)
band short: frequency band whose frequency range is requested. The numbering of the bands starts from 0 and ends at (number of bands - 1).
返回(Returns)
int[] the frequency range in millHertz in an array of integers. The first element is the lower limit of the range, the second element the upper limit.
抛出异常(Throws)
IllegalStateException
IllegalArgumentException
UnsupportedOperationException
IllegalStateException
IllegalArgumentException

getBandLevel

Added in API level 9
short getBandLevel (short band)

获取给定均衡器频段的增益集。

参数(Parameters)
band short: frequency band whose gain is requested. The numbering of the bands starts from 0 and ends at (number of bands - 1).
返回(Returns)
short the gain in millibels of the given band.
抛出异常(Throws)
IllegalStateException
IllegalArgumentException
UnsupportedOperationException
IllegalStateException
IllegalArgumentException

getBandLevelRange

Added in API level 9
short[] getBandLevelRange ()

获取setBandLevel(short, short)使用的等级范围。 该级别以毫巴表示。

返回(Returns)
short[] the band level range in an array of short integers. The first element is the lower limit of the range, the second element the upper limit.
抛出异常(Throws)
IllegalStateException
IllegalArgumentException
UnsupportedOperationException
IllegalStateException
IllegalArgumentException

getCenterFreq

Added in API level 9
int getCenterFreq (short band)

获取给定乐队的中心频率。

参数(Parameters)
band short: frequency band whose center frequency is requested. The numbering of the bands starts from 0 and ends at (number of bands - 1).
返回(Returns)
int the center frequency in milliHertz
抛出异常(Throws)
IllegalStateException
IllegalArgumentException
UnsupportedOperationException
IllegalStateException
IllegalArgumentException

getCurrentPreset

Added in API level 9
short getCurrentPreset ()

获取当前预设。

返回(Returns)
short the preset that is set at the moment.
抛出异常(Throws)
IllegalStateException
IllegalArgumentException
UnsupportedOperationException
IllegalStateException
IllegalArgumentException

getNumberOfBands

Added in API level 9
short getNumberOfBands ()

获取均衡器引擎支持的频段数量。

返回(Returns)
short the number of bands
抛出异常(Throws)
IllegalStateException
IllegalArgumentException
UnsupportedOperationException
IllegalStateException
IllegalArgumentException

getNumberOfPresets

Added in API level 9
short getNumberOfPresets ()

获取均衡器支持的预设总数。 预设将具有索引[0,预设数量-1]。

返回(Returns)
short the number of presets the equalizer supports.
抛出异常(Throws)
IllegalStateException
IllegalArgumentException
UnsupportedOperationException
IllegalStateException
IllegalArgumentException

getPresetName

Added in API level 9
String getPresetName (short preset)

根据索引获取预设名称。

参数(Parameters)
preset short: index of the preset. The valid range is [0, number of presets-1].
返回(Returns)
String a string containing the name of the given preset.
抛出异常(Throws)
IllegalStateException
IllegalArgumentException
UnsupportedOperationException

getProperties

Added in API level 9
Equalizer.Settings getProperties ()

获取均衡器属性。 当应用程序必须保存当前均衡器设置的快照时,此方法非常有用。

返回(Returns)
Equalizer.Settings an Equalizer.Settings object containing all current parameters values
抛出异常(Throws)
IllegalStateException
IllegalArgumentException
UnsupportedOperationException
IllegalStateException
IllegalArgumentException

setBandLevel

Added in API level 9
void setBandLevel (short band, 
                short level)

将给定的均衡器频段设置为给定的增益值。

参数(Parameters)
band short: frequency band that will have the new gain. The numbering of the bands starts from 0 and ends at (number of bands - 1).
level short: new gain in millibels that will be set to the given band. getBandLevelRange() will define the maximum and minimum values.
抛出异常(Throws)
IllegalStateException
IllegalArgumentException
UnsupportedOperationException
IllegalStateException
IllegalArgumentException
UnsupportedOperationException

也可以看看:

setParameterListener

Added in API level 9
void setParameterListener (Equalizer.OnParameterChangeListener listener)

注册OnParameterChangeListener接口。

参数(Parameters)
listener Equalizer.OnParameterChangeListener: OnParameterChangeListener interface registered

setProperties

Added in API level 9
void setProperties (Equalizer.Settings settings)

设置均衡器属性。 当必须从先前的备份应用均衡器设置时,此方法非常有用。

参数(Parameters)
settings Equalizer.Settings: an Equalizer.Settings object containing the properties to apply
抛出异常(Throws)
IllegalStateException
IllegalArgumentException
UnsupportedOperationException
IllegalStateException
IllegalArgumentException

usePreset

Added in API level 9
void usePreset (short preset)

根据给定的预设设置均衡器。

参数(Parameters)
preset short: new preset that will be taken into use. The valid range is [0, number of presets-1].
抛出异常(Throws)
IllegalStateException
IllegalArgumentException
UnsupportedOperationException
IllegalStateException
IllegalArgumentException
UnsupportedOperationException

也可以看看:

Hooray!