Writing values directly to SIN0_RATE and SIN0_WIDTH

Algorithm development and general DSP issues

Moderator: frank

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

Writing values directly to SIN0_RATE and SIN0_WIDTH

Post by Digital Larry »

I'm trying to map a scaled value of some other parameter to adjust the SIN LFO.

What are the decimal values that correspond to setting LFO rate to 25 and 125 (out of 511) using the WLDS instruction?

e.g.

SOF 0, 0.25
WRAX SIN0_RATE, 0

Similar question as regards the width. What would be the values to write to SIN0_WIDTH that would correspond to using values of 16 and 64 in the WLDS instruction?

Many thanks,

DL
Iconnu
Posts: 10
Joined: Thu Apr 17, 2014 7:49 pm

Post by Iconnu »

Kf = 2^17 (2 pi f / R)

f: Desired LFO frequency in Hz
R: Sample rate in Hz

Kf range: 0 to 511

Kf decimal = Kf / 512

25/512 = 0.048828125

125/512 = 0.244140625


--------------------------------------

Ka = N (32767/16385)

N: Delay length in samples

Ka range: 0 to 32767

Ka decimal = Ka / 32768

16/32768 = 0.00048828125

64/32768 = 0.001953125

the word is RANGE not WIDTH btw
Digital Larry
Posts: 338
Joined: Mon Nov 12, 2012 1:12 pm
Contact:

Post by Digital Larry »

Thanks! I realize I already had answered this question, the trouble with my mind recently is where I left it. :lol:
knutolai
Posts: 65
Joined: Wed Nov 23, 2016 9:43 am
Location: Bergen, Norway

Post by knutolai »

To find the frequency and delay length from Kf / Ka decimals:

From Kf decimal (K) to Frequency (f):

f = K * (512 * R) / ( 2^18 * pi)

R = sample rate (32768)

--------------------------------------------------

From Ka decimal (K) to delay length (a) :

a = K * (16385 * 32768 / 32767)
Post Reply