1. IMPORTANT:
    We launched a new online community and this space is now closed. This community will be available as a read-only resources until further notice.
    JOIN US HERE

exp-lin-log function?

Discussion in 'Building With Reaktor' started by sellotape, Jun 14, 2008.

Thread Status:
Not open for further replies.
  1. sellotape

    sellotape NI Product Owner

    Messages:
    345
    i've a linear function (0 ... 1) delivered by the ramp osc and now it should smoothly bend with one knob. at the left position of the knob it should be exponential, in the middle linear and at the right logarithmic.
    is someone able to help me with this please?
     

    Attached Files:

  2. Jeff Brown

    Jeff Brown Forum Member

    Messages:
    377
    Would pointwise linear interpolation be too crude? I mean, suppose you've got two functions log(x) and exp(x), where the domain of x is [0,1]. Call the morphing parameter m, with a domain of [0,1]. Your output value could simply be

    Out = M * exp(x) + (1-M) log(x)

    Thus when M = 1, you get the exponential function, and when M = 0, you get the logarithmic one.

    The space of functions "between" exponential and logarithmic is immense, and hence the number of paths to morph between them is as well -- but this is probably the easiest path.

    Oh, wait. You wanted the curve to be linear when M = 0.5. For that to happen with the above technique, you would have to chose the right exponential and logarithmic functions. They'll have to be inverses of eachother, as will their ranges. I can't figure out an elegant way to explain that.

    But another idea would be to use 2-part linear interpolation. Suppose M now ranges in [-1,1]. At -1 you'll get log, at 0 linear, and at 1 exponential. Then you can use
    for M < 0, Out = -M exp(x) + (1+M) x
    for M >= 0, Out = M log(x) + (1-M) x
     
  3. Jeff Brown

    Jeff Brown Forum Member

    Messages:
    377
    One potential disadvantage of the 2-part interpolation that I described above is that while it's continuous, it's not differentiable when you cross linearity. I can't imagine needing a differentiable control for anything I'm doing, but I don't know how you're planning to use the module.
     
  4. herw

    herw NI Product Owner

    Messages:
    6,421
    ? ?
     

    Attached Files:

  5. sellotape

    sellotape NI Product Owner

    Messages:
    345
    so it's not working? anyhow i'm no student and i don't know how to implement exp(x) or log(x) in reaktor. i just understand it with the logic of reaktor but not with mathematical terms.
    i've found exactly what i was looking for in the oki-computer. the three shapes are in a table with y interpolation. it'll bend the waves from a table in a pwm like way. i want to use this in real time so i need to load the 3 shapes in a audio table. but in this case i've a ramp that reads the "shape" table which delivers the read position for the "wave" table. that isn't a very cpu saving solution so i'm still interested in a more econmic one.
     
  6. Jeff Brown

    Jeff Brown Forum Member

    Messages:
    377
    > i don't know how to implement exp(x) or log(x) in reaktor.

    There are built-in mathematical functions for amplitude-style exponentiation and logarithms, and for pitch-style exponentiation and logarithms. You can build any exponential or logarithm function you want out of those.

    I can't interpret your attached graph. What are the axes? What are the formulas?
     
  7. m3m

    m3m NI Product Owner

    Messages:
    536
    Is there any chance you could approximate this by having a knob which went from say 0.33333 to 3, then set your function to [Input] ^ [Knob value]?

    I just graphed 40 input values between 0 and 1 raised to the power 1/3, 1, and 3, and while the results aren't actually log or exp, they look quite like your diagrams.

    "Near enough for rock 'n' roll" maybe? ;)
     

    Attached Files:

  8. Jeff Brown

    Jeff Brown Forum Member

    Messages:
    377
    That's elegant. Much better than what I was talking about.
     
  9. lxint

    lxint NI Product Owner

    Messages:
    764

    macros for such curves can be found in this ensemble :

    http://www.native-instruments.com/index.php?id=userlibrary&type=0&ulbr=1&plview=detail&patchid=7065

    theres also an option to flip the curve left right (1- exp) and inputs to shift and scale the output
    and a table to graph the curve, maybe it's useful for your case too
     
  10. sellotape

    sellotape NI Product Owner

    Messages:
    345
    wow a very impressive ensemble with good looking eq! but it seems that "real" exp or log shapes arn't working for me. i tried it with the power function but the ratio between exp and log is asymmetrical. if you use a square osc and set the pw to 0.5 you'll get a ration between up and down (-1..1) of 25%-75% and with a pw of -0.5 it's 75%-25%. with the power function i get something like pw=0.5=40%.60% and pw=0.5=70%-30%.
    i hope it's comprehensibly.
    anyway the shapes in oki are looking like a quarter of cycle and that brings a more pwm like sound.
    is it possible to let a control shaper module work like a soft knee (round the angular control shape)?
    thanks for all your help!
     
  11. lhaymehr

    lhaymehr Forum Member

    Messages:
    129
    Try this attachment. HTH.
     

    Attached Files:

  12. sellotape

    sellotape NI Product Owner

    Messages:
    345
    ok it uses a bit more cpu than using a audiotable with the shapes in it but it works.
     

    Attached Files:

Thread Status:
Not open for further replies.