question about audio frequency log scale (maths)

Production | Sep 27, 2011

  1. parsley

    parsley

    parsley

    10,825 posts
    Since Apr 25, 2004
    Likes Received:
    5,418
    So I'm writing a little program to generate a pitch sweepable sine wave.
    It's easy enough to make it linear.
    I have a seekbar with values from 20hz to 20khz, but I want to make it a log scale and I'm completely lost.


    What's the equation to find the next interval (up or down) from a given frequency.

    Or maybe, a better question, is how do convert and arbitrary linear scale to a log scale relevant to frequency?

    My brain is now boogaloo
  2. DrTiTus Finger rollin rhythm

    DrTiTus

    DrTiTus Finger rollin rhythm

    577 posts
    Since May 16, 2005
    Likes Received:
    6
    Location:
    Wellington, NZ
    The logarithm represents the exponent that 10 is raised to. That is, 100 = 10 to the power of 2, therefore log 100 = 2.

    Similarly, 1000 = 10^3 so log 1000 = 3.

    You would have an exponential function f(x) := 2*10^x
    If you take values of x from 1 to 4 you'd get the familiar 20-20kHz sweep.
    f(1) = 2*10^1 = 20 Hz
    f(2) = 2*10^2 = 200 Hz
    f(3) = 2*10^3 = 2 kHz
    f(4) = 2*10^4 = 20 kHz

    Rather than sweeping from 20 to 20 000 by a step of 1, you would sweep from 1 to 4 with a step of 0.01 (or whatever values are appropriate for the rate of change).

    I hope that's of some use!
  3. parsley

    parsley

    parsley

    10,825 posts
    Since Apr 25, 2004
    Likes Received:
    5,418
    thats what i needed. :twothumbs: that really helps it was very hard to find this information distilled like that. you are an absolute gent.
Production