title: Calculate saw and triangle wave from specific data
body: <p>I need to calculate a triangle and saw wave but it is a little complicate because of my model and the data I'm able to work with (but maybe I'm just confused).</p>
  
  <p>I'm able to calculate my sine wave but I'm not really using a frame counter. What I do is, calculate a <code>theta_increment</code> variable which I can use the next time I need to calculate a sample. This works like this:</p>
  
  <pre><code>float x = note.frequency / AppSettings::sampleRate;
  float theta_increment = 2.0f * M_PI * x;
  float value = 0;
  
  if(waveType == SINE){
      value = sin(note.theta) * fixedAmplitude;
  }
  </code></pre>
  
  <p>Now that I have the value of the currend frame/sample I store <code>theta_increment</code> inside my <code>note.theta</code> member so I can use it for the next sample:</p>
  
  <pre><code>note.theta += theta_increment;
  </code></pre>
  
  <p>I've looked at tons of examples on how I should calculate a saw or a triangle but I can't figure it out. (I only have the data mentioned above at my disposal) This is my last attempt but it's not working and giving me tons of glitches:</p>
  
  <pre><code>value = 1.0f - (2.0f * ((float)note.theta / (float)44100));
  </code></pre>