Hi guys! I’m trying to code a plugin that changes sound in a similar way as Half-Time does. It is the same effect as when you resample a sound using a lower samplerate.
I tried to use JUCE Interpolators to resample every buffer in the processBlock. Here is the code I´m trying to make it work:
void RESAMPLINGAudioProcessor::processBlock (juce::AudioBuffer& buffer, juce::MidiBuffer& midiMessages)
{
juce::ScopedNoDenormals noDenormals;
auto totalNumInputChannels = getTotalNumInputChannels();
auto totalNumOutputChannels = getTotalNumOutputChannels();
juce::LagrangeInterpolator Resampler;
juce::AudioBuffer<float> bufferResampleado(totalNumInputChannels,buffer.getNumSamples()/2); //buffer of 128 samples and two channels
for (auto i = totalNumInputChannels; i < totalNumOutputChannels; ++i)
buffer.clear (i, 0, buffer.getNumSamples());
bufferResampleado.clear();
for (int channel = 0; channel < totalNumInputChannels; ++channel)
{
auto* channelData = bufferResampleado.getWritePointer (channel);
auto* channelDataRead = buffer.getReadPointer(channel);
Resampler.process(1.378125, channelDataRead, channelData, bufferResampleado.getNumSamples());
buffer = bufferResampleado;
Resampler.reset();
}
}
I’m doing something wrong as the only thing I hear when I load my plugin are my sounds being crushed with distortion.
Anyone has some idea? Do you think I’m goin the right way?