Juce SynthesiserVoice and SoundTouch

Hello for everybody!

I try to implement my own SynthesiserVoice class and everything looks good.
But have problem with SoundTouch. I try to put it to renderNextBlock, but it doesn’t work.

Could you help me with it?

My code:

void renderNextBlock(AudioBuffer<float>& outputBuffer, int startSample, int numSamples) override
{
    if (auto* playingSound = static_cast<SynthSound*> (getCurrentlyPlayingSound().get()))
    {
            auto data = *playingSound->getAudioData();
            auto length = playingSound->getSoundLength();
            auto numOfChannels = data.getNumChannels();
        
        AudioSampleBuffer buffer0 = data;
        AudioSampleBuffer buffer1 = AudioSampleBuffer(1, numSamples);
        buffer1.copyFrom(0, startSample, buffer0, 1, startSample, numSamples);
        
        float* out0 = buffer0.getWritePointer(0, startSample);
        float* out1 = buffer1.getWritePointer(0, startSample);
        
        pSoundTouch1->putSamples(out0, numSamples);
        pSoundTouch1->receiveSamples(out0, numSamples);
        
        pSoundTouch2->putSamples(out1, numSamples);
        pSoundTouch2->receiveSamples(out1, numSamples);
        
        data.copyFrom(1, startSample, buffer1, 0, startSample, numSamples);
        
        
        const auto inL = data.getReadPointer(0);
        const auto inR = numOfChannels > 1 ? data.getReadPointer(0) : nullptr;
        
        auto outL = outputBuffer.getWritePointer(0, startSample);
        auto outR = numOfChannels > 1 ? outputBuffer.getWritePointer(1, startSample) : nullptr;

        auto position = numSamples;
        while (--numSamples >= 0)
        {
            auto pos = (int)sourceSamplePosition;
            auto alpha = (float)(sourceSamplePosition - pos);
            auto invAlpha = 1.0f - alpha;
            
            float l = (inL[pos] * invAlpha + inL[pos + 1] * alpha);
            float r = (inR != nullptr) ? (inR[pos] * invAlpha + inR[pos + 1] * alpha)
            : l;
            
            auto envelopeValue = adsr.getNextSample();
            
            if (outR != nullptr)
            {
                *outL++ += l;
                *outR++ += r;
            }
            else
            {
                *outL++ += (l + r) * 0.5f;
            }
            
            sourceSamplePosition += pitchRatio;
            position++;
            
            if (sourceSamplePosition > length)
            {
                stopNote(0.0f, false);
                break;
            }
        }
}

Thank you!