Newbie Wavetable question

DSP, Plugin and Host development discussion.
Post Reply New Topic
RELATED
PRODUCTS

Post

Hi guys!
I'm very happy to see this new part of kvr!!
I'm learnin' c++/dsp/basic math and calculus to do my own audio stuff....
I've got that wonderful book by Curtis Roads called
"Computer Music Tutorial"

In the chapter dedicated to wavetable synthesis there's a formula about table's index and increment stuff.....

the formula is

phase_index=modL (previous_phase+increment)

The explanation is : "...The modulo operation divides the sum [previous_phase+increment] by the Table lenght (L) and keeps only the remainder....."

Now, my question is...
i.e. we have a 10 index long table (0 to 9) and we have a sample increment of 1....following that formula
we have phase_index = mod 10 / (0+1) = 0
then mod 10 / (1+1)=0, then mod 10 / (2+1) = 1 , then
mod 10 / (3+1)= 2 , mod 10 / (4+1) = 0.....
so the index sequenc is 0,0,1,2,0,4,3,2,1,0
maybe i've not understand 'cause this is a funny index sequence to read a wavetable...
can anyone tell me if i did some misunderstanding?
...well i'm pretty sure
thanx in advance
lalo

Post

Your first would be mod10/(10+0)=0,second would be mod10/(0+1)=1,third would be mod10/(1+1)=2,etc.
Alternatively if you aren't looking at the index as a loop,you could add a constant of -1 at the end.Then,the lookup for the first would be [mod10/(0+1)]-1=0,the second would be [mod10/(1=1)]-1=1,etc.
You're only using the remainder,so it would keep incrementing by one-I don't see where you're getting your numbers :?
ew
A spectral heretic...

Post

Oh thanx!
maybe i did'nt understand the mod operation cause to me 10/(0+1)=10 and the remainder is 0
same thing for 10/(1+1)=5 and the remainder is 0....so maybe is better u explain me the modulo operation...thanx in advance
lalo

Post

It's because you're looking at it backwards.It's the index that's being divided by 10,and not 10 being divided by the index.Your divisor is the constant,and not the other way around.
ew
A spectral heretic...

Post

Thanx a lot!!
I was thinkin' about this solution...but i did'nt understand that 1/10=0 and the reminder is 1.....
i was a fool thinkin' that 1/10=0.1...hehe....now i've understand the modulo stuff...thanx a lot ew!!!!

Post

Right-you've got it :) In a modulo operation,one output will be the highest integer that's less than or equal to the divisor(the integer result of the division),and the modulo's the remainder.
ew
A spectral heretic...

Post Reply

Return to “DSP and Plugin Development”