title: OpenAL 3D sounds
body: <p>In my 3D game I currently have sounds working through a factory class "sound". I am initializing OpenAL through my camera class, on load it will store global floatbuffers of its position, orientation and velocity <br></p>
  
  <pre><code>private static FloatBuffer listenerPosition = BufferUtils.createFloatBuffer( 3 ).put( new float[] { X(), Y(), Z() } );
  private static FloatBuffer listenerOrientation = BufferUtils.createFloatBuffer( 6 ).put (new float[] { 0.0f, 0.0f, 1.0f, 0.0f, 1.0f, 0.0f } );
  private static FloatBuffer listenerVelocity = BufferUtils.createFloatBuffer( 3 ).put (new float[] { Velocity.x, Velocity.y, Velocity.z } );
  </code></pre>
  
  <p>Then on each tick when the camera moves or rotates it updates these with the code<br></p>
  
  <pre><code>listenerVelocity.put(0, Velocity.x);
  listenerVelocity.put(1, Velocity.y);
  listenerVelocity.put(2, Velocity.z);
  
  alListener( AL_POSITION, listenerPosition );
  alListener( AL_ORIENTATION, listenerOrientation );
  alListener( AL_VELOCITY, listenerVelocity );
  </code></pre>
  
  <p>This is the class which I think is not enabling OpenAL to know how I want the sound though I am giving it all the information it needs as far as I know.</p>
  
  <pre><code>private int ID;
  
  public Sound(String name) {
      try {
          ID = alGenBuffers();
          WaveData data = WaveData.create(new BufferedInputStream(new FileInputStream("res/Sound/"+name+".wav")));
          alBufferData(ID, data.format, data.data, data.samplerate);
          data.dispose();
      } catch (FileNotFoundException e) {
          JOptionPane.showMessageDialog(null, "Could not find \"" + name + "\"", "IO Exception", JOptionPane.ERROR_MESSAGE);
          Display.destroy();
          System.exit(1);
      }
  }
  
  public void play(float x, float y, float z) {
      playSound(ID, new Vector3f(x,y,z));
  }
  
  private static void playSound(int buffer, Vector3f pos) {
      while(alGetSourcei(Sources.get(currentsource), AL10.AL_SOURCE_STATE) == AL_PLAYING) {
          currentsource++;
          currentsource %= 10; //there are only 10 sources
      }
      alSourcei(Sources.get(currentsource), AL_BUFFER,   buffer );
      alSourcef(Sources.get(currentsource), AL_PITCH,    1.0f   );
      alSourcef(Sources.get(currentsource), AL_GAIN,     1.0f   );
      alSourcei(Sources.get(currentsource), AL_LOOPING,  AL_FALSE);
      alSourcef(Sources.get(currentsource), AL_REFERENCE_DISTANCE, 0);
      alSourcef(Sources.get(currentsource), AL_MAX_DISTANCE, 100);
  
      alSourcePlay(Sources.get(currentsource));
  }
  
  public static boolean hasLoaded(){return loaded;}
  </code></pre>
  
  <p>My suspicion is the playSound method, is there a better way of finding a non-playing source? and is there any attributes that I have not given it that would result in sounds not having any 3D attributes?</p>