Mercurial > audio-send
view java/src/com/aurellem/send/AudioSend.java @ 26:56f83c170251
adding hard-to-compile artifacts for other systems
author | Robert McIntyre <rlm@mit.edu> |
---|---|
date | Sat, 19 Nov 2011 19:17:37 -0700 |
parents | 22ac5a0367cd |
children |
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 which16 * will be copies to all other contexts. It must be called17 * before any calls to <code>addListener();</code>18 */19 public void initDevice(){20 ninitDevice(this.deviceID);}21 public static native void ninitDevice(long device);23 /**24 * The send device does not automatically process sound. This25 * step function will cause the desired number of samples to26 * be processed for each listener. The results will then be27 * available via calls to <code>getSamples()</code> for each28 * listener.29 * @param samples30 */31 public void step(int samples){32 nstep(this.deviceID, samples);}33 public static native void nstep(long device, int samples);35 /**36 * Retrieve the final rendered sound for a particular37 * listener. <code>contextNum == 0</code> is the main LWJGL38 * context.39 * @param buffer40 * @param samples41 * @param contextNum42 */43 public void getSamples(ByteBuffer buffer,44 int samples, int contextNum){45 ngetSamples(this.deviceID, buffer,46 buffer.position(), samples, contextNum);}47 public static native void48 ngetSamples(long device, ByteBuffer buffer,49 int position, int samples, int contextNum);51 /**52 * Create an additional listener on the recorder device. The53 * device itself will manage this listener and synchronize it54 * with the main LWJGL context. Processed sound samples for55 * this listener will be available via a call to56 * <code>getSamples()</code> with <code>contextNum</code>57 * equal to the number of times this method has been called.58 */59 public void addListener(){naddListener(this.deviceID);}60 public static native void naddListener(long device);62 /**63 * This will internally call <code>alListener3f<code> in the64 * appropriate slave context and update that context's65 * listener's parameters. Calling this for a number greater66 * than the current number of slave contexts will have no67 * effect.68 * @param pname69 * @param v170 * @param v271 * @param v372 * @param contextNum73 */74 public void75 setNthListener3f(int pname, float v1,76 float v2, float v3, int contextNum){77 nsetNthListener3f(pname, v1, v2, v3,78 this.deviceID, contextNum);}79 public static native void80 nsetNthListener3f(int pname, float v1, float v2,81 float v3, long device, int contextNum);83 /**84 * This will internally call <code>alListenerf<code> in the85 * appropriate slave context and update that context's86 * listener's parameters. Calling this for a number greater87 * than the current number of slave contexts will have no88 * effect.89 * @param pname90 * @param v191 * @param contextNum92 */93 public void setNthListenerf(int pname, float v1, int contextNum){94 nsetNthListenerf(pname, v1, this.deviceID, contextNum);}95 public static native void96 nsetNthListenerf(int pname, float v1,97 long device, int contextNum);99 /**100 * Retrieve the AudioFormat which the device is using. This101 * format is itself derived from the OpenAL config file under102 * the "format" variable.103 */104 public AudioFormat getAudioFormat(){105 return ngetAudioFormat(this.deviceID);}106 public static native AudioFormat ngetAudioFormat(long device);107 }