title: OpenAL/OpenAL Soft
body: <p>OpenAL.org &amp;&amp; creative dev website is down. I choose alternative version <a href="http://kcat.strangesoft.net/openal.html" rel="nofollow">OpenAL Soft</a>. I'm worried because in binary installation of OpenAL Soft I can't find the <code>alut.h</code> header. What is the purpose of the <code>alut.h</code> header? What change this header make if I had one?</p>
  
  <p>Oh and one more thing. I take a simple code from this (ZIP in description)<a href="http://www.youtube.com/watch?v=V83Ja4FmrqE" rel="nofollow">tutorial</a> and translate in C language. I actually get a sound but it's deformed. I wonder what is wrong with my code?</p>
  
  <pre><code>#include &lt;stdio.h&gt;
  #include &lt;stdlib.h&gt;
  #include &lt;windows.h&gt;
  #include &lt;OPENAL/al.h&gt;
  #include &lt;OPENAL/alc.h&gt;
  
  
  int main(int argc, char *argv[])
  {  
  FILE *fp = NULL;
  fp=fopen("WAVE/Sound.wav","rb");
  
  char type[4];
  DWORD size,chunkSize;
  short formatType,channels;
  DWORD sampleRate,avgBytesPerSec;
  short bytesPerSample,bitsPerSample;
  DWORD dataSize;
  
  fread(type,sizeof(char),4,fp);
  fread(&amp;size, sizeof(DWORD),1,fp);
  fread(type, sizeof(char),4,fp);
  fread(type,sizeof(char),4,fp);
  fread(&amp;chunkSize,sizeof(DWORD),1,fp);
  fread(&amp;formatType,sizeof(short),1,fp);
  fread(&amp;channels,sizeof(short),1,fp);
  fread(&amp;sampleRate,sizeof(DWORD),1,fp);
  fread(&amp;avgBytesPerSec,sizeof(DWORD),1,fp);
  fread(&amp;bytesPerSample,sizeof(short),1,fp);
  fread(&amp;bitsPerSample,sizeof(short),1,fp);
  fread(type,sizeof(char),4,fp);
  fread(&amp;dataSize,sizeof(DWORD),1,fp);
  
  ALCdevice *device;
  ALCcontext *context;
  device = alcOpenDevice(NULL);
  context = alcCreateContext(device, NULL);
  alcMakeContextCurrent(context);
  
  ALuint source;
  ALuint buffer;
  ALuint frequency=sampleRate;
  ALenum format=0;
  
  alGenBuffers(1, &amp;buffer);
  alGenSources(1, &amp;source);
  
  if(bitsPerSample == 8)
  {
      if(channels == 1)
          format = AL_FORMAT_MONO8;
      else if(channels == 2)
          format = AL_FORMAT_STEREO8;
  }
  else if(bitsPerSample == 16)
  {
      if(channels == 1)
          format = AL_FORMAT_MONO16;
      else if(channels == 2)
          format = AL_FORMAT_STEREO16;
  }
  
  alBufferData(buffer, format, "24641", dataSize, frequency);
  
  //Sound setting variables
  ALfloat SourcePos[] = { 0.0, 0.0, 0.0 };                                    //Position of the source sound
  ALfloat SourceVel[] = { 0.0, 0.0, 0.0 };                                    //Velocity of the source sound
  ALfloat ListenerPos[] = { 0.0, 0.0, 0.0 };                                  //Position of the listener
  ALfloat ListenerVel[] = { 0.0, 0.0, 0.0 };                                  //Velocity of the listener
  ALfloat ListenerOri[] = { 0.0, 0.0, -1.0,  0.0, 1.0, 0.0 };                 //Orientation of the listener
  
  alListenerfv(AL_POSITION,    ListenerPos);                                  //Set position of the listener
  alListenerfv(AL_VELOCITY,    ListenerVel);                                  //Set velocity of the listener
  alListenerfv(AL_ORIENTATION, ListenerOri);                                  //Set orientation of the listener
  
  alSourcei (source, AL_BUFFER,   buffer);                                    //Link the buffer to the source
  alSourcef (source, AL_PITCH,    1.0f     );                                 //Set the pitch of the source
  alSourcef (source, AL_GAIN,     1.0f     );                                 //Set the gain of the source
  alSourcefv(source, AL_POSITION, SourcePos);                                 //Set the position of the source
  alSourcefv(source, AL_VELOCITY, SourceVel);                                 //Set the velocity of the source
  alSourcei (source, AL_LOOPING,  AL_FALSE );                                 //Set if source is looping sound
  
  //PLAY 
  alSourcePlay(source);                                                       //Play the sound buffer linked to the source
  system("PAUSE");                                                            //Pause to let the sound play
  
  //Clean-up
  fclose(fp);                                                           //Delete the sound data buffer
  alDeleteSources(1, &amp;source);                                                //Delete the OpenAL Source
  alDeleteBuffers(1, &amp;buffer);                                                 //Delete the OpenAL Buffer
  alcMakeContextCurrent(NULL);                                                //Make no context current
  alcDestroyContext(context);                                                 //Destroy the OpenAL Context
  alcCloseDevice(device);                                                     //Close the OpenAL Device
  
  return EXIT_SUCCESS;                                                        
  }
  </code></pre>