How to implement Equalizer in android

旧巷老猫 提交于 2019-12-06 06:23:13

问题


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.

来源:https://stackoverflow.com/questions/27619652/how-to-implement-equalizer-in-android

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!