You need to call the method setBandLevel :
public void setBandLevel(short band, short level)
On your instance of the Equalizer
object.
Since different Android devices have different number of frequency bands with different properties (gain, bandwidth, center frequency...) available to them, you will also need to know the maximum number of bands and gain range (at least) available to you.
// New instance of equalizer (add it as a member of your class rather than a scoped instance like this)
Equalizer mEqualizer = new Equalizer(0, mMediaPlayer.getAudioSessionId());
// Get the number of bands available on your device
short bands = mEqualizer.getNumberOfBands();
// Get the gain level available for the bands
final short minEQLevel = mEqualizer.getBandLevelRange()[0];
final short maxEQLevel = mEqualizer.getBandLevelRange()[1];
You can then call your setBandLevel
method by dividing your EQ levels into a percentage.
For more information consult the Equalizer general documentation - there's more methods for getting specific information such as center frequency and frequency band width of the parametric EQ.
Here is a full example of someone using an equalizer and visualizer in an Android project.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…