Code: Select all

```
std::pair<double,double> get_next_sample() {
double outL = 0.0;
double outR = 0.0;
double sum = 0;
double fraction = sample_position - (int)sample_position;
for(int i = 0; i < (int)M; i++) {
const double w = 0.42 - 0.5*cos(TWO_PI*cutoff*(i+fraction)/M) + 0.08*cos(4*M_PI*((i+fraction))/M);
if(abs(i+fraction-M2) <= 0.000000001){
SINC[i] = w*TWO_PI*cutoff;
}else{
SINC[i] = w*(sin(TWO_PI*cutoff*(i+fraction-M2))/(i+fraction-M2));
}
sum += SINC[i];
}
for(int i = 0; i < (int)M; i++){
auto norm = SINC[i]/sum;
float l = inL[(int)sample_position-i];
float r = inR[(int)sample_position-i];
outL += l * norm;
outR += r * norm;
}
sample_position += pitch_ratio;
if(sample_position >= len) {
sample_position = 0;
}
return std::make_pair(outL, outR);
}
```