Search code examples
mathfrequencylogarithmequalizerparametric-equations

How to draw frequency separation in a parametric equalizer


I'm trying to do something similar to this parametric equalizer, in regards to the frequency axis only, i.e. the values along the middle line: Parametric eq

This appears to be the standard format for equalizers but I can't work out the formula to do this.

i.e. The values for the first set of frequency lines are 10, 20, 30, 40, 50, 60, 70, 80, 90, 100 but the spacing reduces as you go up to 100 From there, it goes 100, 200, 300, 400, 500.. to 1000 and the spacing resets at 100 then reduces at each interval up to 1000 The same pattern repeats to the max, which in this case is 20,000

How is this done? Is it logarithmic?


Solution

  • With the help of this video I was able to work out a formula to plot the frequency axis as a logarithmic scale.

            int factor = 10;
            for(int i = 10; i <= FREQ_MAX; i+=factor)
            {
                fx = (float) ((float) (Math.log10(i) - Math.log10(PEQ.FREQ_MIN))/(Math.log10(PEQ.FREQ_MAX)-Math.log10(PEQ.FREQ_MIN)) * getMaxCanvasWidth());
                canvas.drawLine(fx, 0, fx, getHeight(), paintLinesThick);
    
                if(isDisplayedFreq(i))
                {
                    paintText.setTextAlign(Paint.Align.LEFT);
                    canvas.drawText(getFreqAsFormattedLabel(i), fx + (getMaxCanvasWidth() / 120f), (getHeight() / 2f) + (getHeight() / 50f), paintText);
                }
    
                if(i >= (factor*10))
                {
                    factor *= 10;
                }
            }