Conditional randomization gets stuck
I think you have a problem with your math here, not with your code. What
you are simulating is very similar to a 1-dimensional random
walk.
According to the linked MathWorld page, for such a process “the most
probable number of sign changes in a walk is 0”.

If, at some point in your program, the loop starts with note == 6, and
then it starts randomly going up, there is a sizable probability for it
to never go back to values below 7.



Edit: One possible solution could be to avoid the random-walk notion
and instead repeat the random choice always from the same starting
point.

int oldNote = note;  // starting point
do
    note = oldNote + random(-2, 3);
while (
    note == loop1[i - 1] ||       
    note == loop1[i - 2] ||       
    note &gt; 6 ||                       
    note &lt; 0);
loop1[i] = note;