This is by no means optimized i just read about fractional windowed sincs and windowed sincs from dspguide. Most resamplers have artifacts when the pitch is really low soxR, quest for perfect resampler, some others i have tried like the lagrange in Juce. My question is do I interpolate further to handle low frequency resampling artifacts. I want about 8 octaves down. How do I appropriately set my cutoff in the windowed sinc maybe thats what i am missing?
Code:
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-M2+fraction) <= 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; } for(int i = 0; i < (int)M; i++){ auto norm = SINC[i]/sum; // auto pos = (int) sample_position - i;// auto alpha = (float) (sample_position - pos);// auto invAlpha = 1.0f - alpha;//// // just using a very simple linear interpolation here..// float l = (inL[pos] * invAlpha + inL[pos + 1] * alpha);// float r = (inR[pos] * invAlpha + inR[pos + 1] * alpha);// 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); }
Statistics: Posted by Marvinh — Sat May 18, 2024 8:06 pm