Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
menu search
person
Welcome To Ask or Share your Answers For Others

Categories

I don't see anything allow me to specific control each audio band's volume in audiofx.Equalizer library. Is it impossible? Any advice and suggestions will be greatly appreciated. Thank you.

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
146 views
Welcome To Ask or Share your Answers For Others

1 Answer

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.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
...