Adding partial sample via source file

Hello all!

This is my first post and I am new to JUCE, so apologies if my introduction to the forum is embarrassingly simple. I am working on building a sampler and I have caught on to the UI pretty quickly, but I have reached a point where I’m learning the backend.

I can successfully load a sample using:

mSampler.addSound(new juce::SamplerSound(key_num, *mFormatReader, range, key_num_int, 0.1, 0.1, 10));

But with the sampler, I am trying to allow users to crop the sample as my UI shows:

I understand a lot of the DSP processing of the samples needs to occur in the processBlock of my plugin processor. Which currently looks like this:

void NewProjectAudioProcessor::processBlock (juce::AudioBuffer& buffer, juce::MidiBuffer& midiMessages)
juce::ScopedNoDenormals noDenormals;
auto totalNumInputChannels = getTotalNumInputChannels();
auto totalNumOutputChannels = getTotalNumOutputChannels();

// this code if your algorithm always overwrites all the output channels.
for (auto i = totalNumInputChannels; i < totalNumOutputChannels; ++i)
    buffer.clear (i, 0, buffer.getNumSamples());

mSampler.renderNextBlock(buffer, midiMessages, 0, buffer.getNumSamples());


I can’t assign the starting point when adding a sound to my sampler, what’s the recommended way to do this? Audio transport? Can those be assigned to a sampler and mapped to a key?

Thanks in advance!

Well, I got some much needed help from Josh the Audio Programmer! Turns out I needed to expand the “SamplerSound” class. I never would’ve thought this functionality didn’t come out of the box and thought it was a little early in my JUCE experience to touch the base JUCE code, but here we are. Watch out for the buffer sizing if you want to venture down this road, it can be a doozy!

Good talk JUCE forum! Kisses- boomboom