title: C++ - Play back a tone generated from a sinusoidal wave
body: <p>Hey everyone, I'm currently trying to figure out how to play back a tone I have generated using a sinusoidal wave. </p>
  
  <p>Here's my code:</p>
  
  <pre><code>#include &lt;iostream&gt;
  #include &lt;OpenAL/al.h&gt;
  #include &lt;OpenAL/alc.h&gt;
  #include &lt;Math.h&gt;
  
  using namespace std;
  
  int main (int argc, char * const argv[]) {
  
      int number = 0;
      int i, size;
      double const Pi=4*atan(1); 
      cout &lt;&lt; "Enter number of seconds:" &lt;&lt; endl;
      scanf("%d", &amp;number);
      size = 44100*number;
      unsigned char buffer [size]; //buffer array
  
      for(i = 0; i &lt; size; i++){
          buffer[i] = (char)sin((2*Pi*440)/(44100*i))*127;
      }
  
      return 0;
  }
  </code></pre>
  
  <p>Obviously it doesn't do anything at the moment, since I have no idea how to play the buffer.
  I don't want to generate a wav file, nor do I want to load one in. I just want to play back the buffer I have generated.</p>
  
  <p>I am currently working on Mac OS X, and have tried using OpenAL methods - however I have found that alut and alu are not part of it anymore and if I try to use it then it turns out that it's all depredated anyway. 
  I have also tried to include QAudioOutput, but for some reason it does not appear to be anywhere on my Mac.</p>
  
  <p>I just want a simple playback of the tone I've created. Does anyone have anything they can point me to? </p>
  
  <p>Thanks heaps!!!</p>