view java/src/com/aurellem/send/AudioSend.java @ 28:1fc162d84343

updated README
author Robert McIntyre <rlm@mit.edu>
date Sat, 19 Nov 2011 20:09:50 -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 which
16 * will be copies to all other contexts. It must be called
17 * 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. This
25 * step function will cause the desired number of samples to
26 * be processed for each listener. The results will then be
27 * available via calls to <code>getSamples()</code> for each
28 * listener.
29 * @param samples
30 */
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 particular
37 * listener. <code>contextNum == 0</code> is the main LWJGL
38 * context.
39 * @param buffer
40 * @param samples
41 * @param contextNum
42 */
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 void
48 ngetSamples(long device, ByteBuffer buffer,
49 int position, int samples, int contextNum);
51 /**
52 * Create an additional listener on the recorder device. The
53 * device itself will manage this listener and synchronize it
54 * with the main LWJGL context. Processed sound samples for
55 * this listener will be available via a call to
56 * <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 the
64 * appropriate slave context and update that context's
65 * listener's parameters. Calling this for a number greater
66 * than the current number of slave contexts will have no
67 * effect.
68 * @param pname
69 * @param v1
70 * @param v2
71 * @param v3
72 * @param contextNum
73 */
74 public void
75 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 void
80 nsetNthListener3f(int pname, float v1, float v2,
81 float v3, long device, int contextNum);
83 /**
84 * This will internally call <code>alListenerf<code> in the
85 * appropriate slave context and update that context's
86 * listener's parameters. Calling this for a number greater
87 * than the current number of slave contexts will have no
88 * effect.
89 * @param pname
90 * @param v1
91 * @param contextNum
92 */
93 public void setNthListenerf(int pname, float v1, int contextNum){
94 nsetNthListenerf(pname, v1, this.deviceID, contextNum);}
95 public static native void
96 nsetNthListenerf(int pname, float v1,
97 long device, int contextNum);
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);
107 }