javaandroidmedia-playeraudio-playerequalizerandroid-music-player

How to make 10 band equalizer on Android player if default is 5 band?


I am trying to make an android player and a problem occurred while making the equalizer. There is limit of equalizer bands, for example Nexus 5 has 5 band equalizer by default. Several players (such as Poweramp) somehow managed to get 10 band equalizer even on phones that have 5, 6 or 13 bands for example by default.

I am using Equalizer class to attach it to MediaPlayer and generally I understand how that works, but how to make 10 bands on phone that has by default only 5 bands?

So my question is how is this possible and how do some players manage to get 10 band equalizer on all phones, regardless of their system/hardware limit?


Solution

  • Like you said frequency depends on hardware on a device. I tested with my Nexus 5 and it has 5 bands with these values:

    You can get number of bands and presets with this code:

    short numberOfBands = equalizer.getNumberOfBands();
    short numberOfPresets = equalizer.getNumberOfPresets();
    

    Frequency range of band you can get with this code:

    final short minLevel = equalizer.getBandLevelRange()[0]; // get min range
    final short maxLevel = equalizer.getBandLevelRange()[1]; // get max range
    

    To show bends you do that like this:

    for(short i = 0; i < numberOfBands; i++){
         SeekBar seekBar = ...
         mTextViewMin.setText(minLevel + "");
         mTextViewMax.setText(maxLevel + "");   
    }
    

    To initialize Equalizer:

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

    Read more about equalizer here: Equalizer Android Developer