Code: Select all
streamin L1;
streamin R1;
streamin L2;
streamin R2;
streamin frac;
streamout left;
streamout right;
float frac2;
frac2 = 1-frac;
left = (L1*frac2)+(L2*frac);
right = (R1*frac2)+(R2*frac);
- R1 is the value of the Right sample at index p
- L2 is the value of the Left sample at index p+1
- R2 is the value of the Right sample at index p+1
- frac is the fractional part of the step. If I play at original pitch (base C4), frac=1; if I change the base of pitch to C5 (pitching down), frac=0.5. And so on.
- left is the final Left value at index p
- right is the final Right value at index p
p goes between 0 to wavefile size-1 (i.e. first sample value is at index 0).
My first question is: if I'm on original pitch (and so frac2=1-1=0, frac1=1 and p=0):
left=L2
right=R2
why it outputs the values of the "next" sample (p+1)? In this way it will ignore the "first" sample and the last one (because will be null).
What's the reason of this? I've analyzed many Sampler plugins, and the Interpolation method is often this.