I like to take a sine wave, and SOF it into the 0 to 1.0 range to use as a tremolo LFO (or any other LFO application). I also like to square or cube or beyond this sine wave so that it is "warped" but still smooth. What I'd like to do is have a knob that controls the level of warp from, say, 1 to 5. 1 would be the original signal, and 5 would be the signal to the 5th power.
Now of course I could do pot skipping and have each step be a different power step (via cascaded MULX instructions), but I want it to be smooth across pot rotation rather than jump between steps.
In regular math, I can do powers by taking the log, multiplying, and then taking the exponent of the result.
Super trivial example:
starting value is 100. I want to square this.
log10(100) = 2.
2 x 2 = 4.
10^4 = 10,000.
Suppose I want to do the "1.5" power:
log10(100) = 2.
2 x 1.5 = 3
10^3 = 1,000.
Anyone who wants to chime in with the answer is welcome to do so.
The goal:
Take an input control signal between 0.0 and 1.0.
Take a pot control signal and use this to continuously control "variable power" of the control signal from 1 to 5.
TIA,
DL
Knob variable power function?
Moderator: frank
-
- Posts: 338
- Joined: Mon Nov 12, 2012 1:12 pm
- Contact:
The quick and maybe-not-so-dirty solution would be to crossmix between the "pure sine wave" and the "sine wave to the highest power you want available". I did a simulation in GeoGebra. You wont get the exact curve of the powers inbetween, but I doubt you'll notice much difference unless you set a very excessive "largest power".
Code: Select all
ldax maxpower
rdax puresine, -1
mulx POT0
rdax puresine, 1
wrax variablepower, 0
-
- Posts: 338
- Joined: Mon Nov 12, 2012 1:12 pm
- Contact:
Re: Knob variable power function?
Raise to power between 1 and 5
Code: Select all
;ACC contains something between 0 and 1
LOG 1,0
WRAX temp,1
SOF -2,0
SOF -2,0
MULX POT0
RDAX temp,1
EXP 1,0
-
- Posts: 338
- Joined: Mon Nov 12, 2012 1:12 pm
- Contact:
Re: Knob variable power function?
y = exp((1 + (pot0 * 4)) * log(x)) seems straightforward.DrAlx wrote: ↑Tue Apr 02, 2019 11:38 pm Raise to power between 1 and 5
Code: Select all
;ACC contains something between 0 and 1 LOG 1,0 WRAX temp,1 SOF -2,0 SOF -2,0 MULX POT0 RDAX temp,1 EXP 1,0
If pot0 = 0 then y = exp(log(x)) = x
If pot0 =1 then y = exp(log(5 * x)) = x^5
My mind always broke on the log instruction, not sure why. If I sat down and really penciled in the result at different input values I could get it. You are the log-meister! Thanks.