Array question


#1

I have been pulling my hair out on this one, probably an easy one:

void processSample(float* in) noexcept

    { 

        const float input = *in;

        data[currentPos] = input;

        outPos = currentPos - delay;

        //if (outPos < 0) outPos += dataLength;

        *in = data[outPos];        

        ++currentPos;

        if (currentPos >= dataLength) currentPos -= dataLength;

    }

 

When I remove the //, or change it in to if (outPos < 0) outPos = 0;, it crashes AUValTool and I do not understand why. Anyone any hint for me?


#2

Okay, seems that dataLenght is not initialised with the correct value. After using outPos = 16000 + currentPos - delay, it works.