diff java/src/com/aurellem/send/AudioSend.java @ 7:37f25cb34196

transferred native interface for send.c to this project
author Robert McIntyre <rlm@mit.edu>
date Wed, 26 Oct 2011 10:42:15 -0700
parents
children 92b416b4e027
line wrap: on
line diff
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/java/src/com/aurellem/send/AudioSend.java	Wed Oct 26 10:42:15 2011 -0700
     1.3 @@ -0,0 +1,78 @@
     1.4 +package com.aurellem.send;
     1.5 +
     1.6 +import java.nio.ByteBuffer;
     1.7 +
     1.8 +public class AudioSend {
     1.9 +
    1.10 +	private final long deviceID;
    1.11 +	
    1.12 +	public AudioSend(long deviceID){
    1.13 +		this.deviceID = deviceID;
    1.14 +	}
    1.15 +	
    1.16 +	/** This establishes the LWJGL context as the context which will be copies to all 
    1.17 +	 *  other contexts.  It must be called before any calls to <code>addListener();</code>
    1.18 +	 */
    1.19 +	public void initDevice(){
    1.20 +		ninitDevice(this.deviceID);}
    1.21 +	public static native void ninitDevice(long device);
    1.22 +	
    1.23 +	/**
    1.24 +	 * The send device does not automatically process sound.  This step function will cause 
    1.25 +	 * the desired number of samples to be processed for each listener.  The results will then 
    1.26 +	 * be available via calls to <code>getSamples()</code> for each listener.
    1.27 +	 * @param samples
    1.28 +	 */
    1.29 +	public void step(int samples){
    1.30 +		nstep(this.deviceID, samples);}
    1.31 +	public static native void nstep(long device, int samples);
    1.32 +
    1.33 +	/**
    1.34 +	 * Retrieve the final rendered sound for a particular listener.  <code>contextNum == 0</code>
    1.35 +	 * is the main LWJGL context.
    1.36 +	 * @param buffer
    1.37 +	 * @param samples
    1.38 +	 * @param contextNum
    1.39 +	 */
    1.40 +	public void getSamples(ByteBuffer buffer, int samples, int contextNum){
    1.41 +		ngetSamples(this.deviceID, buffer, buffer.position(), samples, contextNum);}
    1.42 +	public static native void ngetSamples(
    1.43 +			long device, ByteBuffer buffer, int position, int samples, int contextNum);
    1.44 +	
    1.45 +	/**
    1.46 +	 * Create an additional listener on the recorder device.  The device itself will manage 
    1.47 +	 * this listener and synchronize it with the main LWJGL context. Processed sound samples
    1.48 +	 * for this listener will be available via a call to <code>getSamples()</code> with 
    1.49 +	 * <code>contextNum</code> equal to the number of times this method has been called. 
    1.50 +	 */
    1.51 +	public void addListener(){naddListener(this.deviceID);}
    1.52 +	public static native void naddListener(long device);
    1.53 +	
    1.54 +	/**
    1.55 +	 * This will internally call <code>alListener3f<code> in the appropriate slave context and update
    1.56 +	 * that context's listener's parameters. Calling this for a number greater than the current 
    1.57 +	 * number of slave contexts will have no effect.
    1.58 +	 * @param pname
    1.59 +	 * @param v1
    1.60 +	 * @param v2
    1.61 +	 * @param v3
    1.62 +	 * @param contextNum
    1.63 +	 */
    1.64 +	public void setNthListener3f(int pname, float v1, float v2, float v3, int contextNum){
    1.65 +		nsetNthListener3f(pname, v1, v2, v3, this.deviceID, contextNum);}
    1.66 +	public static native void 
    1.67 +	nsetNthListener3f(int pname, float v1, float v2, float v3, long device, int contextNum);
    1.68 +	
    1.69 +	/**
    1.70 +	 * This will internally call <code>alListenerf<code> in the appropriate slave context and update
    1.71 +	 * that context's listener's parameters. Calling this for a number greater than the current 
    1.72 +	 * number of slave contexts will have no effect.
    1.73 +	 * @param pname
    1.74 +	 * @param v1
    1.75 +	 * @param contextNum
    1.76 +	 */
    1.77 +	public void setNthListenerf(int pname, float v1, int contextNum){
    1.78 +		nsetNthListenerf(pname, v1, this.deviceID, contextNum);}
    1.79 +	public static native void nsetNthListenerf(int pname, float v1, long device, int contextNum);
    1.80 +	
    1.81 +}