private void setSourceBuffer(int i) {
        if (disabled)
            return;
        SoundObject obj = soundObjects.get(i);
        OggDecoder oggDecoder = new OggDecoder();

        ByteBuffer databuffer = ByteBufferBuffer.alloc(2048 * 2048);
        try {
            InputStream f = Loader.getRequiredResourceAsStream(obj.filename);
            int offset = 0;
            int remaining = databuffer.remaining();
            while (true) {
                if (remaining <= 0)
                    throw new RuntimeException();
                int len = f.read(databuffer.array(), databuffer.arrayOffset() + offset, remaining);
                if (len < 0)
                    break;
                remaining -= len;
                offset += len;
            }
            databuffer.position(offset);
            databuffer.flip();
            f.close();
        } catch (IOException e) {
            e.printStackTrace();
            return;
        }

        byte[] data = new byte[databuffer.remaining()];
        databuffer.get(data);

        // Decode OGG into PCM
        InputStream inputStream = new ByteArrayInputStream(data);

        OggData oggData;
        try {
            oggData = oggDecoder.getData(inputStream);
        } catch (IOException e) {
            e.printStackTrace();
            return;
        }

        int sourceID = source.get(i);
        int bufferID = buffer.get(i);

        // Load PCM data into buffer
        AL10.alBufferData(
                bufferID,
                oggData.channels > 1 ?
                        AL10.AL_FORMAT_STEREO16 : AL10.AL_FORMAT_MONO16,
                oggData.data,
                oggData.rate);

        int error = AL10.alGetError();
        if (error != AL10.AL_NO_ERROR) {
            System.err.println("AL error. " + error);
            return;
        }

        AL10.alSourcei(sourceID, AL10.AL_BUFFER, bufferID);
        AL10.alSourcef(sourceID, AL10.AL_PITCH, 1.0f);
        AL10.alSourcef(sourceID, AL10.AL_GAIN, 1.0f);

        if (obj.type == SoundType.Music) {
            AL10.alSourcei(sourceID, AL10.AL_LOOPING, AL10.AL_TRUE);
        } else {
            AL10.alSourcei(sourceID, AL10.AL_LOOPING, AL10.AL_FALSE);
        }
    }