title: Audio playback, creating nested loop for fade in/out
body: <p>First time poster here. </p>
  
  <p>A quick question about setting up a loop here. I want to set up a for loop for the first 1/3 of the main loop that will increase a value from .00001 or similar to 1. So I can use it to multiply a sample variable so as to create a fade-in in this simple audio file playback routine. </p>
  
  <p>So far it's turning out to be a bit of a head scratcher, any help greatfully recieved. </p>
  
  <pre><code>for(i=0; i &lt; end &amp;&amp; !feof(fpin); i+=blockframes) 
  { 
      samples = fread(audioblock, sizeof(short), blocksamples, fpin); 
      frames = samples; 
      for(j=0; j &lt; frames; j++)
      {   
          for (f = 0; f&lt; frames/3 ;f++)
          {
              fade = fade--;
          } 
      output[j] = audioblock[j]/fade;
      }
  
      fwrite(output,sizeof(short), frames, fpoutput); 
  } 
  </code></pre>
  
  <p>Apologies,
  So far I've read and re-write the file successfully. My problem is I'm trying to figure out a way to loop the variable 'fade' so it either increases or decreases to 1, so as I can modify the output variable.</p>
  
  <p>I wanted to do this in say 3 stages: 
  1. From 0 to frames/3 to increace a multiplication factor from .0001 to 1 
  2. from frames 1/3 to frames 2/3 to do nothing (multiply by 1) and 
  3. For the factor to decrease again below 1 so as for the output variable to decrease back to the original point. </p>
  
  <p>How can I create a loop that will increase and decrease these values over the outside loop? </p>