Mercurial > audio-send
view java/src/com/aurellem/send/AudioSend.java @ 11:17ace5a879b2 hardcoded_but_working
fixed JNI include problem
author | Robert McIntyre <rlm@mit.edu> |
---|---|
date | Fri, 28 Oct 2011 00:27:59 -0700 |
parents | 37f25cb34196 |
children | 92b416b4e027 |
line wrap: on
line source
1 package com.aurellem.send;3 import java.nio.ByteBuffer;5 public class AudioSend {7 private final long deviceID;9 public AudioSend(long deviceID){10 this.deviceID = deviceID;11 }13 /** This establishes the LWJGL context as the context which will be copies to all14 * other contexts. It must be called before any calls to <code>addListener();</code>15 */16 public void initDevice(){17 ninitDevice(this.deviceID);}18 public static native void ninitDevice(long device);20 /**21 * The send device does not automatically process sound. This step function will cause22 * the desired number of samples to be processed for each listener. The results will then23 * be available via calls to <code>getSamples()</code> for each listener.24 * @param samples25 */26 public void step(int samples){27 nstep(this.deviceID, samples);}28 public static native void nstep(long device, int samples);30 /**31 * Retrieve the final rendered sound for a particular listener. <code>contextNum == 0</code>32 * is the main LWJGL context.33 * @param buffer34 * @param samples35 * @param contextNum36 */37 public void getSamples(ByteBuffer buffer, int samples, int contextNum){38 ngetSamples(this.deviceID, buffer, buffer.position(), samples, contextNum);}39 public static native void ngetSamples(40 long device, ByteBuffer buffer, int position, int samples, int contextNum);42 /**43 * Create an additional listener on the recorder device. The device itself will manage44 * this listener and synchronize it with the main LWJGL context. Processed sound samples45 * for this listener will be available via a call to <code>getSamples()</code> with46 * <code>contextNum</code> equal to the number of times this method has been called.47 */48 public void addListener(){naddListener(this.deviceID);}49 public static native void naddListener(long device);51 /**52 * This will internally call <code>alListener3f<code> in the appropriate slave context and update53 * that context's listener's parameters. Calling this for a number greater than the current54 * number of slave contexts will have no effect.55 * @param pname56 * @param v157 * @param v258 * @param v359 * @param contextNum60 */61 public void setNthListener3f(int pname, float v1, float v2, float v3, int contextNum){62 nsetNthListener3f(pname, v1, v2, v3, this.deviceID, contextNum);}63 public static native void64 nsetNthListener3f(int pname, float v1, float v2, float v3, long device, int contextNum);66 /**67 * This will internally call <code>alListenerf<code> in the appropriate slave context and update68 * that context's listener's parameters. Calling this for a number greater than the current69 * number of slave contexts will have no effect.70 * @param pname71 * @param v172 * @param contextNum73 */74 public void setNthListenerf(int pname, float v1, int contextNum){75 nsetNthListenerf(pname, v1, this.deviceID, contextNum);}76 public static native void nsetNthListenerf(int pname, float v1, long device, int contextNum);78 }