Fields Summary |
---|
private static final String | TAG |
public static final int | PARAM_NUM_BANDSNumber of bands. Parameter ID for OnParameterChangeListener |
public static final int | PARAM_LEVEL_RANGEBand level range. Parameter ID for OnParameterChangeListener |
public static final int | PARAM_BAND_LEVELBand level. Parameter ID for OnParameterChangeListener |
public static final int | PARAM_CENTER_FREQBand center frequency. Parameter ID for OnParameterChangeListener |
public static final int | PARAM_BAND_FREQ_RANGEBand frequency range. Parameter ID for
{@link android.media.audiofx.Equalizer.OnParameterChangeListener} |
public static final int | PARAM_GET_BANDBand for a given frequency. Parameter ID for OnParameterChangeListener |
public static final int | PARAM_CURRENT_PRESETCurrent preset. Parameter ID for OnParameterChangeListener |
public static final int | PARAM_GET_NUM_OF_PRESETSRequest number of presets. Parameter ID for OnParameterChangeListener |
public static final int | PARAM_GET_PRESET_NAMERequest preset name. Parameter ID for OnParameterChangeListener |
private static final int | PARAM_PROPERTIES |
public static final int | PARAM_STRING_SIZE_MAXMaximum size for preset name |
private short | mNumBandsNumber of bands implemented by Equalizer engine |
private int | mNumPresetsNumber of presets implemented by Equalizer engine |
private String[] | mPresetNamesNames of presets implemented by Equalizer engine |
private OnParameterChangeListener | mParamListenerRegistered listener for parameter changes. |
private BaseParameterListener | mBaseParamListenerListener used internally to to receive raw parameter change event from AudioEffect super class |
private final Object | mParamListenerLockLock for access to mParamListener |
Methods Summary |
---|
public short | getBand(int frequency)Gets the band that has the most effect on the given frequency.
int[] param = new int[2];
short[] result = new short[1];
param[0] = PARAM_GET_BAND;
param[1] = frequency;
checkStatus(getParameter(param, result));
return result[0];
|
public int[] | getBandFreqRange(short band)Gets the frequency range of the given frequency band.
int[] param = new int[2];
int[] result = new int[2];
param[0] = PARAM_BAND_FREQ_RANGE;
param[1] = (int)band;
checkStatus(getParameter(param, result));
return result;
|
public short | getBandLevel(short band)Gets the gain set for the given equalizer band.
int[] param = new int[2];
short[] result = new short[1];
param[0] = PARAM_BAND_LEVEL;
param[1] = (int)band;
checkStatus(getParameter(param, result));
return result[0];
|
public short[] | getBandLevelRange()Gets the level range for use by {@link #setBandLevel(short,short)}. The level is expressed in
milliBel.
short[] result = new short[2];
checkStatus(getParameter(PARAM_LEVEL_RANGE, result));
return result;
|
public int | getCenterFreq(short band)Gets the center frequency of the given band.
int[] param = new int[2];
int[] result = new int[1];
param[0] = PARAM_CENTER_FREQ;
param[1] = (int)band;
checkStatus(getParameter(param, result));
return result[0];
|
public short | getCurrentPreset()Gets current preset.
short[] result = new short[1];
checkStatus(getParameter(PARAM_CURRENT_PRESET, result));
return result[0];
|
public short | getNumberOfBands()Gets the number of frequency bands supported by the Equalizer engine.
if (mNumBands != 0) {
return mNumBands;
}
int[] param = new int[1];
param[0] = PARAM_NUM_BANDS;
short[] result = new short[1];
checkStatus(getParameter(param, result));
mNumBands = result[0];
return mNumBands;
|
public short | getNumberOfPresets()Gets the total number of presets the equalizer supports. The presets will have indices
[0, number of presets-1].
short[] result = new short[1];
checkStatus(getParameter(PARAM_GET_NUM_OF_PRESETS, result));
return result[0];
|
public java.lang.String | getPresetName(short preset)Gets the preset name based on the index.
if (preset >= 0 && preset < mNumPresets) {
return mPresetNames[preset];
} else {
return "";
}
|
public android.media.audiofx.Equalizer$Settings | getProperties()Gets the equalizer properties. This method is useful when a snapshot of current
equalizer settings must be saved by the application.
byte[] param = new byte[4 + mNumBands * 2];
checkStatus(getParameter(PARAM_PROPERTIES, param));
Settings settings = new Settings();
settings.curPreset = byteArrayToShort(param, 0);
settings.numBands = byteArrayToShort(param, 2);
settings.bandLevels = new short[mNumBands];
for (int i = 0; i < mNumBands; i++) {
settings.bandLevels[i] = byteArrayToShort(param, 4 + 2*i);
}
return settings;
|
public void | setBandLevel(short band, short level)Sets the given equalizer band to the given gain value.
int[] param = new int[2];
short[] value = new short[1];
param[0] = PARAM_BAND_LEVEL;
param[1] = (int)band;
value[0] = level;
checkStatus(setParameter(param, value));
|
public void | setParameterListener(android.media.audiofx.Equalizer$OnParameterChangeListener listener)Registers an OnParameterChangeListener interface.
synchronized (mParamListenerLock) {
if (mParamListener == null) {
mParamListener = listener;
mBaseParamListener = new BaseParameterListener();
super.setParameterListener(mBaseParamListener);
}
}
|
public void | setProperties(android.media.audiofx.Equalizer$Settings settings)Sets the equalizer properties. This method is useful when equalizer settings have to
be applied from a previous backup.
if (settings.numBands != settings.bandLevels.length ||
settings.numBands != mNumBands) {
throw new IllegalArgumentException("settings invalid band count: " +settings.numBands);
}
byte[] param = concatArrays(shortToByteArray(settings.curPreset),
shortToByteArray(mNumBands));
for (int i = 0; i < mNumBands; i++) {
param = concatArrays(param,
shortToByteArray(settings.bandLevels[i]));
}
checkStatus(setParameter(PARAM_PROPERTIES, param));
|
public void | usePreset(short preset)Sets the equalizer according to the given preset.
checkStatus(setParameter(PARAM_CURRENT_PRESET, preset));
|