title: iPhone - lot of noise in audio file
body: <p>I am writing raw audio bytes from two files into a new wav file to combine the two files. The resultant file which is created has the contents of both the audio clips but there is also a lot of noise in the file.</p>
  
  <p>Can someone point me to a good example which shows how to write raw audio bytes to a file? Here's the basic logic that I am following</p>
  
  <pre><code>SInt32 leftSample1 = ReadSampleFromFile1(music_iter1);
  leftSample1 = (SInt32)((float) leftSample1 * 0.7071); //to avoid clipping
  
  SInt32 leftStereoSample2 = ReadLeftSample(music_iter2);
  leftStereoSample2 += leftSample1;
  if (leftStereoSample2 &gt; 32767)
  leftStereoSample2 = 32767;
  else if (leftStereoSample2 &lt; -32768
  leftStereoSample2 = -32768;
  // write leftStereoSample2 to the file
  //do the same as left sample to right sample also
  
  ++music_iter2;
  ++music_iter1;
  </code></pre>
  
  <p>Thanks.</p>