title: Recorded sound by core audio is distorted and noisy
body: <p>I have been trying to record sound using Audio Queue on Mac OS X. Right now, my code works and I can store my recorded sound on file, but when I play the sound, it is distorted, noisy and almost useless. I have adapted my code from official codes(SpeakHere) published by Apple, but it doesn't seem to work. I don't know where the problem lies, but I guess maybe it's the setting of the format, it's like: </p>
  
  <pre><code>  AudioStreamBasicDescription recordFormat;
  memset(&amp;recordFormat, 0, sizeof(recordFormat));
  
  recordFormat.mFormatFlags =         kAudioFormatFlagIsPacked | kAudioFormatFlagIsSignedInteger;
  recordFormat.mFormatID         = kAudioFormatALaw; // 2
  recordFormat.mSampleRate       = 16000.0;               // 3
  recordFormat.mChannelsPerFrame = 1;                     // 4
  recordFormat.mBitsPerChannel   = 16;                    // 5
  recordFormat.mBytesPerPacket   = recordFormat.mChannelsPerFrame * sizeof (SInt16);                       // 6
  recordFormat.mBytesPerFrame =
  recordFormat.mChannelsPerFrame * sizeof (SInt16);
  recordFormat.mFramesPerPacket  = 1;                     // 7
  recordFormat.mReserved = 0;
  </code></pre>
  
  <p>Any clue on the subject(reasons of recording incomprehensible, distorted and noisy) sound is appreciated.</p>
  
  <p><strong>EDIT</strong></p>
  
  <p>I opened the file using CoolEdit Pro. It looked like this:</p>
  
  <p><a href="http://i.stack.imgur.com/Qge5L.png" rel="nofollow">WAVE file form</a></p>