rlm@7: package com.aurellem.send; rlm@7: rlm@7: import java.nio.ByteBuffer; rlm@7: rlm@13: import javax.sound.sampled.AudioFormat; rlm@13: rlm@7: public class AudioSend { rlm@7: rlm@7: private final long deviceID; rlm@7: rlm@7: public AudioSend(long deviceID){ rlm@7: this.deviceID = deviceID; rlm@7: } rlm@7: rlm@7: /** This establishes the LWJGL context as the context which will be copies to all rlm@7: * other contexts. It must be called before any calls to addListener(); rlm@7: */ rlm@7: public void initDevice(){ rlm@7: ninitDevice(this.deviceID);} rlm@7: public static native void ninitDevice(long device); rlm@7: rlm@7: /** rlm@7: * The send device does not automatically process sound. This step function will cause rlm@7: * the desired number of samples to be processed for each listener. The results will then rlm@7: * be available via calls to getSamples() for each listener. rlm@7: * @param samples rlm@7: */ rlm@7: public void step(int samples){ rlm@7: nstep(this.deviceID, samples);} rlm@7: public static native void nstep(long device, int samples); rlm@7: rlm@7: /** rlm@7: * Retrieve the final rendered sound for a particular listener. contextNum == 0 rlm@7: * is the main LWJGL context. rlm@7: * @param buffer rlm@7: * @param samples rlm@7: * @param contextNum rlm@7: */ rlm@7: public void getSamples(ByteBuffer buffer, int samples, int contextNum){ rlm@7: ngetSamples(this.deviceID, buffer, buffer.position(), samples, contextNum);} rlm@7: public static native void ngetSamples( rlm@7: long device, ByteBuffer buffer, int position, int samples, int contextNum); rlm@7: rlm@7: /** rlm@7: * Create an additional listener on the recorder device. The device itself will manage rlm@7: * this listener and synchronize it with the main LWJGL context. Processed sound samples rlm@7: * for this listener will be available via a call to getSamples() with rlm@7: * contextNum equal to the number of times this method has been called. rlm@7: */ rlm@7: public void addListener(){naddListener(this.deviceID);} rlm@7: public static native void naddListener(long device); rlm@7: rlm@7: /** rlm@7: * This will internally call alListener3f in the appropriate slave context and update rlm@7: * that context's listener's parameters. Calling this for a number greater than the current rlm@7: * number of slave contexts will have no effect. rlm@7: * @param pname rlm@7: * @param v1 rlm@7: * @param v2 rlm@7: * @param v3 rlm@7: * @param contextNum rlm@7: */ rlm@7: public void setNthListener3f(int pname, float v1, float v2, float v3, int contextNum){ rlm@7: nsetNthListener3f(pname, v1, v2, v3, this.deviceID, contextNum);} rlm@7: public static native void rlm@7: nsetNthListener3f(int pname, float v1, float v2, float v3, long device, int contextNum); rlm@7: rlm@7: /** rlm@7: * This will internally call alListenerf in the appropriate slave context and update rlm@7: * that context's listener's parameters. Calling this for a number greater than the current rlm@7: * number of slave contexts will have no effect. rlm@7: * @param pname rlm@7: * @param v1 rlm@7: * @param contextNum rlm@7: */ rlm@7: public void setNthListenerf(int pname, float v1, int contextNum){ rlm@7: nsetNthListenerf(pname, v1, this.deviceID, contextNum);} rlm@7: public static native void nsetNthListenerf(int pname, float v1, long device, int contextNum); rlm@7: rlm@13: rlm@13: /** rlm@13: * Retrieve the AudioFormat which the device is using. This format is itself derived rlm@13: * from the OpenAL config file under the "format" variable. rlm@13: */ rlm@13: public AudioFormat getAudioFormat(){ rlm@13: return ngetAudioFormat(this.deviceID);} rlm@13: public static native AudioFormat ngetAudioFormat(long device); rlm@13: rlm@13: rlm@13: rlm@7: }