androidaudioequalizer

How to change the frequency of an equalizer?


It is possible to change the frequency of the bands of an equalizer, or is only possible to use 60Hz 230 Hz 910 Hz 3600 Hz 14000 Hz?


Solution

  • I suppose you're talking about android.media.audiofx.Equalizer.

    Different Android devices have different number of frequency bands, and you can set it freely between the supported ones, as the docs says:

    setBandLevel(short band, short level)

    Sets the given equalizer band to the given gain value.

    Parameters

    band - short: frequency band that will have the new gain. The numbering of the bands starts from 0 and ends at (number of bands - 1).

    level - short: new gain in millibels that will be set to the given band. getBandLevelRange() will define the maximum and minimum values.

    This answer from WoodyDev gives us some example code to get range supported for the device:

    // 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 find more opinions and help here: Number of bands in Android Equalizer