Hello! I’m completely stuck with the JUCE interpolators
Before that I used libsamplerate and I was happy.
I need to resample the buffer of floats from sound file’s samplerate to DAW session’s sample rate.
So I have the source buffer (loaded from the reader):
Code: Select all
juce::AudioBuffer<float> *buffer = new juce::AudioBuffer<float>;
If the buffer’s samplerate != session’s samplerate I need to resample.
My steps are.
Define the resamling ratio:
Code: Select all
float ratio = (float) session_samplerate / samplerate;
Calculate the output frames (samples) count for each channels:
Code: Select all
size_t output_frames_count = ratio * length_in_samples;
length_in_samples is the length of the source buffer, in samples, for the any of the channels.
I define the new buffer to write resampled data:
Code: Select all
juce::AudioBuffer<float> * output_buffer = new juce::AudioBuffer <float> (channels, output_frames_count);
Then I process:
Code: Select all
for (int i = 0; i < channels; i++)
{
juce::LinearInterpolator interpolator;
int result = interpolator.process (ratio,
buffer->getReadPointer(i),
output_buffer->getWritePointer(i),
output_frames_count);
}
Sometime it works, but sound sounded as doubled/repeated, sometime I get just crashes..