I'm pretty new to OpenAL and I can't really get my head around it, so you will probably find the answer pretty obvious

I would also be really thankful if you could explain a little bit more on in which order to do things and why it doesn't work

Here's my code:
import java.io.BufferedInputStream;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.nio.IntBuffer;
import java.util.ArrayList;
import org.lwjgl.BufferUtils;
import org.lwjgl.openal.AL;
import org.lwjgl.util.WaveData;
import static org.lwjgl.openal.AL10.*;
public class AudioManager{
private Main M;
private IntBuffer buffer = BufferUtils.createIntBuffer(1);
private IntBuffer source = BufferUtils.createIntBuffer(128);
private ArrayList<WaveData> waveFiles = new ArrayList<WaveData>();
public AudioManager(Main M){
this.M=M;
try{
AL.create();
}catch(Exception e){
e.printStackTrace();
}
initializeAudio();
}
private void initializeAudio(){
alGenBuffers(buffer);
try{
waveFiles.add(WaveData.create(new BufferedInputStream(new FileInputStream("res/audio/music.wav"))));
}catch(Exception e){e.printStackTrace();}
for(int i=0;i<waveFiles.size();i++){
alBufferData(buffer.get(i), waveFiles.get(i).format, waveFiles.get(i).data, waveFiles.get(i).samplerate);
waveFiles.get(i).dispose();
}
}
public void playSound(int i, boolean b, float x, float y, float z){
alGenSources(source);
alSourcei(source.get(i), AL_BUFFER, buffer.get(i));
alSourcef(source.get(i), AL_PITCH, 1);
alSourcef(source.get(i), AL_GAIN, 3);
alSource3f(source.get(i), AL_POSITION, x, y, z);
alSource3f(source.get(i), AL_VELOCITY, 0, 0, 0);
if(b)alSourcei(source.get(i), AL_LOOPING, AL_TRUE);
else alSourcei(source.get(i), AL_LOOPING, AL_FALSE);
alSourcePlay(source.get(i));
}
public void setListener(){
alListener3f(AL_POSITION, M.C.getX(), M.C.getY(), M.C.getZ());
alListener3f(AL_VELOCITY, 0, 0, 0);
alListener3f(AL_ORIENTATION, 0, 0, 0);
}
}
And here is my game loop:
public void gameLoop(){
AM.setListener();
AM.playSound(0, true, C.getX(), C.getY(), C.getZ());
while(!Display.isCloseRequested()){
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
AM.setListener();
C.draw3D();
glLoadIdentity();
C.useView();
R.render();
IM.update();
C.draw2D();
glLoadIdentity();
R.render2D();
Display.update();
Display.sync(70);
}
}
The problem is that I can't hear the sound :/ And I'm sure that I've done something really stupid

If you wonder what M.C.getX(); getY() and getZ() does it's basicly returning the player's position, or to be more exact, the listening point.
Thanks in advance!
