Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
154 views
in Technique[技术] by (71.8m points)

android - How to change each audio band's volume using Equalizer?

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

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

1 Reply

0 votes
by (71.8m points)

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.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...