title: How to implement IIR filters in C?
body: <p>I'm trying to implement simple IIR (Direct Form I) filters in C.</p>
  
  <p>For high-pass (10 Hz at 256 samples/second) I do this:</p>
  
  <pre><code>int Diff = Sample - Previous_Sample;
  
  HP_Output = ((HP_Output + Diff) * 4) / 5;
  </code></pre>
  
  <p>For low-pass (10 Hz @ at 32 samples/second) I do this:</p>
  
  <pre><code>int Diff = Sample - LP_Output ;
  
  LP_Output = ((LP_Output + Diff) * 2) / 3; 
  </code></pre>
  
  <p>Now I was wondering: are both implementations mathematically correct? </p>
  
  <p>And if I want to change the input sample-rate (or filter frequency), how do I calculate the new factors?</p>