public class Equalizer extends AudioEffect
An application creates an Equalizer object to instantiate and control an Equalizer engine in the audio framework. The application can either simply use predefined presets or have a more precise control of the gain in each frequency band controlled by the equalizer.
The methods, parameter types and units exposed by the Equalizer implementation are directly mapping those defined by the OpenSL ES 1.0.1 Specification (http://www.khronos.org/opensles/) for the SLEqualizerItf interface. Please refer to this specification for more details.
To attach the Equalizer to a particular AudioTrack or MediaPlayer, specify the audio session ID of this AudioTrack or MediaPlayer when constructing the Equalizer.
NOTE: attaching an Equalizer to the global audio output mix by use of session 0 is deprecated.
See MediaPlayer.getAudioSessionId()
for details on audio sessions.
See AudioEffect
class for more details on controlling audio
effects.
Modifier and Type | Class and Description |
---|---|
static interface |
Equalizer.OnParameterChangeListener
The OnParameterChangeListener interface defines a method called by the Equalizer when a
parameter value has changed.
|
static class |
Equalizer.Settings
The Settings class regroups all equalizer parameters.
|
AudioEffect.Descriptor, AudioEffect.OnControlStatusChangeListener, AudioEffect.OnEnableStatusChangeListener
Modifier and Type | Field and Description |
---|---|
static int |
PARAM_BAND_FREQ_RANGE
Band frequency range.
|
static int |
PARAM_BAND_LEVEL
Band level.
|
static int |
PARAM_CENTER_FREQ
Band center frequency.
|
static int |
PARAM_CURRENT_PRESET
Current preset.
|
static int |
PARAM_GET_BAND
Band for a given frequency.
|
static int |
PARAM_GET_NUM_OF_PRESETS
Request number of presets.
|
static int |
PARAM_GET_PRESET_NAME
Request preset name.
|
static int |
PARAM_LEVEL_RANGE
Band level range.
|
static int |
PARAM_NUM_BANDS
Number of bands.
|
static int |
PARAM_STRING_SIZE_MAX
Maximum size for preset name
|
ACTION_CLOSE_AUDIO_EFFECT_CONTROL_SESSION, ACTION_DISPLAY_AUDIO_EFFECT_CONTROL_PANEL, ACTION_OPEN_AUDIO_EFFECT_CONTROL_SESSION, ALREADY_EXISTS, CONTENT_TYPE_GAME, CONTENT_TYPE_MOVIE, CONTENT_TYPE_MUSIC, CONTENT_TYPE_VOICE, EFFECT_AUXILIARY, EFFECT_INSERT, EFFECT_PRE_PROCESSING, EFFECT_TYPE_AEC, EFFECT_TYPE_AGC, EFFECT_TYPE_BASS_BOOST, EFFECT_TYPE_ENV_REVERB, EFFECT_TYPE_EQUALIZER, EFFECT_TYPE_LOUDNESS_ENHANCER, EFFECT_TYPE_NS, EFFECT_TYPE_NULL, EFFECT_TYPE_PRESET_REVERB, EFFECT_TYPE_VIRTUALIZER, ERROR, ERROR_BAD_VALUE, ERROR_DEAD_OBJECT, ERROR_INVALID_OPERATION, ERROR_NO_INIT, ERROR_NO_MEMORY, EXTRA_AUDIO_SESSION, EXTRA_CONTENT_TYPE, EXTRA_PACKAGE_NAME, mListenerLock, mNativeEventHandler, NATIVE_EVENT_CONTROL_STATUS, NATIVE_EVENT_ENABLED_STATUS, NATIVE_EVENT_PARAMETER_CHANGED, STATE_INITIALIZED, STATE_UNINITIALIZED, SUCCESS
Constructor and Description |
---|
Equalizer(int priority,
int audioSession)
Class constructor.
|
Modifier and Type | Method and Description |
---|---|
short |
getBand(int frequency)
Gets the band that has the most effect on the given frequency.
|
int[] |
getBandFreqRange(short band)
Gets the frequency range of the given frequency band.
|
short |
getBandLevel(short band)
Gets the gain set for the given equalizer band.
|
short[] |
getBandLevelRange()
Gets the level range for use by
setBandLevel(short,short) . |
int |
getCenterFreq(short band)
Gets the center frequency of the given band.
|
short |
getCurrentPreset()
Gets current preset.
|
short |
getNumberOfBands()
Gets the number of frequency bands supported by the Equalizer engine.
|
short |
getNumberOfPresets()
Gets the total number of presets the equalizer supports.
|
String |
getPresetName(short preset)
Gets the preset name based on the index.
|
Equalizer.Settings |
getProperties()
Gets the equalizer properties.
|
void |
setBandLevel(short band,
short level)
Sets the given equalizer band to the given gain value.
|
void |
setParameterListener(Equalizer.OnParameterChangeListener listener)
Registers an OnParameterChangeListener interface.
|
void |
setProperties(Equalizer.Settings settings)
Sets the equalizer properties.
|
void |
usePreset(short preset)
Sets the equalizer according to the given preset.
|
byteArrayToInt, byteArrayToInt, byteArrayToShort, byteArrayToShort, checkState, checkStatus, command, concatArrays, finalize, getDescriptor, getEnabled, getId, getParameter, getParameter, getParameter, getParameter, getParameter, getParameter, getParameter, hasControl, intToByteArray, isEffectTypeAvailable, isError, queryEffects, queryPreProcessings, release, setControlStatusListener, setEnabled, setEnableStatusListener, setParameter, setParameter, setParameter, setParameter, setParameter, setParameter, setParameter, setParameterListener, shortToByteArray
public static final int PARAM_NUM_BANDS
public static final int PARAM_LEVEL_RANGE
public static final int PARAM_BAND_LEVEL
public static final int PARAM_CENTER_FREQ
public static final int PARAM_BAND_FREQ_RANGE
Equalizer.OnParameterChangeListener
public static final int PARAM_GET_BAND
public static final int PARAM_CURRENT_PRESET
public static final int PARAM_GET_NUM_OF_PRESETS
public static final int PARAM_GET_PRESET_NAME
public static final int PARAM_STRING_SIZE_MAX
public Equalizer(int priority, int audioSession) throws IllegalStateException, IllegalArgumentException, UnsupportedOperationException, RuntimeException
priority
- 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
- system wide unique audio session identifier. The Equalizer will be
attached to the MediaPlayer or AudioTrack in the same audio session.IllegalStateException
IllegalArgumentException
UnsupportedOperationException
RuntimeException
public short getNumberOfBands() throws IllegalStateException, IllegalArgumentException, UnsupportedOperationException
IllegalStateException
IllegalArgumentException
UnsupportedOperationException
public short[] getBandLevelRange() throws IllegalStateException, IllegalArgumentException, UnsupportedOperationException
setBandLevel(short,short)
. The level is expressed in
milliBel.IllegalStateException
IllegalArgumentException
UnsupportedOperationException
public void setBandLevel(short band, short level) throws IllegalStateException, IllegalArgumentException, UnsupportedOperationException
band
- frequency band that will have the new gain. The numbering of the bands starts
from 0 and ends at (number of bands - 1).level
- new gain in millibels that will be set to the given band. getBandLevelRange()
will define the maximum and minimum values.IllegalStateException
IllegalArgumentException
UnsupportedOperationException
getNumberOfBands()
public short getBandLevel(short band) throws IllegalStateException, IllegalArgumentException, UnsupportedOperationException
band
- frequency band whose gain is requested. The numbering of the bands starts
from 0 and ends at (number of bands - 1).IllegalStateException
IllegalArgumentException
UnsupportedOperationException
public int getCenterFreq(short band) throws IllegalStateException, IllegalArgumentException, UnsupportedOperationException
band
- frequency band whose center frequency is requested. The numbering of the bands
starts from 0 and ends at (number of bands - 1).IllegalStateException
IllegalArgumentException
UnsupportedOperationException
public int[] getBandFreqRange(short band) throws IllegalStateException, IllegalArgumentException, UnsupportedOperationException
band
- frequency band whose frequency range is requested. The numbering of the bands
starts from 0 and ends at (number of bands - 1).IllegalStateException
IllegalArgumentException
UnsupportedOperationException
public short getBand(int frequency) throws IllegalStateException, IllegalArgumentException, UnsupportedOperationException
frequency
- frequency in milliHertz which is to be equalized via the returned band.IllegalStateException
IllegalArgumentException
UnsupportedOperationException
public short getCurrentPreset() throws IllegalStateException, IllegalArgumentException, UnsupportedOperationException
IllegalStateException
IllegalArgumentException
UnsupportedOperationException
public void usePreset(short preset) throws IllegalStateException, IllegalArgumentException, UnsupportedOperationException
preset
- new preset that will be taken into use. The valid range is [0,
number of presets-1].IllegalStateException
IllegalArgumentException
UnsupportedOperationException
getNumberOfPresets()
public short getNumberOfPresets() throws IllegalStateException, IllegalArgumentException, UnsupportedOperationException
IllegalStateException
IllegalArgumentException
UnsupportedOperationException
public String getPresetName(short preset)
preset
- index of the preset. The valid range is [0, number of presets-1].IllegalStateException
IllegalArgumentException
UnsupportedOperationException
public void setParameterListener(Equalizer.OnParameterChangeListener listener)
listener
- OnParameterChangeListener interface registeredpublic Equalizer.Settings getProperties() throws IllegalStateException, IllegalArgumentException, UnsupportedOperationException
IllegalStateException
IllegalArgumentException
UnsupportedOperationException
public void setProperties(Equalizer.Settings settings) throws IllegalStateException, IllegalArgumentException, UnsupportedOperationException
settings
- an Equalizer.Settings object containing the properties to applyIllegalStateException
IllegalArgumentException
UnsupportedOperationException