How to implement Equalizer in android

2019-05-10 12:11发布

问题:

I have to implement an Equalizer in android and i also find source code here

But i have no idea about NumberOfBands and BandLevelRange(What are they?) and how can i handle them.

the given code i have shown you is from the source code i mentioned.

eq = new Equalizer(0, 0);

        if (eq != null)
        {
            eq.setEnabled(true);

            int num_bands = eq.getNumberOfBands();

            num_sliders = num_bands;

            short r[] = eq.getBandLevelRange();

            min_level = r[0];

            max_level = r[1];

            for (int i = 0; i < num_sliders && i < MAX_SLIDERS; i++) 
            {
                int[] freq_range = eq.getBandFreqRange((short) i);

                sliders[i].setOnSeekBarChangeListener(this);

                slider_labels[i].setText(formatBandLabel(freq_range));
            }

        }

        for (int i = num_sliders; i < MAX_SLIDERS; i++) 
        {
            sliders[i].setVisibility(View.GONE);

            slider_labels[i].setVisibility(View.GONE);
        }

        bb = new BassBoost(0, 0);

        if (bb != null) 
        {
        }
        else 
        {
            bass_boost.setVisibility(View.GONE);

            bass_boost_label.setVisibility(View.GONE);
        }

        updateUI();

And in onProgresschanged it does

@Override
    public void onProgressChanged(SeekBar seekBar, int level, boolean fromTouch) {

        if (seekBar == bass_boost) {
            bb.setEnabled(level > 0 ? true : false);

            bb.setStrength((short) level); // Already in the right range 0-1000
        } else if (eq != null) {
            int new_level = min_level + (max_level - min_level) * level / 100;

            for (int i = 0; i < num_sliders; i++) {
                if (sliders[i] == seekBar) {
                    eq.setBandLevel((short) i, (short) new_level);

                    break;
                }
            }
        }

    }

I have to create it similar to the above image but don't what is 60, 3k, 14k, and what -15db to +15db means.

Edit

I understand what it does,it changes frequency of each band, but what happen when we increase or decrease frequency. At which stage i get the maximum sound output and what stage i get the minimum sound output.