Audio Chorus (Delay with STM32)

My problem is, that im to stupid to use pointers.

No your not.

Here is a small extract from my book Arduino Music

What you have here is the input buffer and the output buffer tied together. Whenever you put a sample into the buffer, you take one out. The distance between the input and output pointers coupled with the sample rate give you the delay in seconds. Note here the input and output pointers are moving from right to left. The code fragment to implement this is below. Note I have changed it from the book to allow for a buffer in the processor's memory. The buffer is simply an array you define in memory.

void basicDelay(){  // loop time 48.2uS - sample rate 20.83 KHz
  static unsigned int bufferIn=bufferSize, bufferOut=bufferSize - bufferOffset, sample; 
  while(1){
     sample = analogRead(0);
     buffer[bufferIn] = sample; 
     sample = buffer[bufferOut]; 
     ADwrite(sample); // change this to how you are outputting your samples 
     bufferIn++;
     if(bufferIn > bufferSize) bufferIn=0;
     bufferOut++;
     if(bufferOut > bufferSize) bufferOut=0; 
  }
}

Remember this is a code fragment and needs other functions to make it run, but you can easily see the idea. The length of the delay is set by the bufferOffset variable and is the number of samples between the input and output pointers. A sample is read from the A/D and saved at the location given by the bufferIn variable. Then a sample is taken from the memory from a location given in the bufferOut variable and sent to the A/D converter. Finally, the two pointers are incremented and, if either exceeds the total buffer size, they are wrapped around back to zero.
The bufferOffset variable is set from the outside and can implement different lengths of delay, up to the maximum size of the memory you have.

You can download the software from that link. Listing 15.8 is a multi effects program but it is tailored to the board I designed for this chapter.

I use a 2nd order Lowpass at 15KHz.

Nowhere close to being good enough. At 30KHz you are only 6dBs down. So lower the roll off or get a higher order filter, or both.

When i use a fixed delay the signal is clean, with more or less the same code.

When you change the delay you have a whole lot of samples in the buffer that are not related to what you are doing. For example you make the delay longer and there is junk samples in the difference between the old buffer and the new one. You will here these samples as noise because they don't fit in with what is going on at this point.