annotate java/src/com/aurellem/send/AudioSend.java @ 7:37f25cb34196

transferred native interface for send.c to this project
author Robert McIntyre <rlm@mit.edu>
date Wed, 26 Oct 2011 10:42:15 -0700
parents
children 92b416b4e027
rev   line source
rlm@7 1 package com.aurellem.send;
rlm@7 2
rlm@7 3 import java.nio.ByteBuffer;
rlm@7 4
rlm@7 5 public class AudioSend {
rlm@7 6
rlm@7 7 private final long deviceID;
rlm@7 8
rlm@7 9 public AudioSend(long deviceID){
rlm@7 10 this.deviceID = deviceID;
rlm@7 11 }
rlm@7 12
rlm@7 13 /** This establishes the LWJGL context as the context which will be copies to all
rlm@7 14 * other contexts. It must be called before any calls to <code>addListener();</code>
rlm@7 15 */
rlm@7 16 public void initDevice(){
rlm@7 17 ninitDevice(this.deviceID);}
rlm@7 18 public static native void ninitDevice(long device);
rlm@7 19
rlm@7 20 /**
rlm@7 21 * The send device does not automatically process sound. This step function will cause
rlm@7 22 * the desired number of samples to be processed for each listener. The results will then
rlm@7 23 * be available via calls to <code>getSamples()</code> for each listener.
rlm@7 24 * @param samples
rlm@7 25 */
rlm@7 26 public void step(int samples){
rlm@7 27 nstep(this.deviceID, samples);}
rlm@7 28 public static native void nstep(long device, int samples);
rlm@7 29
rlm@7 30 /**
rlm@7 31 * Retrieve the final rendered sound for a particular listener. <code>contextNum == 0</code>
rlm@7 32 * is the main LWJGL context.
rlm@7 33 * @param buffer
rlm@7 34 * @param samples
rlm@7 35 * @param contextNum
rlm@7 36 */
rlm@7 37 public void getSamples(ByteBuffer buffer, int samples, int contextNum){
rlm@7 38 ngetSamples(this.deviceID, buffer, buffer.position(), samples, contextNum);}
rlm@7 39 public static native void ngetSamples(
rlm@7 40 long device, ByteBuffer buffer, int position, int samples, int contextNum);
rlm@7 41
rlm@7 42 /**
rlm@7 43 * Create an additional listener on the recorder device. The device itself will manage
rlm@7 44 * this listener and synchronize it with the main LWJGL context. Processed sound samples
rlm@7 45 * for this listener will be available via a call to <code>getSamples()</code> with
rlm@7 46 * <code>contextNum</code> equal to the number of times this method has been called.
rlm@7 47 */
rlm@7 48 public void addListener(){naddListener(this.deviceID);}
rlm@7 49 public static native void naddListener(long device);
rlm@7 50
rlm@7 51 /**
rlm@7 52 * This will internally call <code>alListener3f<code> in the appropriate slave context and update
rlm@7 53 * that context's listener's parameters. Calling this for a number greater than the current
rlm@7 54 * number of slave contexts will have no effect.
rlm@7 55 * @param pname
rlm@7 56 * @param v1
rlm@7 57 * @param v2
rlm@7 58 * @param v3
rlm@7 59 * @param contextNum
rlm@7 60 */
rlm@7 61 public void setNthListener3f(int pname, float v1, float v2, float v3, int contextNum){
rlm@7 62 nsetNthListener3f(pname, v1, v2, v3, this.deviceID, contextNum);}
rlm@7 63 public static native void
rlm@7 64 nsetNthListener3f(int pname, float v1, float v2, float v3, long device, int contextNum);
rlm@7 65
rlm@7 66 /**
rlm@7 67 * This will internally call <code>alListenerf<code> in the appropriate slave context and update
rlm@7 68 * that context's listener's parameters. Calling this for a number greater than the current
rlm@7 69 * number of slave contexts will have no effect.
rlm@7 70 * @param pname
rlm@7 71 * @param v1
rlm@7 72 * @param contextNum
rlm@7 73 */
rlm@7 74 public void setNthListenerf(int pname, float v1, int contextNum){
rlm@7 75 nsetNthListenerf(pname, v1, this.deviceID, contextNum);}
rlm@7 76 public static native void nsetNthListenerf(int pname, float v1, long device, int contextNum);
rlm@7 77
rlm@7 78 }