Should I use ResamplingAudioSource for my sampler? [Solved]

I’ve tried CatmullRomInterpolator and LagrangeInterpolator, having 1 per audio channel in every voice (2 per voice for stereo) and I call reset on all of voice’s interpolators on startNote (since stopNote may tail off).

There is a very noticeable drop in quality.

// this is correct right?
const double speedRatio = sampleFileSampleRate / hostSampleRate;
// (transposing is disabled so I don't care for changing the speed of a sample)

Update:
Increasing the buffer size of the host, improves the quality.

The quality drop is still perceptible, even with the largest buffer size on my machine (2016 samples). But if it was perfect, this isn’t a solution - keeping the buffer so high.

What am I doing wrong?

The only thing I can think of now is the number of input samples I enter is different from the number I want the interpolator to produce - I get a pitchRatio * blockSize. Where (this code is from the voice):

pitchRatio = pow (2.0, (midiNoteNumber - sound->midiRootNote) / 12.0)
    * sound->sourceSampleRate / getSampleRate ();

Update2:
I found out an error in my calculations which was accumulating faster with lower buffer size - so changing the buffer size, doesn’t produce (at least not perceptible) difference in the audio, any more.

Quality remains affected quite badly (the quality is now constant with any type of buffer size setting, but still unsatisfying).

I am not switching to ResamplingAudioSource, because even though no one has responded yet, I am 90% sure I shouldn’t be using it in my case, since I would still need resampling if playing with changed pitch (speed), and that has to happen on voice rendering level. So it doesn’t make sense to have resampling in 2 places, with 2 different qualities.

Update3:
OK, I’ve been digging around the forum history and found this: LagrangeAudioSource?

This makes me think I should have resampling in both places - a simpler one (like the Lagrangian) for speed change inside the sampler voice and a more sophisticated one fed with the entire rendering of the sampler (the ResamplingAudioSource).

Is this what I’m supposed to do? Anyone…

1 Like