Mercurial > audio-send
view java/src/com/aurellem/send/AudioSend.java @ 15:19ff95c69cf5
moved send.c to org file
author | Robert McIntyre <rlm@mit.edu> |
---|---|
date | Thu, 03 Nov 2011 12:08:39 -0700 |
parents | 92b416b4e027 |
children | 22ac5a0367cd |
line wrap: on
line source
1 package com.aurellem.send;3 import java.nio.ByteBuffer;5 import javax.sound.sampled.AudioFormat;7 public class AudioSend {9 private final long deviceID;11 public AudioSend(long deviceID){12 this.deviceID = deviceID;13 }15 /** This establishes the LWJGL context as the context which will be copies to all16 * other contexts. It must be called before any calls to <code>addListener();</code>17 */18 public void initDevice(){19 ninitDevice(this.deviceID);}20 public static native void ninitDevice(long device);22 /**23 * The send device does not automatically process sound. This step function will cause24 * the desired number of samples to be processed for each listener. The results will then25 * be available via calls to <code>getSamples()</code> for each listener.26 * @param samples27 */28 public void step(int samples){29 nstep(this.deviceID, samples);}30 public static native void nstep(long device, int samples);32 /**33 * Retrieve the final rendered sound for a particular listener. <code>contextNum == 0</code>34 * is the main LWJGL context.35 * @param buffer36 * @param samples37 * @param contextNum38 */39 public void getSamples(ByteBuffer buffer, int samples, int contextNum){40 ngetSamples(this.deviceID, buffer, buffer.position(), samples, contextNum);}41 public static native void ngetSamples(42 long device, ByteBuffer buffer, int position, int samples, int contextNum);44 /**45 * Create an additional listener on the recorder device. The device itself will manage46 * this listener and synchronize it with the main LWJGL context. Processed sound samples47 * for this listener will be available via a call to <code>getSamples()</code> with48 * <code>contextNum</code> equal to the number of times this method has been called.49 */50 public void addListener(){naddListener(this.deviceID);}51 public static native void naddListener(long device);53 /**54 * This will internally call <code>alListener3f<code> in the appropriate slave context and update55 * that context's listener's parameters. Calling this for a number greater than the current56 * number of slave contexts will have no effect.57 * @param pname58 * @param v159 * @param v260 * @param v361 * @param contextNum62 */63 public void setNthListener3f(int pname, float v1, float v2, float v3, int contextNum){64 nsetNthListener3f(pname, v1, v2, v3, this.deviceID, contextNum);}65 public static native void66 nsetNthListener3f(int pname, float v1, float v2, float v3, long device, int contextNum);68 /**69 * This will internally call <code>alListenerf<code> in the appropriate slave context and update70 * that context's listener's parameters. Calling this for a number greater than the current71 * number of slave contexts will have no effect.72 * @param pname73 * @param v174 * @param contextNum75 */76 public void setNthListenerf(int pname, float v1, int contextNum){77 nsetNthListenerf(pname, v1, this.deviceID, contextNum);}78 public static native void nsetNthListenerf(int pname, float v1, long device, int contextNum);81 /**82 * Retrieve the AudioFormat which the device is using. This format is itself derived83 * from the OpenAL config file under the "format" variable.84 */85 public AudioFormat getAudioFormat(){86 return ngetAudioFormat(this.deviceID);}87 public static native AudioFormat ngetAudioFormat(long device);91 }