OpenAL position data type

hello all…

i is just playing around with the OpenAL cool stuff. I have got it playing audio and stuff. Just wondering how i set the position of the sound?

i take it the call should take 3 floats but i cant see a call that will let me do that. can anyone help me out?

rock and roll…

al.source3f(source, property, x, y, z);

where property is AL.POSITION

Cas :slight_smile:

yep i got it working :).

just wondered how i send stuff to:

al.sourcefv(int, int, int);

shouldnt it be:

al.sourcefv(int, int, float[]);

? if not how to i send an array of floats to ‘sourcefv’ ?

top tops anyways. - just wondered.

Not if you want LWJGL to be FAST!

We use ByteBuffers to transfer between Java and the Native side. Pack you floats into a ByteBuffer, and pass the position of those floats long.

Check
http://java-game-lib.sourceforge.net/documents/openal_c-to-java.html
for more info

That last parameter would be the address of a FloatBuffer. Do something like:

// Do this bit once - it's computationally expensive
FloatBuffer fb = ByteBuffer.allocateDirect(3 * 4).order(ByteOrder.nativeOrder()).asFloatBuffer() ;
int address = Sys.getDirectBufferAddress(fb) ;

// Fill the buffer whenever
fb.rewind() ;
fb.put(1.0f).put(0.5f).put(0.3f) ;

// Call the method with the address of the buffer
al.sourcefv(source, property, address) ;

what the numbers in:

allocateDirect(3 * 4) ?

faster is it? ok but i update the positions every time so i guess there wont be much of a speed leep.

will do anyways looks cooler :slight_smile:

[quote] allocateDirect(3 * 4) ?
[/quote]
allocateDirect needs to be told how many bytes it should allocate = 3 floats of each 4 bytes.

cool :slight_smile: i was looking at the wrong docs. part of java.nio - i just started playing with at. cool - it seems very fast at io… well i guess thats what everyone is on about :slight_smile: