numChannel exception when trying to make flanger

I keep trying to create delay with my LFO but I keep being told that my channels are out of bounds, what’s wrong?

ScopedNoDenormals noDenormals;
auto totalNumInputChannels = getTotalNumInputChannels();
auto totalNumOutputChannels = getTotalNumOutputChannels();
int n = buffer.getNumSamples();
for (auto i = totalNumInputChannels; i < totalNumOutputChannels; ++i)
buffer.clear (i, 0, n);

    for  (int channel = 0;  channel < totalNumInputChannels; ++channel)
    {
         printf("%d", totalNumInputChannels);
        
        //auto* delayBlockPointer = mDelayBlockBuffer.getWritePointer(channel);
        //auto* ringBuffptr = mRingBuf.getWritePointer(channel);
       
       
        
        
        int ringbufferWriteIndx = mRingBufferWriteIdx;
        float currentAngle = mCurrentAngle;
        for (int i = 0; i < n; ++i, ++mRingBufferWriteIdx)
        {
            int j = 0, r0 = 0 , r1 = 0 , r2 = 0 , r3 = 0;
            double readIndx = 0 , mu = 0;
            
            float DelayTime = std::sin(mCurrentAngle);
            DelayTime *= (mLFODepth/100.0);
            //Scale the samples by 5ms of samples
            DelayTime += 1.0;
            DelayTime = 0.5;
            DelayTime *= roundToInt(0.02 * mSampleRate);
            DelayTime += roundToInt(0.005 * mSampleRate);
            // advance the modulator signal angle by one increment for the next sample
            currentAngle += mAngleDelta;
            readIndx = mRingBufferWriteIdx - 22500.0;
            
            if (readIndx < 0.0)
                readIndx += mRingBufferSize;
            mu = readIndx - floor(readIndx);
            j = floor(readIndx);
            r0 = ((j - 1) >= 0) ? j - 1 : mRingBufferSize + (j - 1);
            r1 = j;
            r2 = (j + 1) % mRingBufferSize;
            r3 = (j + 2) % mRingBufferSize;
            
            //delayBlockPointer[i] = cubic_interpolation(ringBuffptr[r0], ringBuffptr[r1], ringBuffptr[r2], ringBuffptr[r3], mu);
            
        }
        
        //Reduce the gain of the delayblock 
        //mDelayBlockBuffer.applyGain(channel, 0, n, 0.5); 
        //Mix the delayed audio with the dry signal. 
        buffer.addFrom(channel, 0, mDelayBlockBuffer, 0, 0, n);
        
        //Feed the mix back into the delay buffer at the current write position. 
        //mRingBuf.copyFrom(channel, mRingBufferWriteIdx, buffer, channel, 0, n); 

       
    }

    mRingBufferWriteIdx += n; 
    mRingBufferWriteIdx = fmod(mRingBufferWriteIdx, mRingBufferSize); 
    
   

}