annotate java/src/com/aurellem/send/AudioSend.java @ 13:92b416b4e027

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