3

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;
                }
            }
        }

    }

Desired equilizer

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.

Xar-e-ahmer Khan
  • 1,314
  • 15
  • 23
  • 5
    I see 5 bands (60Hz to 14KHz), ranging from -15db to +15db. If you don't know what does it mean, you better change project. `I have to implement an Equalizer` **1** It seems you are **copying** an existing source. **2** You should understand what an Equalizer is and how does it work in the real life, before trying to emulate it in software. – Phantômaxx Dec 23 '14 at 11:47
  • yes @DerGolem I want to understand what an Equalizer does in real life . then i will be able to implement it,Your second part is my question – Xar-e-ahmer Khan Dec 23 '14 at 11:57
  • 4
    So, the correct method is: **First** read something (Wikipedia?) about equalizers. **Then** start making yours, when you have clear ideas about what your app is going to be. Otherwise, you're driving blind and counterhand on a highway. – Phantômaxx Dec 23 '14 at 12:00

0 Answers0