Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- counter_t increment=42;
- counter_t threshold=9001;
- counter_t counter=0;
- sample_t curSample=0,nextSample=0;
- sample_t linearInterpolateNextSample() {
- counter+=increment;
- while(counter>threshold) {
- counter-=threshold;
- curSample=nextSample;
- nextSample=readNextSample();
- }
- //can be optimized using fixed point math
- //and fast division by shifting
- float t=counter/threshold;
- //lerp between the two samples
- return curSample*(1-t)+nextSample*(t);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement