How to create equalizer for android

2019-01-22 20:58发布

问题:

I want to create simple equalizer for android. How can I do it?

Try to find some methods in MediaPlayer class. But all my attempts failed.

回答1:

Simple answer... you can't do it with the framework or with Java (because there is no JMF support in Android). You have to use the NDK and JNI to compile a native library with equalizer support. If you know C/C++ there are plenty of libraries around that will provide this functionality but if you don't know C/C++ or have the means to pay someone that does I would recommend you move on to something else within your means... There are even some working examples for Android, if you look around, that use libmpg123... but libmpg123 only provides an equalizer interface for mp3's. I found that it's pretty buggy in general and compromised the stability of the app in such a way that it would lock up android and I would have to pull the battery to reboot the phone. In addition, there was alot of audio clipping even with the equalizer flatlined. That is my experience...



回答2:

Android has built-in qualizer engine, though it isn't located in MediaPlayer class, becouse it's a class itself located in android.media.audioFx package.

http://developer.android.com/reference/android/media/audiofx/Equalizer.html



回答3:

You can create a equalizer like

Equalizer equalizer = new Equalizer(0,mediaplayer.getAudioSessionId());

equalizer.setEnabled(true);

equalizer.getNumberOfBands(); //it tells you the number of equalizer in device.

equalizer.getNumberOfPresets();//like Normal Classic,Dance Flat,Folk Heavy Metal,Hip Hop,Jazz, Pop, Rock

http://developer.android.com/reference/android/media/audiofx/Equalizer.html

Have a look at full example



回答4:

I hope that below link is useful for you.

https://developer.android.com/resources/samples/ApiDemos/src/com/example/android/apis/media/AudioFxDemo.html