title: Manipulating AudioQueueBuffer audio data results in noise
body: <p>I try to implement an iPhone sound processing app using SpeakHere sample app as a starting point. The app involves manipulating buffered audio samples during playback. When I multiply the samples by a fractional number (0.9 for instance) I get noise as a result. The strangest thing about it is that when multiplying samples by whole numbers (like 1.0, 2.0) or adding or subtracting from them the playback sounds as expected.</p>
  
  <p>I'm doing it in the playbackCallback function of AudioPlayer.m with the following code snippet:</p>
  
  <pre><code>  //------------------
    //If buffer samples are multiplied by 0.9 we get noise. If we multiply it by 1.0 or add to it everything's fine.
    short *buffer = (short *)calloc(1, numPackets * 2);
    memmove(buffer, bufferReference-&gt;mAudioData, numPackets * 2);
    for (int i = 0; i &lt; numPackets; i++)
    {
     buffer[i] *= 0.9;
     //buffer[i] *= 1.0;
     //buffer[i] += 10.0;
    }
    memmove(bufferReference-&gt;mAudioData, buffer, numPackets * 2);
    free(buffer);
    buffer = NULL;
    //-------------------
  </code></pre>
  
  <p>The full project could be downloaded here: <a href="http://depositfiles.com/files/lmnkq68n8" rel="nofollow noreferrer">http://depositfiles.com/files/lmnkq68n8</a></p>
  
  <p>Could anyone point me to what am I doing wrong? I've been struggling with it for a couple of days already and I'm completely lost.</p>
  
  <p>Thank you!</p>