Author Topic: code for a logarithmic pot  (Read 121 times)

Boner

code for a logarithmic pot
« on: March 05, 2023, 07:40:18 PM »
Hello folks, I'm having the hardest time trying to get a pot to have a logarithmic taper in spinASM. I'm trying to go by spins explanation of how to do the log on their site and Im struggling to understand.

From my understanding LOG expects an input ranging from close to zero and 1 and gives a result ranging from -1 to +0.9999 with a logarithmic curve. So I figured this should work but it does not.

LDAX POT1
LOG  0.5, 0.5



Please note I'm not asking about an exp response where you can simply square the pot value, I need the logarithm.

Thanks all


octfrank

Re: code for a logarithmic pot
« Reply #1 on: March 06, 2023, 09:23:18 AM »
You need to take into consideration that you are taking the LOG of a value <1.0 so the result of LOG will be negative. So depending on how you plan to use the result you make need to invert the LOG result. I suggest you use a spreadsheet like Excel to plot POT value (0 to 0.9999) versus log2 values to see how they map.
Frank Thomson
Experimental Noize

swamphorn

Re: code for a logarithmic pot
« Reply #2 on: March 06, 2023, 02:45:29 PM »
Hi Boner,

The FV-1's LOG instruction implements the function

LOG(x) = K/16 log2(x) + C

with K in [-2, 2) and C in [-1, 1). When K = 1 and C = 0, LOG maps [0, 1) → [-1, 0], and the largest value it can output is 0. More generally it maps [0, 1) → [-K+C, C], and you can trivially solve for K and C to get your desired output interval. To your end, mapping the interval [0, 1) back to itself is achieved by setting K to 1 and C to the largest positive offset 0.999 ≈ 1.