title: Low Pass filter in C
body: <p>I'm implementing a low pass filter in C wih the PortAudio library.
  I record my microphone input with a script from PortAudio itself. There I added the following code:</p>
  
  <pre><code>float cutoff = 4000.0;
  
  float filter(float cutofFreq){
      float RC = 1.0/(cutofFreq * 2 * M_PI);
      float dt = 1.0/SAMPLE_RATE;
      float alpha = dt/(RC+dt);
  
      return alpha;
  }
  
  float filteredArray[numSamples];
  filteredArray[0] = data.recordedSamples[0];
  
  for(i=1; i&lt;numSamples; i++){
      if(i%SAMPLE_RATE == 0){
          cutoff = cutoff - 400;
      }
      data.recordedSamples[i] = data.recordedSamples[i-1] + (filter(cutoff)*(data.recordedSamples[i] - data.recordedSamples[i-1]));
  }
  </code></pre>
  
  <p>When I run this script for 5 seconds it works. But when I try to run this for more then 5 seconds it fails. The application records everything, but crashes on playback. If I remove the filter, the application works.</p>
  
  <p>Any advice?</p>