Using openAL

I tried using the skeleton code for openAL but these lines didnt make any sense to me or the compiler:

//create one IntBuffer as buffer and one as source
IntBuffer buffers = createIntBuffer(1);
IntBuffer sources = createIntBuffer(1);

Also, is it hard to load orbis files instead of wave files? I want to have one stream with background music and one to play effects… can you mix it that way?
Any code samples would be appreciated :slight_smile:

[quote]but these lines didnt make any sense to me or the compiler:
[/quote]
It’s just a utility method located in:
org.lwjgl.test.openal.BasicTest


    /**
     * Creates an integer buffer to hold specified ints
     * - strictly a utility method
     *
     * @param size how many int to contain
     * @return created IntBuffer
     */
    protected IntBuffer createIntBuffer(int size) {
        ByteBuffer temp = ByteBuffer.allocateDirect(4*size);
        temp.order(ByteOrder.nativeOrder());
        
        return temp.asIntBuffer();
    }

[quote] Also, is it hard to load orbis files instead of wave files?
[/quote]
Nope - however oal only plays PCM audio, so you need to decode the ogg files to PCM first, and then load them directly:
Go to http://www.jcraft.com/jorbis/index.html and download the jorbis package
Familiarize yourself with it
take any ogg file, and decode it using the VorbisFile class - save the raw data, and play that directly with openal.

http://sourceforge.net/projects/spgl also have some OpenAL stuff in there…(http://cvs.sourceforge.net/cgi-bin/viewcvs.cgi/spgl/spgl/src/com/shavenpuppy/jglib/sound/)

hope this gets you started

Ok, thanks :slight_smile:

Jorbis has become part of the SPGL now :wink: All the sound in A.F. is oggs.

Cas :slight_smile:

I think I could use to write something simple myself really… Not that I dont like your work princec but I think using lwjgl is just enough, otherwise my software will be mostly written by you :slight_smile:

Soon ALL software will be written by me! Muahahaha! (etc)

Cas :slight_smile: