comparison java/src/com/aurellem/send/AudioSend.java @ 19:22ac5a0367cd

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