SHOW:
|
|
- or go back to the newest paste.
| 1 | counter_t increment=42; | |
| 2 | counter_t threshold=9001; | |
| 3 | counter_t counter=0; | |
| 4 | - | sample_t curSample=0; |
| 4 | + | sample_t curSample=0,nextSample=0; |
| 5 | ||
| 6 | - | sample_t dropDoubleInterpolateNextSample() {
|
| 6 | + | sample_t linearInterpolateNextSample() {
|
| 7 | counter+=increment; | |
| 8 | while(counter>threshold) {
| |
| 9 | counter-=threshold; | |
| 10 | - | curSample=readNextSample(); |
| 10 | + | curSample=nextSample; |
| 11 | nextSample=readNextSample(); | |
| 12 | - | return curSample; |
| 12 | + | |
| 13 | ||
| 14 | //can be optimized using fixed point math | |
| 15 | //and fast division by shifting | |
| 16 | float t=counter/threshold; | |
| 17 | ||
| 18 | //lerp between the two samples | |
| 19 | return curSample*(1-t)+nextSample*(t); | |
| 20 | } |