Tap Tempo tremolo again

Algorithm development and general DSP issues

Moderator: frank

Post Reply
Digital Larry
Posts: 338
Joined: Mon Nov 12, 2012 1:12 pm
Contact:

Tap Tempo tremolo again

Post by Digital Larry »

I referenced this older thread:

http://www.spinsemi.com/forum/viewtopic ... =tap+tempo

I have some tap tempo code that can measure up to 1 second. The resulting value is 32767 *256 or "really close to 1.0". This maps to LFO freq or 1.0 Hz, or Kf = 26, and at the low end I'm going down to 1/20th of a second (which is probably faster than you can tap) at which point the LFO is at 20 Hz, where Kf = 502.

Now one approach is to interpolate linearly between these endpoints, but this does not really give the desired result at anywhere other than the endpoints. The real equation I am trying to implement is Kf = (8 * pi)/x, where x is the delay time in seconds, or essentially the number of samples counted between taps at 32768 Hz.

I've read the 1/X section at the knowledge base more than a few times and it is breaking my brain as I have not used the log/exp functions much and they are a little tough to understand.

http://spinsemi.com/knowledge_base/pgm_ ... n_limiters

The input X will go from 0.05 to 1.0.

The output should go from 502 to 26 over this same range, of course that is scaled to the number representation used by the LFO.

Anyone want to help an old geezer out? Thanks! DL
frank
Posts: 1244
Joined: Wed Oct 19, 2005 12:26 pm
Contact:

Post by frank »

So if the input X goes 0.05 to 1.0 and needs to give an output of 502 to 26 and it is linear then the equation:

527.05263 - X*501.05263

Should give a result between 502 and 26 for an input range of 0.05 to 1.0 for X
Frank Thomson
Experimental Noize
Digital Larry
Posts: 338
Joined: Mon Nov 12, 2012 1:12 pm
Contact:

Post by Digital Larry »

Hi Frank,

I don't want linear interpolation. I want the function (8 * pi)/x so that the tap interval maps as closely as possible to the LFO period.

I'll continue to attempt to muddle through with the LOG/EXP examples.

Thx,

DL
frank
Posts: 1244
Joined: Wed Oct 19, 2005 12:26 pm
Contact:

Post by frank »

Then I would try solving for 1/Kf instead so solve r=x/(8*pi) then do the 1/r to get the result. Since 1/8*pi is a constant it becomes a multiply
Frank Thomson
Experimental Noize
Aaron
Posts: 54
Joined: Wed Mar 04, 2015 8:10 pm
Location: Oklahoma

Post by Aaron »

Log rules dictate that:

log(a/b) = log(a)-log(b)
and
log(a*b) = log(a)+log(b)


so for (8*pi)/x we can re-write this as:

exp ( log( 8 )+log( pi )-log( x ) )


in spin terms this would look like:

ldax x
;load x in acc

log -1,0.29
; ( logbase2(x) / 16 ) * -1 + ( logbase2(8*pi) / 16 )

exp 1,0
; 2^(acc*16)
Digital Larry
Posts: 338
Joined: Mon Nov 12, 2012 1:12 pm
Contact:

Post by Digital Larry »

Thanks a lot for the clarification. I very carefully went through the 1/X example at the knowledge base and mapped it to my situation. Just about to test it. Be still my heart!

Update - it seems like it worked. To be completely up front, the value I'm really trying to get to is (8 * pi)/(x * 512) or maybe 512 should be 511 because I'm scaling the value to write into the LFO rate register.
potul
Posts: 76
Joined: Tue Sep 26, 2017 12:33 am

Re: Tap Tempo tremolo again

Post by potul »

Hi Larry

can you share your final code? I'm trying to achieve the same thing, I guess (adapting the infamous tap tempo delay to a sin LFO for a tremolo), and it would be helpful, because my head is spinning with so many number conversions....

Regards
Digital Larry
Posts: 338
Joined: Mon Nov 12, 2012 1:12 pm
Contact:

Re: Tap Tempo tremolo again

Post by Digital Larry »

Sorry, I can't share the code as it was for a commercial customer.

DL
potul
Posts: 76
Joined: Tue Sep 26, 2017 12:33 am

Re: Tap Tempo tremolo again

Post by potul »

Ok, I understand

what I came up with is a variation of the code above, changing the parameter of the log instruction

Code: Select all

...
ldax taptempo
;load tempo in acc
log -1,-0.27178149
; ( logbase2(x) / 16 ) * -1 + ( logbase2(8*pi/ 512)/16 )
exp 1,0
; 2^(acc*16)
WRAX SIN0_RATE,0.00
...
But I didn't test it yet. Later today I will burn it and test if my calculations are right.
potul
Posts: 76
Joined: Tue Sep 26, 2017 12:33 am

Re: Tap Tempo tremolo again

Post by potul »

Quick update before going to bed.....

The formula works as expected, and everything fine. But it took me 2 hours of dumb troubleshooting because it was not working initially... and the failure was that I copy-pasted some code and did not check that the registers were duplicated (stupid me).

So, the code looks like this:
once you have your taptempo register calculated....

Code: Select all

...
ldax taptempo
; do the magic
;load tempo in acc
log -1,-0.27178149
; ( logbase2(x) / 16 ) * -1 + ( logbase2(8*pi/ 512/16 )
exp 1,0
; 2^(acc*16)
wrax sin0_rate,0
...
and if you want to control a ramp LFO....

Code: Select all

...
ldax taptempo
; do the magic
;load tempo in acc
log -1,-0.2499428
; ( logbase2(x) / 16 ) * -1 + ( logbase2(8*pi/ 512/16/0.7849 )
exp 1,0
; 2^(acc*16)
wrax   rmp1_rate,1 
...
I hope it gets useful for someone in the future.
Post Reply