From a4dd0ad63c00f4dee3b86dfd3075d1d61b2b3180 Mon Sep 17 00:00:00 2001 From: sanine Date: Sat, 27 Aug 2022 23:52:56 -0500 Subject: add plibsys --- .../java/c/src/com_portaudio_BlockingStream.c | 352 ++++++++++++++ .../java/c/src/com_portaudio_BlockingStream.h | 130 +++++ .../bindings/java/c/src/com_portaudio_PortAudio.c | 279 +++++++++++ .../bindings/java/c/src/com_portaudio_PortAudio.h | 183 +++++++ 3rdparty/portaudio/bindings/java/c/src/jpa_tools.c | 208 ++++++++ 3rdparty/portaudio/bindings/java/c/src/jpa_tools.h | 62 +++ 3rdparty/portaudio/bindings/java/jportaudio.dox | 65 +++ .../portaudio/bindings/java/jportaudio/.classpath | 8 + .../portaudio/bindings/java/jportaudio/.project | 17 + .../jportaudio/jtests/com/portaudio/PlaySine.java | 89 ++++ .../jportaudio/jtests/com/portaudio/TestBasic.java | 523 +++++++++++++++++++++ .../src/com/portaudio/BlockingStream.java | 208 ++++++++ .../jportaudio/src/com/portaudio/DeviceInfo.java | 65 +++ .../jportaudio/src/com/portaudio/HostApiInfo.java | 61 +++ .../jportaudio/src/com/portaudio/PortAudio.java | 261 ++++++++++ .../jportaudio/src/com/portaudio/StreamInfo.java | 60 +++ .../src/com/portaudio/StreamParameters.java | 57 +++ .../bindings/java/scripts/make_header.bat | 4 + 18 files changed, 2632 insertions(+) create mode 100644 3rdparty/portaudio/bindings/java/c/src/com_portaudio_BlockingStream.c create mode 100644 3rdparty/portaudio/bindings/java/c/src/com_portaudio_BlockingStream.h create mode 100644 3rdparty/portaudio/bindings/java/c/src/com_portaudio_PortAudio.c create mode 100644 3rdparty/portaudio/bindings/java/c/src/com_portaudio_PortAudio.h create mode 100644 3rdparty/portaudio/bindings/java/c/src/jpa_tools.c create mode 100644 3rdparty/portaudio/bindings/java/c/src/jpa_tools.h create mode 100644 3rdparty/portaudio/bindings/java/jportaudio.dox create mode 100644 3rdparty/portaudio/bindings/java/jportaudio/.classpath create mode 100644 3rdparty/portaudio/bindings/java/jportaudio/.project create mode 100644 3rdparty/portaudio/bindings/java/jportaudio/jtests/com/portaudio/PlaySine.java create mode 100644 3rdparty/portaudio/bindings/java/jportaudio/jtests/com/portaudio/TestBasic.java create mode 100644 3rdparty/portaudio/bindings/java/jportaudio/src/com/portaudio/BlockingStream.java create mode 100644 3rdparty/portaudio/bindings/java/jportaudio/src/com/portaudio/DeviceInfo.java create mode 100644 3rdparty/portaudio/bindings/java/jportaudio/src/com/portaudio/HostApiInfo.java create mode 100644 3rdparty/portaudio/bindings/java/jportaudio/src/com/portaudio/PortAudio.java create mode 100644 3rdparty/portaudio/bindings/java/jportaudio/src/com/portaudio/StreamInfo.java create mode 100644 3rdparty/portaudio/bindings/java/jportaudio/src/com/portaudio/StreamParameters.java create mode 100644 3rdparty/portaudio/bindings/java/scripts/make_header.bat (limited to '3rdparty/portaudio/bindings/java') diff --git a/3rdparty/portaudio/bindings/java/c/src/com_portaudio_BlockingStream.c b/3rdparty/portaudio/bindings/java/c/src/com_portaudio_BlockingStream.c new file mode 100644 index 0000000..64d8213 --- /dev/null +++ b/3rdparty/portaudio/bindings/java/c/src/com_portaudio_BlockingStream.c @@ -0,0 +1,352 @@ +/* + * Portable Audio I/O Library + * Java Binding for PortAudio + * + * Based on the Open Source API proposed by Ross Bencina + * Copyright (c) 2008 Ross Bencina + * + * Permission is hereby granted, free of charge, to any person obtaining + * a copy of this software and associated documentation files + * (the "Software"), to deal in the Software without restriction, + * including without limitation the rights to use, copy, modify, merge, + * publish, distribute, sublicense, and/or sell copies of the Software, + * and to permit persons to whom the Software is furnished to do so, + * subject to the following conditions: + * + * The above copyright notice and this permission notice shall be + * included in all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. + * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR + * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF + * CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION + * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ + +/* + * The text above constitutes the entire PortAudio license; however, + * the PortAudio community also makes the following non-binding requests: + * + * Any person wishing to distribute modifications to the Software is + * requested to send the modifications to the original developer so that + * they can be incorporated into the canonical version. It is also + * requested that these non-binding requests be included along with the + * license above. + */ + +#include "com_portaudio_BlockingStream.h" +#include "portaudio.h" +#include "jpa_tools.h" + +#ifndef FALSE +#define FALSE (0) +#endif +#ifndef TRUE +#define TRUE (!FALSE) +#endif + +/* + * Class: com_portaudio_BlockingStream + * Method: getReadAvailable + * Signature: ()I + */ +JNIEXPORT jint JNICALL Java_com_portaudio_BlockingStream_getReadAvailable + (JNIEnv *env, jobject blockingStream) +{ + PaStream *stream =jpa_GetStreamPointer( env, blockingStream ); + if( stream == NULL ) return 0; + return Pa_GetStreamReadAvailable( stream ); +} + +/* + * Class: com_portaudio_BlockingStream + * Method: getWriteAvailable + * Signature: ()I + */ +JNIEXPORT jint JNICALL Java_com_portaudio_BlockingStream_getWriteAvailable + (JNIEnv *env, jobject blockingStream) +{ + PaStream *stream =jpa_GetStreamPointer( env, blockingStream ); + if( stream == NULL ) return 0; + return Pa_GetStreamWriteAvailable( stream ); +} + + +/* + * Class: com_portaudio_BlockingStream + * Method: writeFloats + * Signature: ([FI)Z + */ +JNIEXPORT jboolean JNICALL Java_com_portaudio_BlockingStream_writeFloats + (JNIEnv *env, jobject blockingStream, jfloatArray buffer, jint numFrames) +{ + jfloat *carr; + jint err; + PaStream *stream =jpa_GetStreamPointer( env, blockingStream ); + if( buffer == NULL ) + { + (*env)->ThrowNew( env, (*env)->FindClass(env,"java/lang/RuntimeException"), + "null stream buffer"); + return FALSE; + } + carr = (*env)->GetFloatArrayElements(env, buffer, NULL); + if (carr == NULL) + { + (*env)->ThrowNew( env, (*env)->FindClass(env,"java/lang/RuntimeException"), + "invalid stream buffer"); + return FALSE; + } + err = Pa_WriteStream( stream, carr, numFrames ); + (*env)->ReleaseFloatArrayElements(env, buffer, carr, 0); + if( err == paOutputUnderflowed ) + { + return TRUE; + } + else + { + jpa_CheckError( env, err ); + return FALSE; + } +} + +/* + * Class: com_portaudio_BlockingStream + * Method: readFloats + * Signature: ([FI)Z + */ +JNIEXPORT jboolean JNICALL Java_com_portaudio_BlockingStream_readFloats + (JNIEnv *env, jobject blockingStream, jfloatArray buffer, jint numFrames) +{ + jfloat *carr; + jint err; + PaStream *stream =jpa_GetStreamPointer( env, blockingStream ); + if( buffer == NULL ) + { + (*env)->ThrowNew( env, (*env)->FindClass(env,"java/lang/RuntimeException"), + "null stream buffer"); + return FALSE; + } + carr = (*env)->GetFloatArrayElements(env, buffer, NULL); + if (carr == NULL) + { + (*env)->ThrowNew( env, (*env)->FindClass(env,"java/lang/RuntimeException"), + "invalid stream buffer"); + return FALSE; + } + err = Pa_ReadStream( stream, carr, numFrames ); + (*env)->ReleaseFloatArrayElements(env, buffer, carr, 0); + if( err == paInputOverflowed ) + { + return TRUE; + } + else + { + jpa_CheckError( env, err ); + return FALSE; + } +} + +/* + * Class: com_portaudio_BlockingStream + * Method: writeShorts + * Signature: ([SI)Z + */ +JNIEXPORT jboolean JNICALL Java_com_portaudio_BlockingStream_writeShorts + (JNIEnv *env, jobject blockingStream, jfloatArray buffer, jint numFrames) +{ + jshort *carr; + jint err; + PaStream *stream =jpa_GetStreamPointer( env, blockingStream ); + if( buffer == NULL ) + { + (*env)->ThrowNew( env, (*env)->FindClass(env,"java/lang/RuntimeException"), + "null stream buffer"); + return FALSE; + } + carr = (*env)->GetShortArrayElements(env, buffer, NULL); + if (carr == NULL) + { + (*env)->ThrowNew( env, (*env)->FindClass(env,"java/lang/RuntimeException"), + "invalid stream buffer"); + return FALSE; + } + err = Pa_WriteStream( stream, carr, numFrames ); + (*env)->ReleaseShortArrayElements(env, buffer, carr, 0); + if( err == paOutputUnderflowed ) + { + return TRUE; + } + else + { + jpa_CheckError( env, err ); + return FALSE; + } +} + +/* + * Class: com_portaudio_BlockingStream + * Method: readShorts + * Signature: ([SI)Z + */ +JNIEXPORT jboolean JNICALL Java_com_portaudio_BlockingStream_readShorts + (JNIEnv *env, jobject blockingStream, jfloatArray buffer, jint numFrames) +{ + jshort *carr; + jint err; + PaStream *stream =jpa_GetStreamPointer( env, blockingStream ); + if( buffer == NULL ) + { + (*env)->ThrowNew( env, (*env)->FindClass(env,"java/lang/RuntimeException"), + "null stream buffer"); + return FALSE; + } + carr = (*env)->GetShortArrayElements(env, buffer, NULL); + if (carr == NULL) + { + (*env)->ThrowNew( env, (*env)->FindClass(env,"java/lang/RuntimeException"), + "invalid stream buffer"); + return FALSE; + } + err = Pa_ReadStream( stream, carr, numFrames ); + (*env)->ReleaseShortArrayElements(env, buffer, carr, 0); + if( err == paInputOverflowed ) + { + return TRUE; + } + else + { + jpa_CheckError( env, err ); + return FALSE; + } +} + +/* + * Class: com_portaudio_BlockingStream + * Method: start + * Signature: ()V + */ +JNIEXPORT void JNICALL Java_com_portaudio_BlockingStream_start + (JNIEnv *env, jobject blockingStream ) +{ + PaStream *stream = jpa_GetStreamPointer( env, blockingStream ); + int err = Pa_StartStream( stream ); + jpa_CheckError( env, err ); +} + +/* + * Class: com_portaudio_BlockingStream + * Method: stop + * Signature: ()V + */ +JNIEXPORT void JNICALL Java_com_portaudio_BlockingStream_stop + (JNIEnv *env, jobject blockingStream ) +{ + PaStream *stream =jpa_GetStreamPointer( env, blockingStream ); + int err = Pa_StopStream( stream ); + jpa_CheckError( env, err ); +} +/* + * Class: com_portaudio_BlockingStream + * Method: abort + * Signature: ()V + */ +JNIEXPORT void JNICALL Java_com_portaudio_BlockingStream_abort + (JNIEnv *env, jobject blockingStream ) +{ + PaStream *stream =jpa_GetStreamPointer( env, blockingStream ); + int err = Pa_AbortStream( stream ); + jpa_CheckError( env, err ); +} + +/* + * Class: com_portaudio_BlockingStream + * Method: close + * Signature: ()V + */ +JNIEXPORT void JNICALL Java_com_portaudio_BlockingStream_close + (JNIEnv *env, jobject blockingStream ) +{ + jclass cls; + PaStream *stream =jpa_GetStreamPointer( env, blockingStream ); + if( stream != NULL ) + { + int err = Pa_CloseStream( stream ); + jpa_CheckError( env, err ); + cls = (*env)->GetObjectClass(env, blockingStream); + jpa_SetLongField( env, cls, blockingStream, "nativeStream", (jlong) 0 ); + } +} + +/* + * Class: com_portaudio_BlockingStream + * Method: isStopped + * Signature: ()V + */ +JNIEXPORT jboolean JNICALL Java_com_portaudio_BlockingStream_isStopped + (JNIEnv *env, jobject blockingStream ) +{ + int err; + PaStream *stream =jpa_GetStreamPointer( env, blockingStream ); + if( stream == NULL ) return 1; + err = Pa_IsStreamStopped( stream ); + return (jpa_CheckError( env, err ) > 0); +} +/* + * Class: com_portaudio_BlockingStream + * Method: isActive + * Signature: ()V + */ +JNIEXPORT jboolean JNICALL Java_com_portaudio_BlockingStream_isActive + (JNIEnv *env, jobject blockingStream ) +{ + int err; + PaStream *stream =jpa_GetStreamPointer( env, blockingStream ); + if( stream == NULL ) return 0; + err = Pa_IsStreamActive( stream ); + return (jpa_CheckError( env, err ) > 0); +} + + +/* + * Class: com_portaudio_BlockingStream + * Method: getTime + * Signature: ()D + */ +JNIEXPORT jdouble JNICALL Java_com_portaudio_BlockingStream_getTime + (JNIEnv *env, jobject blockingStream ) +{ + PaStream *stream =jpa_GetStreamPointer( env, blockingStream ); + if( stream == NULL ) return 0.0; + return Pa_GetStreamTime( stream ); +} + + +/* + * Class: com_portaudio_BlockingStream + * Method: getInfo + * Signature: ()Lcom/portaudio/StreamInfo; + */ +JNIEXPORT void JNICALL Java_com_portaudio_BlockingStream_getInfo + (JNIEnv *env, jobject blockingStream, jobject streamInfo) +{ + + PaStream *stream =jpa_GetStreamPointer( env, blockingStream ); + const PaStreamInfo *info = Pa_GetStreamInfo( stream ); + if( streamInfo == NULL ) + { + jpa_ThrowError( env, "Invalid stream." ); + } + else + { + /* Get a reference to obj's class */ + jclass cls = (*env)->GetObjectClass(env, streamInfo); + + jpa_SetIntField( env, cls, streamInfo, "structVersion", info->structVersion ); + jpa_SetDoubleField( env, cls, streamInfo, "inputLatency", info->inputLatency ); + jpa_SetDoubleField( env, cls, streamInfo, "outputLatency", info->outputLatency ); + jpa_SetDoubleField( env, cls, streamInfo, "sampleRate", info->sampleRate ); + } +} + diff --git a/3rdparty/portaudio/bindings/java/c/src/com_portaudio_BlockingStream.h b/3rdparty/portaudio/bindings/java/c/src/com_portaudio_BlockingStream.h new file mode 100644 index 0000000..e405fae --- /dev/null +++ b/3rdparty/portaudio/bindings/java/c/src/com_portaudio_BlockingStream.h @@ -0,0 +1,130 @@ +/* DO NOT EDIT THIS FILE - it is machine generated */ +#if defined(__APPLE__) +#include +#else +#include +#endif + +/* Header for class com_portaudio_BlockingStream */ + +#ifndef _Included_com_portaudio_BlockingStream +#define _Included_com_portaudio_BlockingStream +#ifdef __cplusplus +extern "C" { +#endif +/* + * Class: com_portaudio_BlockingStream + * Method: getReadAvailable + * Signature: ()I + */ +JNIEXPORT jint JNICALL Java_com_portaudio_BlockingStream_getReadAvailable + (JNIEnv *, jobject); + +/* + * Class: com_portaudio_BlockingStream + * Method: getWriteAvailable + * Signature: ()I + */ +JNIEXPORT jint JNICALL Java_com_portaudio_BlockingStream_getWriteAvailable + (JNIEnv *, jobject); + +/* + * Class: com_portaudio_BlockingStream + * Method: readFloats + * Signature: ([FI)Z + */ +JNIEXPORT jboolean JNICALL Java_com_portaudio_BlockingStream_readFloats + (JNIEnv *, jobject, jfloatArray, jint); + +/* + * Class: com_portaudio_BlockingStream + * Method: writeFloats + * Signature: ([FI)Z + */ +JNIEXPORT jboolean JNICALL Java_com_portaudio_BlockingStream_writeFloats + (JNIEnv *, jobject, jfloatArray, jint); + +/* + * Class: com_portaudio_BlockingStream + * Method: readShorts + * Signature: ([SI)Z + */ +JNIEXPORT jboolean JNICALL Java_com_portaudio_BlockingStream_readShorts + (JNIEnv *, jobject, jshortArray, jint); + +/* + * Class: com_portaudio_BlockingStream + * Method: writeShorts + * Signature: ([SI)Z + */ +JNIEXPORT jboolean JNICALL Java_com_portaudio_BlockingStream_writeShorts + (JNIEnv *, jobject, jshortArray, jint); + +/* + * Class: com_portaudio_BlockingStream + * Method: start + * Signature: ()V + */ +JNIEXPORT void JNICALL Java_com_portaudio_BlockingStream_start + (JNIEnv *, jobject); + +/* + * Class: com_portaudio_BlockingStream + * Method: stop + * Signature: ()V + */ +JNIEXPORT void JNICALL Java_com_portaudio_BlockingStream_stop + (JNIEnv *, jobject); + +/* + * Class: com_portaudio_BlockingStream + * Method: abort + * Signature: ()V + */ +JNIEXPORT void JNICALL Java_com_portaudio_BlockingStream_abort + (JNIEnv *, jobject); + +/* + * Class: com_portaudio_BlockingStream + * Method: close + * Signature: ()V + */ +JNIEXPORT void JNICALL Java_com_portaudio_BlockingStream_close + (JNIEnv *, jobject); + +/* + * Class: com_portaudio_BlockingStream + * Method: isStopped + * Signature: ()Z + */ +JNIEXPORT jboolean JNICALL Java_com_portaudio_BlockingStream_isStopped + (JNIEnv *, jobject); + +/* + * Class: com_portaudio_BlockingStream + * Method: isActive + * Signature: ()Z + */ +JNIEXPORT jboolean JNICALL Java_com_portaudio_BlockingStream_isActive + (JNIEnv *, jobject); + +/* + * Class: com_portaudio_BlockingStream + * Method: getTime + * Signature: ()D + */ +JNIEXPORT jdouble JNICALL Java_com_portaudio_BlockingStream_getTime + (JNIEnv *, jobject); + +/* + * Class: com_portaudio_BlockingStream + * Method: getInfo + * Signature: (Lcom/portaudio/StreamInfo;)V + */ +JNIEXPORT void JNICALL Java_com_portaudio_BlockingStream_getInfo + (JNIEnv *, jobject, jobject); + +#ifdef __cplusplus +} +#endif +#endif diff --git a/3rdparty/portaudio/bindings/java/c/src/com_portaudio_PortAudio.c b/3rdparty/portaudio/bindings/java/c/src/com_portaudio_PortAudio.c new file mode 100644 index 0000000..77c42eb --- /dev/null +++ b/3rdparty/portaudio/bindings/java/c/src/com_portaudio_PortAudio.c @@ -0,0 +1,279 @@ +/* + * Portable Audio I/O Library + * Java Binding for PortAudio + * + * Based on the Open Source API proposed by Ross Bencina + * Copyright (c) 2008 Ross Bencina + * + * Permission is hereby granted, free of charge, to any person obtaining + * a copy of this software and associated documentation files + * (the "Software"), to deal in the Software without restriction, + * including without limitation the rights to use, copy, modify, merge, + * publish, distribute, sublicense, and/or sell copies of the Software, + * and to permit persons to whom the Software is furnished to do so, + * subject to the following conditions: + * + * The above copyright notice and this permission notice shall be + * included in all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. + * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR + * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF + * CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION + * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ + +/* + * The text above constitutes the entire PortAudio license; however, + * the PortAudio community also makes the following non-binding requests: + * + * Any person wishing to distribute modifications to the Software is + * requested to send the modifications to the original developer so that + * they can be incorporated into the canonical version. It is also + * requested that these non-binding requests be included along with the + * license above. + */ + +#include "com_portaudio_PortAudio.h" +#include "portaudio.h" +#include "jpa_tools.h" + +/* + * Class: com_portaudio_PortAudio + * Method: getVersion + * Signature: ()I + */ +JNIEXPORT jint JNICALL Java_com_portaudio_PortAudio_getVersion + (JNIEnv *env, jclass clazz) +{ + return Pa_GetVersion(); +} + +/* + * Class: com_portaudio_PortAudio + * Method: getVersionText + * Signature: ()Ljava/lang/String; + */ +JNIEXPORT jstring JNICALL Java_com_portaudio_PortAudio_getVersionText + (JNIEnv *env, jclass clazz) +{ + return (*env)->NewStringUTF(env, Pa_GetVersionText() ); +} + +/* + * Class: com_portaudio_PortAudio + * Method: initialize + * Signature: ()I + */ +JNIEXPORT void JNICALL Java_com_portaudio_PortAudio_initialize + (JNIEnv *env, jclass clazz) +{ + PaError err = Pa_Initialize(); + jpa_CheckError( env, err ); +} + +/* + * Class: com_portaudio_PortAudio + * Method: terminate + * Signature: ()I + */ +JNIEXPORT void JNICALL Java_com_portaudio_PortAudio_terminate + (JNIEnv *env, jclass clazz) +{ + PaError err = Pa_Terminate(); + jpa_CheckError( env, err ); +} + +/* + * Class: com_portaudio_PortAudio + * Method: getDeviceCount + * Signature: ()I + */ +JNIEXPORT jint JNICALL Java_com_portaudio_PortAudio_getDeviceCount + (JNIEnv *env, jclass clazz) +{ + jint count = Pa_GetDeviceCount(); + return jpa_CheckError( env, count ); +} + +/* + * Class: com_portaudio_PortAudio + * Method: getDeviceInfo + * Signature: (ILcom/portaudio/DeviceInfo;)I + */ +JNIEXPORT void JNICALL Java_com_portaudio_PortAudio_getDeviceInfo + (JNIEnv *env, jclass clazz, jint index, jobject deviceInfo) +{ + const PaDeviceInfo *info; + /* Get a reference to obj's class */ + jclass cls = (*env)->GetObjectClass(env, deviceInfo); + + info = Pa_GetDeviceInfo( index ); + if( info == NULL ) + { + jpa_ThrowError( env, "Pa_GetDeviceInfo returned NULL." ); + } + else + { + jpa_SetStringField( env, cls, deviceInfo, "name", info->name ); + jpa_SetIntField( env, cls, deviceInfo, "maxInputChannels", info->maxInputChannels ); + jpa_SetIntField( env, cls, deviceInfo, "maxOutputChannels", info->maxOutputChannels ); + jpa_SetIntField( env, cls, deviceInfo, "hostApi", info->hostApi ); + jpa_SetDoubleField( env, cls, deviceInfo, "defaultSampleRate", info->defaultSampleRate ); + jpa_SetDoubleField( env, cls, deviceInfo, "defaultLowInputLatency", info->defaultLowInputLatency ); + jpa_SetDoubleField( env, cls, deviceInfo, "defaultLowInputLatency", info->defaultHighInputLatency ); + jpa_SetDoubleField( env, cls, deviceInfo, "defaultLowOutputLatency", info->defaultLowOutputLatency ); + jpa_SetDoubleField( env, cls, deviceInfo, "defaultHighOutputLatency", info->defaultHighOutputLatency ); + } +} + +/* + * Class: com_portaudio_PortAudio + * Method: geHostApiCount + * Signature: ()I + */ +JNIEXPORT jint JNICALL Java_com_portaudio_PortAudio_getHostApiCount + (JNIEnv *env, jclass clazz) +{ + jint count = Pa_GetHostApiCount(); + return jpa_CheckError( env, count ); +} + + +/* + * Class: com_portaudio_PortAudio + * Method: hostApiTypeIdToHostApiIndex + * Signature: (I)I + */ +JNIEXPORT jint JNICALL Java_com_portaudio_PortAudio_hostApiTypeIdToHostApiIndex + (JNIEnv *env, jclass clazz, jint hostApiType) +{ + return Pa_HostApiTypeIdToHostApiIndex( (PaHostApiTypeId) hostApiType ); +} + +/* + * Class: com_portaudio_PortAudio + * Method: hostApiDeviceIndexToDeviceIndex + * Signature: (II)I + */ +JNIEXPORT jint JNICALL Java_com_portaudio_PortAudio_hostApiDeviceIndexToDeviceIndex + (JNIEnv *env, jclass clazz, jint hostApiIndex, jint apiDeviceIndex) +{ + return Pa_HostApiDeviceIndexToDeviceIndex( hostApiIndex, apiDeviceIndex ); +} + + +/* + * Class: com_portaudio_PortAudio + * Method: getHostApiInfo + * Signature: (ILcom/portaudio/HostApiInfo;)I + */ +JNIEXPORT void JNICALL Java_com_portaudio_PortAudio_getHostApiInfo + (JNIEnv *env, jclass clazz, jint index, jobject hostApiInfo) +{ + const PaHostApiInfo *info; + /* Get a reference to obj's class */ + jclass cls = (*env)->GetObjectClass(env, hostApiInfo); + + info = Pa_GetHostApiInfo( index ); + if( info == NULL ) + { + jpa_ThrowError( env, "Pa_GetHostApiInfo returned NULL." ); + } + else + { + jpa_SetIntField( env, cls, hostApiInfo, "version", info->structVersion ); + jpa_SetIntField( env, cls, hostApiInfo, "type", info->type ); + jpa_SetStringField( env, cls, hostApiInfo, "name", info->name ); + jpa_SetIntField( env, cls, hostApiInfo, "deviceCount", info->deviceCount ); + jpa_SetIntField( env, cls, hostApiInfo, "defaultInputDevice", info->defaultInputDevice ); + jpa_SetIntField( env, cls, hostApiInfo, "defaultOutputDevice", info->defaultOutputDevice ); + } +} + +/* + * Class: com_portaudio_PortAudio + * Method: getDefaultInputDevice + * Signature: ()I + */ +JNIEXPORT jint JNICALL Java_com_portaudio_PortAudio_getDefaultInputDevice + (JNIEnv *env, jclass clazz) +{ + jint deviceId = Pa_GetDefaultInputDevice(); + return jpa_CheckError( env, deviceId ); +} + +/* + * Class: com_portaudio_PortAudio + * Method: getDefaultOutputDevice + * Signature: ()I + */ +JNIEXPORT jint JNICALL Java_com_portaudio_PortAudio_getDefaultOutputDevice + (JNIEnv *env, jclass clazz) +{ + jint deviceId = Pa_GetDefaultOutputDevice(); + return jpa_CheckError( env, deviceId ); +} + +/* + * Class: com_portaudio_PortAudio + * Method: getDefaultHostApi + * Signature: ()I + */ +JNIEXPORT jint JNICALL Java_com_portaudio_PortAudio_getDefaultHostApi + (JNIEnv *env, jclass clazz) +{ + jint deviceId = Pa_GetDefaultHostApi(); + return jpa_CheckError( env, deviceId ); +} + +/* + * Class: com_portaudio_PortAudio + * Method: isFormatSupported + * Signature: (Lcom/portaudio/StreamParameters;Lcom/portaudio/StreamParameters;I)I + */ +JNIEXPORT jint JNICALL Java_com_portaudio_PortAudio_isFormatSupported + (JNIEnv *env, jclass clazz, jobject inParams, jobject outParams, jint sampleRate ) +{ + PaStreamParameters myInParams, *paInParams; + PaStreamParameters myOutParams, *paOutParams; + + paInParams = jpa_FillStreamParameters( env, inParams, &myInParams ); + paOutParams = jpa_FillStreamParameters( env, outParams, &myOutParams ); + + return Pa_IsFormatSupported( paInParams, paOutParams, sampleRate ); + +} + +/* + * Class: com_portaudio_PortAudio + * Method: openStream + * Signature: (Lcom/portaudio/BlockingStream;Lcom/portaudio/StreamParameters;Lcom/portaudio/StreamParameters;III)I + */ +JNIEXPORT void JNICALL Java_com_portaudio_PortAudio_openStream + (JNIEnv *env, jclass clazz, jobject blockingStream, jobject inParams, jobject outParams, jint sampleRate, jint framesPerBuffer, jint flags ) +{ + int err; + PaStreamParameters myInParams, *paInParams; + PaStreamParameters myOutParams, *paOutParams; + PaStream *stream; + + paInParams = jpa_FillStreamParameters( env, inParams, &myInParams ); + paOutParams = jpa_FillStreamParameters( env, outParams, &myOutParams ); + err = Pa_OpenStream( &stream, paInParams, paOutParams, sampleRate, framesPerBuffer, flags, NULL, NULL ); + if( jpa_CheckError( env, err ) == 0 ) + { + jclass cls = (*env)->GetObjectClass(env, blockingStream); + jpa_SetLongField( env, cls, blockingStream, "nativeStream", (jlong) stream ); + if( paInParams != NULL ) + { + jpa_SetIntField( env, cls, blockingStream, "inputFormat", paInParams->sampleFormat ); + } + if( paOutParams != NULL ) + { + jpa_SetIntField( env, cls, blockingStream, "outputFormat", paOutParams->sampleFormat ); + } + } +} diff --git a/3rdparty/portaudio/bindings/java/c/src/com_portaudio_PortAudio.h b/3rdparty/portaudio/bindings/java/c/src/com_portaudio_PortAudio.h new file mode 100644 index 0000000..ed806ac --- /dev/null +++ b/3rdparty/portaudio/bindings/java/c/src/com_portaudio_PortAudio.h @@ -0,0 +1,183 @@ +/* DO NOT EDIT THIS FILE - it is machine generated */ +#if defined(__APPLE__) +#include +#else +#include +#endif +/* Header for class com_portaudio_PortAudio */ + +#ifndef _Included_com_portaudio_PortAudio +#define _Included_com_portaudio_PortAudio +#ifdef __cplusplus +extern "C" { +#endif +#undef com_portaudio_PortAudio_FLAG_CLIP_OFF +#define com_portaudio_PortAudio_FLAG_CLIP_OFF 1L +#undef com_portaudio_PortAudio_FLAG_DITHER_OFF +#define com_portaudio_PortAudio_FLAG_DITHER_OFF 2L +#undef com_portaudio_PortAudio_FORMAT_FLOAT_32 +#define com_portaudio_PortAudio_FORMAT_FLOAT_32 1L +#undef com_portaudio_PortAudio_FORMAT_INT_32 +#define com_portaudio_PortAudio_FORMAT_INT_32 2L +#undef com_portaudio_PortAudio_FORMAT_INT_24 +#define com_portaudio_PortAudio_FORMAT_INT_24 4L +#undef com_portaudio_PortAudio_FORMAT_INT_16 +#define com_portaudio_PortAudio_FORMAT_INT_16 8L +#undef com_portaudio_PortAudio_FORMAT_INT_8 +#define com_portaudio_PortAudio_FORMAT_INT_8 16L +#undef com_portaudio_PortAudio_FORMAT_UINT_8 +#define com_portaudio_PortAudio_FORMAT_UINT_8 32L +#undef com_portaudio_PortAudio_HOST_API_TYPE_DEV +#define com_portaudio_PortAudio_HOST_API_TYPE_DEV 0L +#undef com_portaudio_PortAudio_HOST_API_TYPE_DIRECTSOUND +#define com_portaudio_PortAudio_HOST_API_TYPE_DIRECTSOUND 1L +#undef com_portaudio_PortAudio_HOST_API_TYPE_MME +#define com_portaudio_PortAudio_HOST_API_TYPE_MME 2L +#undef com_portaudio_PortAudio_HOST_API_TYPE_ASIO +#define com_portaudio_PortAudio_HOST_API_TYPE_ASIO 3L +#undef com_portaudio_PortAudio_HOST_API_TYPE_SOUNDMANAGER +#define com_portaudio_PortAudio_HOST_API_TYPE_SOUNDMANAGER 4L +#undef com_portaudio_PortAudio_HOST_API_TYPE_COREAUDIO +#define com_portaudio_PortAudio_HOST_API_TYPE_COREAUDIO 5L +#undef com_portaudio_PortAudio_HOST_API_TYPE_OSS +#define com_portaudio_PortAudio_HOST_API_TYPE_OSS 7L +#undef com_portaudio_PortAudio_HOST_API_TYPE_ALSA +#define com_portaudio_PortAudio_HOST_API_TYPE_ALSA 8L +#undef com_portaudio_PortAudio_HOST_API_TYPE_AL +#define com_portaudio_PortAudio_HOST_API_TYPE_AL 9L +#undef com_portaudio_PortAudio_HOST_API_TYPE_BEOS +#define com_portaudio_PortAudio_HOST_API_TYPE_BEOS 10L +#undef com_portaudio_PortAudio_HOST_API_TYPE_WDMKS +#define com_portaudio_PortAudio_HOST_API_TYPE_WDMKS 11L +#undef com_portaudio_PortAudio_HOST_API_TYPE_JACK +#define com_portaudio_PortAudio_HOST_API_TYPE_JACK 12L +#undef com_portaudio_PortAudio_HOST_API_TYPE_WASAPI +#define com_portaudio_PortAudio_HOST_API_TYPE_WASAPI 13L +#undef com_portaudio_PortAudio_HOST_API_TYPE_AUDIOSCIENCE +#define com_portaudio_PortAudio_HOST_API_TYPE_AUDIOSCIENCE 14L +#undef com_portaudio_PortAudio_HOST_API_TYPE_COUNT +#define com_portaudio_PortAudio_HOST_API_TYPE_COUNT 15L +/* + * Class: com_portaudio_PortAudio + * Method: getVersion + * Signature: ()I + */ +JNIEXPORT jint JNICALL Java_com_portaudio_PortAudio_getVersion + (JNIEnv *, jclass); + +/* + * Class: com_portaudio_PortAudio + * Method: getVersionText + * Signature: ()Ljava/lang/String; + */ +JNIEXPORT jstring JNICALL Java_com_portaudio_PortAudio_getVersionText + (JNIEnv *, jclass); + +/* + * Class: com_portaudio_PortAudio + * Method: initialize + * Signature: ()V + */ +JNIEXPORT void JNICALL Java_com_portaudio_PortAudio_initialize + (JNIEnv *, jclass); + +/* + * Class: com_portaudio_PortAudio + * Method: terminate + * Signature: ()V + */ +JNIEXPORT void JNICALL Java_com_portaudio_PortAudio_terminate + (JNIEnv *, jclass); + +/* + * Class: com_portaudio_PortAudio + * Method: getDeviceCount + * Signature: ()I + */ +JNIEXPORT jint JNICALL Java_com_portaudio_PortAudio_getDeviceCount + (JNIEnv *, jclass); + +/* + * Class: com_portaudio_PortAudio + * Method: getDeviceInfo + * Signature: (ILcom/portaudio/DeviceInfo;)V + */ +JNIEXPORT void JNICALL Java_com_portaudio_PortAudio_getDeviceInfo + (JNIEnv *, jclass, jint, jobject); + +/* + * Class: com_portaudio_PortAudio + * Method: getHostApiCount + * Signature: ()I + */ +JNIEXPORT jint JNICALL Java_com_portaudio_PortAudio_getHostApiCount + (JNIEnv *, jclass); + +/* + * Class: com_portaudio_PortAudio + * Method: getHostApiInfo + * Signature: (ILcom/portaudio/HostApiInfo;)V + */ +JNIEXPORT void JNICALL Java_com_portaudio_PortAudio_getHostApiInfo + (JNIEnv *, jclass, jint, jobject); + +/* + * Class: com_portaudio_PortAudio + * Method: hostApiTypeIdToHostApiIndex + * Signature: (I)I + */ +JNIEXPORT jint JNICALL Java_com_portaudio_PortAudio_hostApiTypeIdToHostApiIndex + (JNIEnv *, jclass, jint); + +/* + * Class: com_portaudio_PortAudio + * Method: hostApiDeviceIndexToDeviceIndex + * Signature: (II)I + */ +JNIEXPORT jint JNICALL Java_com_portaudio_PortAudio_hostApiDeviceIndexToDeviceIndex + (JNIEnv *, jclass, jint, jint); + +/* + * Class: com_portaudio_PortAudio + * Method: getDefaultInputDevice + * Signature: ()I + */ +JNIEXPORT jint JNICALL Java_com_portaudio_PortAudio_getDefaultInputDevice + (JNIEnv *, jclass); + +/* + * Class: com_portaudio_PortAudio + * Method: getDefaultOutputDevice + * Signature: ()I + */ +JNIEXPORT jint JNICALL Java_com_portaudio_PortAudio_getDefaultOutputDevice + (JNIEnv *, jclass); + +/* + * Class: com_portaudio_PortAudio + * Method: getDefaultHostApi + * Signature: ()I + */ +JNIEXPORT jint JNICALL Java_com_portaudio_PortAudio_getDefaultHostApi + (JNIEnv *, jclass); + +/* + * Class: com_portaudio_PortAudio + * Method: isFormatSupported + * Signature: (Lcom/portaudio/StreamParameters;Lcom/portaudio/StreamParameters;I)I + */ +JNIEXPORT jint JNICALL Java_com_portaudio_PortAudio_isFormatSupported + (JNIEnv *, jclass, jobject, jobject, jint); + +/* + * Class: com_portaudio_PortAudio + * Method: openStream + * Signature: (Lcom/portaudio/BlockingStream;Lcom/portaudio/StreamParameters;Lcom/portaudio/StreamParameters;III)V + */ +JNIEXPORT void JNICALL Java_com_portaudio_PortAudio_openStream + (JNIEnv *, jclass, jobject, jobject, jobject, jint, jint, jint); + +#ifdef __cplusplus +} +#endif +#endif diff --git a/3rdparty/portaudio/bindings/java/c/src/jpa_tools.c b/3rdparty/portaudio/bindings/java/c/src/jpa_tools.c new file mode 100644 index 0000000..e3f903a --- /dev/null +++ b/3rdparty/portaudio/bindings/java/c/src/jpa_tools.c @@ -0,0 +1,208 @@ +/* + * Portable Audio I/O Library + * Java Binding for PortAudio + * + * Based on the Open Source API proposed by Ross Bencina + * Copyright (c) 2008 Ross Bencina + * + * Permission is hereby granted, free of charge, to any person obtaining + * a copy of this software and associated documentation files + * (the "Software"), to deal in the Software without restriction, + * including without limitation the rights to use, copy, modify, merge, + * publish, distribute, sublicense, and/or sell copies of the Software, + * and to permit persons to whom the Software is furnished to do so, + * subject to the following conditions: + * + * The above copyright notice and this permission notice shall be + * included in all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. + * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR + * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF + * CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION + * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ + +/* + * The text above constitutes the entire PortAudio license; however, + * the PortAudio community also makes the following non-binding requests: + * + * Any person wishing to distribute modifications to the Software is + * requested to send the modifications to the original developer so that + * they can be incorporated into the canonical version. It is also + * requested that these non-binding requests be included along with the + * license above. + */ + +#include "com_portaudio_PortAudio.h" +#include "portaudio.h" +#include "jpa_tools.h" + +jint jpa_GetIntField( JNIEnv *env, jclass cls, jobject obj, const char *fieldName ) +{ + /* Look for the instance field maxInputChannels in cls */ + jfieldID fid = (*env)->GetFieldID(env, cls, fieldName, "I"); + if (fid == NULL) + { + jpa_ThrowError( env, "Cannot find integer JNI field." ); + return 0; + } + else + { + return (*env)->GetIntField(env, obj, fid ); + } +} + +void jpa_SetIntField( JNIEnv *env, jclass cls, jobject obj, const char *fieldName, jint value ) +{ + /* Look for the instance field maxInputChannels in cls */ + jfieldID fid = (*env)->GetFieldID(env, cls, fieldName, "I"); + if (fid == NULL) + { + jpa_ThrowError( env, "Cannot find integer JNI field." ); + } + else + { + (*env)->SetIntField(env, obj, fid, value ); + } +} + +jlong jpa_GetLongField( JNIEnv *env, jclass cls, jobject obj, const char *fieldName ) +{ + /* Look for the instance field maxInputChannels in cls */ + jfieldID fid = (*env)->GetFieldID(env, cls, fieldName, "J"); + if (fid == NULL) + { + jpa_ThrowError( env, "Cannot find long JNI field." ); + return 0L; + } + else + { + return (*env)->GetLongField(env, obj, fid ); + } +} + +void jpa_SetLongField( JNIEnv *env, jclass cls, jobject obj, const char *fieldName, jlong value ) +{ + /* Look for the instance field maxInputChannels in cls */ + jfieldID fid = (*env)->GetFieldID(env, cls, fieldName, "J"); + if (fid == NULL) + { + jpa_ThrowError( env, "Cannot find long JNI field." ); + } + else + { + (*env)->SetLongField(env, obj, fid, value ); + } +} + + +void jpa_SetDoubleField( JNIEnv *env, jclass cls, jobject obj, const char *fieldName, jdouble value ) +{ + /* Look for the instance field maxInputChannels in cls */ + jfieldID fid = (*env)->GetFieldID(env, cls, fieldName, "D"); + if (fid == NULL) + { + jpa_ThrowError( env, "Cannot find double JNI field." ); + } + else + { + (*env)->SetDoubleField(env, obj, fid, value ); + } +} + + +jdouble jpa_GetDoubleField( JNIEnv *env, jclass cls, jobject obj, const char *fieldName ) +{ + /* Look for the instance field maxInputChannels in cls */ + jfieldID fid = (*env)->GetFieldID(env, cls, fieldName, "D"); + if (fid == NULL) + { + jpa_ThrowError( env, "Cannot find double JNI field." ); + return 0; + } + else + { + return (*env)->GetDoubleField(env, obj, fid ); + } +} + +void jpa_SetStringField( JNIEnv *env, jclass cls, jobject obj, const char *fieldName, const char *value ) +{ + /* Look for the instance field maxInputChannels in cls */ + jfieldID fid = (*env)->GetFieldID(env, cls, fieldName, "Ljava/lang/String;"); + if (fid == NULL) + { + jpa_ThrowError( env, "Cannot find String JNI field." ); + } + else + { + jstring jstr = (*env)->NewStringUTF(env, value); + if (jstr == NULL) + { + jpa_ThrowError( env, "Cannot create new String." ); + } + else + { + (*env)->SetObjectField(env, obj, fid, jstr ); + } + } +} + +PaStreamParameters *jpa_FillStreamParameters( JNIEnv *env, jobject jstreamParam, PaStreamParameters *myParams ) +{ + jclass cls; + + if( jstreamParam == NULL ) return NULL; // OK, not an error + + cls = (*env)->GetObjectClass(env, jstreamParam); + + myParams->channelCount = jpa_GetIntField( env, cls, jstreamParam, "channelCount" ); + myParams->device = jpa_GetIntField( env, cls, jstreamParam, "device" ); + myParams->sampleFormat = jpa_GetIntField( env, cls, jstreamParam, "sampleFormat" ); + myParams->suggestedLatency = jpa_GetDoubleField( env, cls, jstreamParam, "suggestedLatency" ); + myParams->hostApiSpecificStreamInfo = NULL; + + return myParams; +} + +// Create an exception that will be thrown when we return from the JNI call. +jint jpa_ThrowError( JNIEnv *env, const char *message ) +{ + return (*env)->ThrowNew(env, (*env)->FindClass( env, "java/lang/RuntimeException"), + message ); +} + +// Throw an exception on error. +jint jpa_CheckError( JNIEnv *env, PaError err ) +{ + if( err == -1 ) + { + return jpa_ThrowError( env, "-1, possibly no available default device" ); + } + else if( err < 0 ) + { + if( err == paUnanticipatedHostError ) + { + const PaHostErrorInfo *hostErrorInfo = Pa_GetLastHostErrorInfo(); + return jpa_ThrowError( env, hostErrorInfo->errorText ); + } + else + { + return jpa_ThrowError( env, Pa_GetErrorText( err ) ); + } + } + else + { + return err; + } +} + +// Get the stream pointer from a BlockingStream long field. +PaStream *jpa_GetStreamPointer( JNIEnv *env, jobject blockingStream ) +{ + jclass cls = (*env)->GetObjectClass(env, blockingStream); + return (PaStream *) jpa_GetLongField( env, cls, blockingStream, "nativeStream" ); +} diff --git a/3rdparty/portaudio/bindings/java/c/src/jpa_tools.h b/3rdparty/portaudio/bindings/java/c/src/jpa_tools.h new file mode 100644 index 0000000..11e724c --- /dev/null +++ b/3rdparty/portaudio/bindings/java/c/src/jpa_tools.h @@ -0,0 +1,62 @@ +/* + * Portable Audio I/O Library + * Java Binding for PortAudio + * + * Based on the Open Source API proposed by Ross Bencina + * Copyright (c) 2008 Ross Bencina + * + * Permission is hereby granted, free of charge, to any person obtaining + * a copy of this software and associated documentation files + * (the "Software"), to deal in the Software without restriction, + * including without limitation the rights to use, copy, modify, merge, + * publish, distribute, sublicense, and/or sell copies of the Software, + * and to permit persons to whom the Software is furnished to do so, + * subject to the following conditions: + * + * The above copyright notice and this permission notice shall be + * included in all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. + * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR + * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF + * CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION + * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ + +/* + * The text above constitutes the entire PortAudio license; however, + * the PortAudio community also makes the following non-binding requests: + * + * Any person wishing to distribute modifications to the Software is + * requested to send the modifications to the original developer so that + * they can be incorporated into the canonical version. It is also + * requested that these non-binding requests be included along with the + * license above. + */ + +#include "com_portaudio_PortAudio.h" +#include "portaudio.h" + +#ifndef JPA_TOOLS_H +#define JPA_TOOLS_H + +jint jpa_GetIntField( JNIEnv *env, jclass cls, jobject obj, const char *fieldName ); +void jpa_SetIntField( JNIEnv *env, jclass cls, jobject obj, const char *fieldName, jint value ); + +jlong jpa_GetLongField( JNIEnv *env, jclass cls, jobject obj, const char *fieldName ); +void jpa_SetLongField( JNIEnv *env, jclass cls, jobject obj, const char *fieldName, jlong value ); + +jdouble jpa_GetDoubleField( JNIEnv *env, jclass cls, jobject obj, const char *fieldName ); +void jpa_SetDoubleField( JNIEnv *env, jclass cls, jobject obj, const char *fieldName, jdouble value ); + +void jpa_SetStringField( JNIEnv *env, jclass cls, jobject obj, const char *fieldName, const char *value ); +PaStreamParameters *jpa_FillStreamParameters( JNIEnv *env, jobject jstreamParam, PaStreamParameters *myParams ); + +jint jpa_CheckError( JNIEnv *env, PaError err ); +jint jpa_ThrowError( JNIEnv *env, const char *message ); + +PaStream *jpa_GetStreamPointer( JNIEnv *env, jobject blockingStream ); + +#endif /* JPA_TOOLS_H */ diff --git a/3rdparty/portaudio/bindings/java/jportaudio.dox b/3rdparty/portaudio/bindings/java/jportaudio.dox new file mode 100644 index 0000000..f97b565 --- /dev/null +++ b/3rdparty/portaudio/bindings/java/jportaudio.dox @@ -0,0 +1,65 @@ +/** +@page java_binding JPortAudio Java Binding +@ingroup jportaudio + +Note: this page has not been reviewed, and may contain errors. + +@section java_draft DRAFT - IN PROGRESS + +9/4/12 JPortAudio is very new and should be considered an "alpha" release. +The building of JPortAudio will eventually be integrated into the Makefile as an optional build. + +Currently JPortAudio is only supported for Windows and Macintosh. Please contact us if you want to help with porting Linux. + +For reference documentation of the JPortAudio API see: com.portaudio.PortAudio + +For an example see: PlaySine.java + +@section java_comp_windows Building JPortAudio on Windows + +Build the Java code using the Eclipse project in "jportaudio". Export as "jportaudio.jar". + +If you modify the JNI API then you will need to regenerate the JNI .h files using: + +@code +cd bindings/java/scripts +make_header.bat +@endcode + +Build the JNI DLL using the Visual Studio 2010 solution in "java/c/build/vs2010/PortAudioJNI". + +@section java_use_windows Using JPortAudio on Windows + +Put the "jportaudio.jar" in the classpath for your application. +Place the following libraries where they can be found, typically in the same folder as your application. + +- portaudio_x86.dll +- portaudio_x64.dll +- jportaudio_x86.dll +- jportaudio_x64.dll + +@section java_comp_max Building JPortAudio on Mac + +These are notes from building JPortAudio on a Mac with 10.6.8 and XCode 4. + +I created a target of type 'C' library. + +I added the regular PortAudio frameworks plus the JavaVM framework. + +I modified com_portaudio_PortAudio.h and com_portaudio_BlockingStream.h so that jni.h could found. + +@code +#if defined(__APPLE__) +#include +#else +#include +#endif +@endcode + +This is bad because those header files are autogenerated and will be overwritten. +We need a better solution for this. + +I had trouble finding the "libjportaudio.jnilib". So I added a Build Phase that copied the library to "/Users/phil/Library/Java/Extensions". + +On the Mac we can create a universal library for both 32 and 64-bit JVMs. So in the JAR file I will open "jportaudio" on Apple. ON WIndows I will continue to open "jportaudio_x64" and "jportaudio_x86". +*/ diff --git a/3rdparty/portaudio/bindings/java/jportaudio/.classpath b/3rdparty/portaudio/bindings/java/jportaudio/.classpath new file mode 100644 index 0000000..6bbd70c --- /dev/null +++ b/3rdparty/portaudio/bindings/java/jportaudio/.classpath @@ -0,0 +1,8 @@ + + + + + + + + diff --git a/3rdparty/portaudio/bindings/java/jportaudio/.project b/3rdparty/portaudio/bindings/java/jportaudio/.project new file mode 100644 index 0000000..8d2a750 --- /dev/null +++ b/3rdparty/portaudio/bindings/java/jportaudio/.project @@ -0,0 +1,17 @@ + + + JPortAudio + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/3rdparty/portaudio/bindings/java/jportaudio/jtests/com/portaudio/PlaySine.java b/3rdparty/portaudio/bindings/java/jportaudio/jtests/com/portaudio/PlaySine.java new file mode 100644 index 0000000..ec2cb97 --- /dev/null +++ b/3rdparty/portaudio/bindings/java/jportaudio/jtests/com/portaudio/PlaySine.java @@ -0,0 +1,89 @@ + +/** @file + @ingroup bindings_java + + @brief Example that shows how to play sine waves using JPortAudio. +*/ +package com.portaudio; + +import com.portaudio.TestBasic.SineOscillator; + +public class PlaySine +{ + /** + * Write a sine wave to the stream. + * @param stream + * @param framesPerBuffer + * @param numFrames + * @param sampleRate + */ + private void writeSineData( BlockingStream stream, int framesPerBuffer, + int numFrames, int sampleRate ) + { + float[] buffer = new float[framesPerBuffer * 2]; + SineOscillator osc1 = new SineOscillator( 200.0, sampleRate ); + SineOscillator osc2 = new SineOscillator( 300.0, sampleRate ); + int framesLeft = numFrames; + while( framesLeft > 0 ) + { + int index = 0; + int framesToWrite = (framesLeft > framesPerBuffer) ? framesPerBuffer + : framesLeft; + for( int j = 0; j < framesToWrite; j++ ) + { + buffer[index++] = (float) osc1.next(); + buffer[index++] = (float) osc2.next(); + } + stream.write( buffer, framesToWrite ); + framesLeft -= framesToWrite; + } + } + + /** + * Create a stream on the default device then play sine waves. + */ + public void play() + { + PortAudio.initialize(); + + // Get the default device and setup the stream parameters. + int deviceId = PortAudio.getDefaultOutputDevice(); + DeviceInfo deviceInfo = PortAudio.getDeviceInfo( deviceId ); + double sampleRate = deviceInfo.defaultSampleRate; + System.out.println( " deviceId = " + deviceId ); + System.out.println( " sampleRate = " + sampleRate ); + System.out.println( " device name = " + deviceInfo.name ); + + StreamParameters streamParameters = new StreamParameters(); + streamParameters.channelCount = 2; + streamParameters.device = deviceId; + streamParameters.suggestedLatency = deviceInfo.defaultLowOutputLatency; + System.out.println( " suggestedLatency = " + + streamParameters.suggestedLatency ); + + int framesPerBuffer = 256; + int flags = 0; + + // Open a stream for output. + BlockingStream stream = PortAudio.openStream( null, streamParameters, + (int) sampleRate, framesPerBuffer, flags ); + + int numFrames = (int) (sampleRate * 4); // enough for 4 seconds + + stream.start(); + + writeSineData( stream, framesPerBuffer, numFrames, (int) sampleRate ); + + stream.stop(); + stream.close(); + + PortAudio.terminate(); + System.out.println( "JPortAudio test complete." ); + } + + public static void main( String[] args ) + { + PlaySine player = new PlaySine(); + player.play(); + } +} diff --git a/3rdparty/portaudio/bindings/java/jportaudio/jtests/com/portaudio/TestBasic.java b/3rdparty/portaudio/bindings/java/jportaudio/jtests/com/portaudio/TestBasic.java new file mode 100644 index 0000000..43b8fa7 --- /dev/null +++ b/3rdparty/portaudio/bindings/java/jportaudio/jtests/com/portaudio/TestBasic.java @@ -0,0 +1,523 @@ +/* + * Portable Audio I/O Library + * Java Binding for PortAudio + * + * Based on the Open Source API proposed by Ross Bencina + * Copyright (c) 2008 Ross Bencina + * + * Permission is hereby granted, free of charge, to any person obtaining + * a copy of this software and associated documentation files + * (the "Software"), to deal in the Software without restriction, + * including without limitation the rights to use, copy, modify, merge, + * publish, distribute, sublicense, and/or sell copies of the Software, + * and to permit persons to whom the Software is furnished to do so, + * subject to the following conditions: + * + * The above copyright notice and this permission notice shall be + * included in all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. + * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR + * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF + * CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION + * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ + +/* + * The text above constitutes the entire PortAudio license; however, + * the PortAudio community also makes the following non-binding requests: + * + * Any person wishing to distribute modifications to the Software is + * requested to send the modifications to the original developer so that + * they can be incorporated into the canonical version. It is also + * requested that these non-binding requests be included along with the + * license above. + */ + +package com.portaudio; + +import junit.framework.TestCase; + +/** + * Test the Java bindings for PortAudio. + * + * @author Phil Burk + * + */ +public class TestBasic extends TestCase +{ + + public void testDeviceCount() + { + PortAudio.initialize(); + assertTrue( "version invalid", (PortAudio.getVersion() > 0) ); + System.out.println( "getVersion = " + PortAudio.getVersion() ); + System.out.println( "getVersionText = " + PortAudio.getVersionText() ); + System.out.println( "getDeviceCount = " + PortAudio.getDeviceCount() ); + assertTrue( "getDeviceCount", (PortAudio.getDeviceCount() > 0) ); + PortAudio.terminate(); + } + + public void testListDevices() + { + PortAudio.initialize(); + int count = PortAudio.getDeviceCount(); + assertTrue( "getDeviceCount", (count > 0) ); + for( int i = 0; i < count; i++ ) + { + DeviceInfo info = PortAudio.getDeviceInfo( i ); + System.out.println( "------------------ #" + i ); + System.out.println( " name = " + info.name ); + System.out.println( " hostApi = " + info.hostApi ); + System.out.println( " maxOutputChannels = " + + info.maxOutputChannels ); + System.out.println( " maxInputChannels = " + + info.maxInputChannels ); + System.out.println( " defaultSampleRate = " + + info.defaultSampleRate ); + System.out.printf( " defaultLowInputLatency = %3d msec\n", + ((int) (info.defaultLowInputLatency * 1000)) ); + System.out.printf( " defaultHighInputLatency = %3d msec\n", + ((int) (info.defaultHighInputLatency * 1000)) ); + System.out.printf( " defaultLowOutputLatency = %3d msec\n", + ((int) (info.defaultLowOutputLatency * 1000)) ); + System.out.printf( " defaultHighOutputLatency = %3d msec\n", + ((int) (info.defaultHighOutputLatency * 1000)) ); + + assertTrue( "some channels", + (info.maxOutputChannels + info.maxInputChannels) > 0 ); + assertTrue( "not too many channels", (info.maxInputChannels < 64) ); + assertTrue( "not too many channels", (info.maxOutputChannels < 64) ); + } + + System.out.println( "defaultInput = " + + PortAudio.getDefaultInputDevice() ); + System.out.println( "defaultOutput = " + + PortAudio.getDefaultOutputDevice() ); + + PortAudio.terminate(); + } + + public void testHostApis() + { + PortAudio.initialize(); + int validApiCount = 0; + for( int hostApiType = 0; hostApiType < PortAudio.HOST_API_TYPE_COUNT; hostApiType++ ) + { + int hostApiIndex = PortAudio + .hostApiTypeIdToHostApiIndex( hostApiType ); + if( hostApiIndex >= 0 ) + { + HostApiInfo info = PortAudio.getHostApiInfo( hostApiIndex ); + System.out.println( "Checking Host API: " + info.name ); + for( int apiDeviceIndex = 0; apiDeviceIndex < info.deviceCount; apiDeviceIndex++ ) + { + int deviceIndex = PortAudio + .hostApiDeviceIndexToDeviceIndex( hostApiIndex, + apiDeviceIndex ); + DeviceInfo deviceInfo = PortAudio + .getDeviceInfo( deviceIndex ); + assertEquals( "host api must match up", hostApiIndex, + deviceInfo.hostApi ); + } + validApiCount++; + } + } + + assertEquals( "host api counts", PortAudio.getHostApiCount(), + validApiCount ); + } + + public void testListHostApis() + { + PortAudio.initialize(); + int count = PortAudio.getHostApiCount(); + assertTrue( "getHostApiCount", (count > 0) ); + for( int i = 0; i < count; i++ ) + { + HostApiInfo info = PortAudio.getHostApiInfo( i ); + System.out.println( "------------------ #" + i ); + System.out.println( " version = " + info.version ); + System.out.println( " name = " + info.name ); + System.out.println( " type = " + info.type ); + System.out.println( " deviceCount = " + info.deviceCount ); + System.out.println( " defaultInputDevice = " + + info.defaultInputDevice ); + System.out.println( " defaultOutputDevice = " + + info.defaultOutputDevice ); + assertTrue( "some devices", info.deviceCount > 0 ); + } + + System.out.println( "------\ndefaultHostApi = " + + PortAudio.getDefaultHostApi() ); + PortAudio.terminate(); + } + + public void testCheckFormat() + { + PortAudio.initialize(); + StreamParameters streamParameters = new StreamParameters(); + streamParameters.device = PortAudio.getDefaultOutputDevice(); + int result = PortAudio + .isFormatSupported( null, streamParameters, 44100 ); + System.out.println( "isFormatSupported returns " + result ); + assertEquals( "default output format", 0, result ); + // Try crazy channelCount + streamParameters.channelCount = 8765; + result = PortAudio.isFormatSupported( null, streamParameters, 44100 ); + System.out.println( "crazy isFormatSupported returns " + result ); + assertTrue( "default output format", (result < 0) ); + PortAudio.terminate(); + } + + static class SineOscillator + { + double phase = 0.0; + double phaseIncrement = 0.01; + + SineOscillator(double freq, int sampleRate) + { + phaseIncrement = freq * Math.PI * 2.0 / sampleRate; + } + + double next() + { + double value = Math.sin( phase ); + phase += phaseIncrement; + if( phase > Math.PI ) + { + phase -= Math.PI * 2.0; + } + return value; + } + } + + public void testStreamError() + { + PortAudio.initialize(); + StreamParameters streamParameters = new StreamParameters(); + streamParameters.sampleFormat = PortAudio.FORMAT_FLOAT_32; + streamParameters.channelCount = 2; + streamParameters.device = PortAudio.getDefaultOutputDevice(); + int framesPerBuffer = 256; + int flags = 0; + BlockingStream stream = PortAudio.openStream( null, streamParameters, + 44100, framesPerBuffer, flags ); + + // Try to write data to a stopped stream. + Throwable caught = null; + try + { + float[] buffer = new float[framesPerBuffer + * streamParameters.channelCount]; + stream.write( buffer, framesPerBuffer ); + } catch( Throwable e ) + { + caught = e; + e.printStackTrace(); + } + + assertTrue( "caught no exception", (caught != null) ); + assertTrue( "exception should say stream is stopped", caught + .getMessage().contains( "stopped" ) ); + + // Try to write null data. + caught = null; + try + { + stream.write( (float[]) null, framesPerBuffer ); + } catch( Throwable e ) + { + caught = e; + e.printStackTrace(); + } + assertTrue( "caught no exception", (caught != null) ); + assertTrue( "exception should say stream is stopped", caught + .getMessage().contains( "null" ) ); + + // Try to write short data to a float stream. + stream.start(); + caught = null; + try + { + short[] buffer = new short[framesPerBuffer + * streamParameters.channelCount]; + stream.write( buffer, framesPerBuffer ); + } catch( Throwable e ) + { + caught = e; + e.printStackTrace(); + } + + assertTrue( "caught no exception", (caught != null) ); + assertTrue( "exception should say tried to", caught.getMessage() + .contains( "Tried to write short" ) ); + + stream.close(); + + PortAudio.terminate(); + } + + public void checkBlockingWriteFloat( int deviceId, double sampleRate ) + { + StreamParameters streamParameters = new StreamParameters(); + streamParameters.channelCount = 2; + streamParameters.device = deviceId; + streamParameters.suggestedLatency = PortAudio + .getDeviceInfo( streamParameters.device ).defaultLowOutputLatency; + System.out.println( "suggestedLatency = " + + streamParameters.suggestedLatency ); + + int framesPerBuffer = 256; + int flags = 0; + BlockingStream stream = PortAudio.openStream( null, streamParameters, + (int) sampleRate, framesPerBuffer, flags ); + assertTrue( "got default stream", stream != null ); + + assertEquals( "stream isStopped", true, stream.isStopped() ); + assertEquals( "stream isActive", false, stream.isActive() ); + + int numFrames = 80000; + double expected = ((double)numFrames) / sampleRate; + stream.start(); + long startTime = System.currentTimeMillis(); + double startStreamTime = stream.getTime(); + assertEquals( "stream isStopped", false, stream.isStopped() ); + assertEquals( "stream isActive", true, stream.isActive() ); + + writeSineData( stream, framesPerBuffer, numFrames, (int) sampleRate ); + + StreamInfo streamInfo = stream.getInfo(); + System.out.println( "inputLatency of a stream = "+ streamInfo.inputLatency ); + System.out.println( "outputLatency of a stream = "+streamInfo.outputLatency ); + System.out.println( "sampleRate of a stream = "+ streamInfo.sampleRate ); + + assertEquals( "inputLatency of a stream ", 0.0, streamInfo.inputLatency, 0.000001 ); + assertTrue( "outputLatency of a stream ",(streamInfo.outputLatency > 0) ); + assertEquals( "sampleRate of a stream ", sampleRate, streamInfo.sampleRate, 3 ); + + double endStreamTime = stream.getTime(); + stream.stop(); + long stopTime = System.currentTimeMillis(); + + System.out.println( "startStreamTime = " + startStreamTime ); + System.out.println( "endStreamTime = " + endStreamTime ); + double elapsedStreamTime = endStreamTime - startStreamTime; + System.out.println( "elapsedStreamTime = " + elapsedStreamTime ); + assertTrue( "elapsedStreamTime: " + elapsedStreamTime, + (elapsedStreamTime > 0.0) ); + assertEquals( "elapsedStreamTime: ", expected, elapsedStreamTime, 0.10 ); + + assertEquals( "stream isStopped", true, stream.isStopped() ); + assertEquals( "stream isActive", false, stream.isActive() ); + stream.close(); + + double elapsed = (stopTime - startTime) / 1000.0; + assertEquals( "elapsed time to play", expected, elapsed, 0.20 ); + } + + public void testBlockingWriteFloat() + { + PortAudio.initialize(); + checkBlockingWriteFloat( PortAudio.getDefaultOutputDevice(), 44100 ); + PortAudio.terminate(); + } + + public void ZtestWriteEachHostAPI() + { + PortAudio.initialize(); + for( int hostApiIndex = 0; hostApiIndex < PortAudio.getHostApiCount(); hostApiIndex++ ) + { + HostApiInfo hostInfo = PortAudio.getHostApiInfo( hostApiIndex ); + System.out.println( "-------------\nWriting using Host API: " + hostInfo.name ); + int deviceId = hostInfo.defaultOutputDevice; + System.out.println( " Device ID =" + deviceId ); + DeviceInfo deviceInfo = PortAudio.getDeviceInfo( deviceId ); + System.out.println( " sampleRate =" + deviceInfo.defaultSampleRate ); + checkBlockingWriteFloat( deviceId, + (int) deviceInfo.defaultSampleRate ); + System.out.println( "Finished with " + hostInfo.name ); + } + PortAudio.terminate(); + } + + private void writeSineData( BlockingStream stream, int framesPerBuffer, + int numFrames, int sampleRate ) + { + float[] buffer = new float[framesPerBuffer * 2]; + SineOscillator osc1 = new SineOscillator( 200.0, sampleRate ); + SineOscillator osc2 = new SineOscillator( 300.0, sampleRate ); + int framesLeft = numFrames; + while( framesLeft > 0 ) + { + int index = 0; + int framesToWrite = (framesLeft > framesPerBuffer) ? framesPerBuffer + : framesLeft; + for( int j = 0; j < framesToWrite; j++ ) + { + buffer[index++] = (float) osc1.next(); + buffer[index++] = (float) osc2.next(); + } + stream.write( buffer, framesToWrite ); + framesLeft -= framesToWrite; + } + } + + private void writeSineDataShort( BlockingStream stream, + int framesPerBuffer, int numFrames ) + { + short[] buffer = new short[framesPerBuffer * 2]; + SineOscillator osc1 = new SineOscillator( 200.0, 44100 ); + SineOscillator osc2 = new SineOscillator( 300.0, 44100 ); + int framesLeft = numFrames; + while( framesLeft > 0 ) + { + int index = 0; + int framesToWrite = (framesLeft > framesPerBuffer) ? framesPerBuffer + : framesLeft; + for( int j = 0; j < framesToWrite; j++ ) + { + buffer[index++] = (short) (osc1.next() * 32767); + buffer[index++] = (short) (osc2.next() * 32767); + } + stream.write( buffer, framesToWrite ); + framesLeft -= framesToWrite; + } + } + + public void testBlockingWriteShort() + { + PortAudio.initialize(); + + StreamParameters streamParameters = new StreamParameters(); + streamParameters.sampleFormat = PortAudio.FORMAT_INT_16; + streamParameters.channelCount = 2; + streamParameters.device = PortAudio.getDefaultOutputDevice(); + streamParameters.suggestedLatency = PortAudio + .getDeviceInfo( streamParameters.device ).defaultLowOutputLatency; + System.out.println( "suggestedLatency = " + + streamParameters.suggestedLatency ); + + int framesPerBuffer = 256; + int flags = 0; + BlockingStream stream = PortAudio.openStream( null, streamParameters, + 44100, framesPerBuffer, flags ); + assertTrue( "got default stream", stream != null ); + + int numFrames = 80000; + stream.start(); + long startTime = System.currentTimeMillis(); + writeSineDataShort( stream, framesPerBuffer, numFrames ); + stream.stop(); + long stopTime = System.currentTimeMillis(); + stream.close(); + + double elapsed = (stopTime - startTime) / 1000.0; + double expected = numFrames / 44100.0; + assertEquals( "elapsed time to play", expected, elapsed, 0.20 ); + PortAudio.terminate(); + } + + public void testRecordPlayFloat() throws InterruptedException + { + checkRecordPlay( PortAudio.FORMAT_FLOAT_32 ); + } + + public void testRecordPlayShort() throws InterruptedException + { + checkRecordPlay( PortAudio.FORMAT_INT_16 ); + } + + public void checkRecordPlay( int sampleFormat ) throws InterruptedException + { + int framesPerBuffer = 256; + int flags = 0; + int sampleRate = 44100; + int numFrames = sampleRate * 3; + float[] floatBuffer = null; + short[] shortBuffer = null; + + PortAudio.initialize(); + StreamParameters inParameters = new StreamParameters(); + inParameters.sampleFormat = sampleFormat; + inParameters.device = PortAudio.getDefaultInputDevice(); + + DeviceInfo info = PortAudio.getDeviceInfo( inParameters.device ); + inParameters.channelCount = (info.maxInputChannels > 2) ? 2 + : info.maxInputChannels; + System.out.println( "channelCount = " + inParameters.channelCount ); + inParameters.suggestedLatency = PortAudio + .getDeviceInfo( inParameters.device ).defaultLowInputLatency; + + if( sampleFormat == PortAudio.FORMAT_FLOAT_32 ) + { + floatBuffer = new float[numFrames * inParameters.channelCount]; + } + else if( sampleFormat == PortAudio.FORMAT_INT_16 ) + { + shortBuffer = new short[numFrames * inParameters.channelCount]; + } + // Record a few seconds of audio. + BlockingStream inStream = PortAudio.openStream( inParameters, null, + sampleRate, framesPerBuffer, flags ); + + System.out.println( "RECORDING - say something like testing 1,2,3..." ); + inStream.start(); + + if( sampleFormat == PortAudio.FORMAT_FLOAT_32 ) + { + inStream.read( floatBuffer, numFrames ); + } + else if( sampleFormat == PortAudio.FORMAT_INT_16 ) + { + inStream.read( shortBuffer, numFrames ); + } + Thread.sleep( 100 ); + int availableToRead = inStream.getReadAvailable(); + System.out.println( "availableToRead = " + availableToRead ); + assertTrue( "getReadAvailable ", availableToRead > 0 ); + + inStream.stop(); + inStream.close(); + System.out.println( "Finished recording. Begin Playback." ); + + // Play back what we recorded. + StreamParameters outParameters = new StreamParameters(); + outParameters.sampleFormat = sampleFormat; + outParameters.channelCount = inParameters.channelCount; + outParameters.device = PortAudio.getDefaultOutputDevice(); + outParameters.suggestedLatency = PortAudio + .getDeviceInfo( outParameters.device ).defaultLowOutputLatency; + + BlockingStream outStream = PortAudio.openStream( null, outParameters, + sampleRate, framesPerBuffer, flags ); + assertTrue( "got default stream", outStream != null ); + + assertEquals( "inStream isActive", false, inStream.isActive() ); + + outStream.start(); + Thread.sleep( 100 ); + int availableToWrite = outStream.getWriteAvailable(); + System.out.println( "availableToWrite = " + availableToWrite ); + assertTrue( "getWriteAvailable ", availableToWrite > 0 ); + + System.out.println( "inStream = " + inStream ); + System.out.println( "outStream = " + outStream ); + assertEquals( "inStream isActive", false, inStream.isActive() ); + assertEquals( "outStream isActive", true, outStream.isActive() ); + if( sampleFormat == PortAudio.FORMAT_FLOAT_32 ) + { + outStream.write( floatBuffer, numFrames ); + } + else if( sampleFormat == PortAudio.FORMAT_INT_16 ) + { + outStream.write( shortBuffer, numFrames ); + } + outStream.stop(); + + outStream.close(); + PortAudio.terminate(); + } +} diff --git a/3rdparty/portaudio/bindings/java/jportaudio/src/com/portaudio/BlockingStream.java b/3rdparty/portaudio/bindings/java/jportaudio/src/com/portaudio/BlockingStream.java new file mode 100644 index 0000000..4c249ab --- /dev/null +++ b/3rdparty/portaudio/bindings/java/jportaudio/src/com/portaudio/BlockingStream.java @@ -0,0 +1,208 @@ +/* + * Portable Audio I/O Library + * Java Binding for PortAudio + * + * Based on the Open Source API proposed by Ross Bencina + * Copyright (c) 2008 Ross Bencina + * + * Permission is hereby granted, free of charge, to any person obtaining + * a copy of this software and associated documentation files + * (the "Software"), to deal in the Software without restriction, + * including without limitation the rights to use, copy, modify, merge, + * publish, distribute, sublicense, and/or sell copies of the Software, + * and to permit persons to whom the Software is furnished to do so, + * subject to the following conditions: + * + * The above copyright notice and this permission notice shall be + * included in all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. + * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR + * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF + * CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION + * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ + +/* + * The text above constitutes the entire PortAudio license; however, + * the PortAudio community also makes the following non-binding requests: + * + * Any person wishing to distribute modifications to the Software is + * requested to send the modifications to the original developer so that + * they can be incorporated into the canonical version. It is also + * requested that these non-binding requests be included along with the + * license above. + */ + +/** @file + @ingroup bindings_java + + @brief A blocking read/write stream. +*/ +package com.portaudio; + +/** + * Represents a stream for blocking read/write I/O. + * + * This Java object contains the pointer to a PortAudio stream stored as a long. + * It is passed to PortAudio when calling stream related functions. + * + * To create one of these, call PortAudio.openStream(). + * + * @see PortAudio + * + * @author Phil Burk + * + */ +public class BlockingStream +{ + // nativeStream is only accessed by the native code. It contains a pointer + // to a PaStream. + private long nativeStream; + private int inputFormat = -1; + private int outputFormat = -1; + + protected BlockingStream() + { + } + + /** + * @return number of frames that can be read without blocking. + */ + public native int getReadAvailable(); + + /** + * @return number of frames that can be written without blocking. + */ + public native int getWriteAvailable(); + + private native boolean readFloats( float[] buffer, int numFrames ); + + private native boolean writeFloats( float[] buffer, int numFrames ); + + /** + * Read 32-bit floating point data from the stream into the array. + * + * @param buffer + * @param numFrames + * number of frames to read + * @return true if an input overflow occurred + */ + public boolean read( float[] buffer, int numFrames ) + { + if( inputFormat != PortAudio.FORMAT_FLOAT_32 ) + { + throw new RuntimeException( + "Tried to read float samples from a non float stream." ); + } + return readFloats( buffer, numFrames ); + } + + /** + * Write 32-bit floating point data to the stream from the array. The data + * should be in the range -1.0 to +1.0. + * + * @param buffer + * @param numFrames + * number of frames to write + * @return true if an output underflow occurred + */ + public boolean write( float[] buffer, int numFrames ) + { + if( outputFormat != PortAudio.FORMAT_FLOAT_32 ) + { + throw new RuntimeException( + "Tried to write float samples to a non float stream." ); + } + return writeFloats( buffer, numFrames ); + } + + private native boolean readShorts( short[] buffer, int numFrames ); + + private native boolean writeShorts( short[] buffer, int numFrames ); + + /** + * Read 16-bit integer data to the stream from the array. + * + * @param buffer + * @param numFrames + * number of frames to write + * @return true if an input overflow occurred + */ + public boolean read( short[] buffer, int numFrames ) + { + if( inputFormat != PortAudio.FORMAT_INT_16 ) + { + throw new RuntimeException( + "Tried to read short samples from a non short stream." ); + } + return readShorts( buffer, numFrames ); + } + + /** + * Write 16-bit integer data to the stream from the array. + * + * @param buffer + * @param numFrames + * number of frames to write + * @return true if an output underflow occurred + */ + public boolean write( short[] buffer, int numFrames ) + { + if( outputFormat != PortAudio.FORMAT_INT_16 ) + { + throw new RuntimeException( + "Tried to write short samples from a non short stream." ); + } + return writeShorts( buffer, numFrames ); + } + + /** + * Atart audio I/O. + */ + public native void start(); + + /** + * Wait for the stream to play all of the data that has been written then + * stop. + */ + public native void stop(); + + /** + * Stop immediately and lose any data that was written but not played. + */ + public native void abort(); + + /** + * Close the stream and zero out the pointer. Do not reference the stream + * after this. + */ + public native void close(); + + public native boolean isStopped(); + + public native boolean isActive(); + + public String toString() + { + return "BlockingStream: streamPtr = " + Long.toHexString( nativeStream ) + + ", inFormat = " + inputFormat + ", outFormat = " + + outputFormat; + } + + /** + * Get audio time related to this stream. Note that it may not start at 0.0. + */ + public native double getTime(); + + private native void getInfo( StreamInfo streamInfo ); + + public StreamInfo getInfo() + { + StreamInfo streamInfo = new StreamInfo(); + getInfo( streamInfo ); + return streamInfo; + } +} diff --git a/3rdparty/portaudio/bindings/java/jportaudio/src/com/portaudio/DeviceInfo.java b/3rdparty/portaudio/bindings/java/jportaudio/src/com/portaudio/DeviceInfo.java new file mode 100644 index 0000000..1c4682e --- /dev/null +++ b/3rdparty/portaudio/bindings/java/jportaudio/src/com/portaudio/DeviceInfo.java @@ -0,0 +1,65 @@ +/* + * Portable Audio I/O Library + * Java Binding for PortAudio + * + * Based on the Open Source API proposed by Ross Bencina + * Copyright (c) 2008 Ross Bencina + * + * Permission is hereby granted, free of charge, to any person obtaining + * a copy of this software and associated documentation files + * (the "Software"), to deal in the Software without restriction, + * including without limitation the rights to use, copy, modify, merge, + * publish, distribute, sublicense, and/or sell copies of the Software, + * and to permit persons to whom the Software is furnished to do so, + * subject to the following conditions: + * + * The above copyright notice and this permission notice shall be + * included in all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. + * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR + * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF + * CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION + * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ + +/* + * The text above constitutes the entire PortAudio license; however, + * the PortAudio community also makes the following non-binding requests: + * + * Any person wishing to distribute modifications to the Software is + * requested to send the modifications to the original developer so that + * they can be incorporated into the canonical version. It is also + * requested that these non-binding requests be included along with the + * license above. + */ + +/** @file + @ingroup bindings_java + + @brief Information about a JPortAudio device. +*/ +package com.portaudio; + +/** + * Equivalent to PaDeviceInfo + * @see PortAudio + * @see HostApiInfo + * @author Phil Burk + * + */ +public class DeviceInfo +{ + public int version; + public String name; + public int hostApi; + public int maxInputChannels; + public int maxOutputChannels; + public double defaultLowInputLatency; + public double defaultHighInputLatency; + public double defaultLowOutputLatency; + public double defaultHighOutputLatency; + public double defaultSampleRate; +} diff --git a/3rdparty/portaudio/bindings/java/jportaudio/src/com/portaudio/HostApiInfo.java b/3rdparty/portaudio/bindings/java/jportaudio/src/com/portaudio/HostApiInfo.java new file mode 100644 index 0000000..dc2cdce --- /dev/null +++ b/3rdparty/portaudio/bindings/java/jportaudio/src/com/portaudio/HostApiInfo.java @@ -0,0 +1,61 @@ +/* + * Portable Audio I/O Library + * Java Binding for PortAudio + * + * Based on the Open Source API proposed by Ross Bencina + * Copyright (c) 2008 Ross Bencina + * + * Permission is hereby granted, free of charge, to any person obtaining + * a copy of this software and associated documentation files + * (the "Software"), to deal in the Software without restriction, + * including without limitation the rights to use, copy, modify, merge, + * publish, distribute, sublicense, and/or sell copies of the Software, + * and to permit persons to whom the Software is furnished to do so, + * subject to the following conditions: + * + * The above copyright notice and this permission notice shall be + * included in all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. + * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR + * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF + * CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION + * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ + +/* + * The text above constitutes the entire PortAudio license; however, + * the PortAudio community also makes the following non-binding requests: + * + * Any person wishing to distribute modifications to the Software is + * requested to send the modifications to the original developer so that + * they can be incorporated into the canonical version. It is also + * requested that these non-binding requests be included along with the + * license above. + */ + +/** @file + @ingroup bindings_java + + @brief Information about a JPortAudio Host API. +*/ +package com.portaudio; + +/** + * Equivalent to PaHostApiInfo + * @see PortAudio + * @see DeviceInfo + * @author Phil Burk + * + */ +public class HostApiInfo +{ + public int version; + public int type; + public String name; + public int deviceCount; + public int defaultInputDevice; + public int defaultOutputDevice; +} diff --git a/3rdparty/portaudio/bindings/java/jportaudio/src/com/portaudio/PortAudio.java b/3rdparty/portaudio/bindings/java/jportaudio/src/com/portaudio/PortAudio.java new file mode 100644 index 0000000..41b3c67 --- /dev/null +++ b/3rdparty/portaudio/bindings/java/jportaudio/src/com/portaudio/PortAudio.java @@ -0,0 +1,261 @@ +/* + * Portable Audio I/O Library + * Java Binding for PortAudio + * + * Based on the Open Source API proposed by Ross Bencina + * Copyright (c) 2008 Ross Bencina + * + * Permission is hereby granted, free of charge, to any person obtaining + * a copy of this software and associated documentation files + * (the "Software"), to deal in the Software without restriction, + * including without limitation the rights to use, copy, modify, merge, + * publish, distribute, sublicense, and/or sell copies of the Software, + * and to permit persons to whom the Software is furnished to do so, + * subject to the following conditions: + * + * The above copyright notice and this permission notice shall be + * included in all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. + * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR + * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF + * CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION + * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ + +/* + * The text above constitutes the entire PortAudio license; however, + * the PortAudio community also makes the following non-binding requests: + * + * Any person wishing to distribute modifications to the Software is + * requested to send the modifications to the original developer so that + * they can be incorporated into the canonical version. It is also + * requested that these non-binding requests be included along with the + * license above. + */ + +/** @file + @ingroup bindings_java + + @brief Java wrapper for the PortAudio API. +*/ +package com.portaudio; + +/** + * Java methods that call PortAudio via JNI. This is a portable audio I/O + * library that can be used as an alternative to JavaSound. + * + * Please see the PortAudio documentation for a full explanation. + * + * http://portaudio.com/docs/ + * http://portaudio.com/docs/v19-doxydocs/portaudio_8h.html + * + * This Java binding does not support audio callbacks because an audio callback + * should never block. Calling into a Java virtual machine might block for + * garbage collection or synchronization. So only the blocking read/write mode + * is supported. + * + * @see BlockingStream + * @see DeviceInfo + * @see HostApiInfo + * @see StreamInfo + * @see StreamParameters + * + * @author Phil Burk + * + */ +public class PortAudio +{ + public final static int FLAG_CLIP_OFF = (1 << 0); + public final static int FLAG_DITHER_OFF = (1 << 1); + + /** Sample Formats */ + public final static int FORMAT_FLOAT_32 = (1 << 0); + public final static int FORMAT_INT_32 = (1 << 1); // not supported + public final static int FORMAT_INT_24 = (1 << 2); // not supported + public final static int FORMAT_INT_16 = (1 << 3); + public final static int FORMAT_INT_8 = (1 << 4); // not supported + public final static int FORMAT_UINT_8 = (1 << 5); // not supported + + /** These HOST_API_TYPES will not change in the future. */ + public final static int HOST_API_TYPE_DEV = 0; + public final static int HOST_API_TYPE_DIRECTSOUND = 1; + public final static int HOST_API_TYPE_MME = 2; + public final static int HOST_API_TYPE_ASIO = 3; + /** Apple Sound Manager. Obsolete. */ + public final static int HOST_API_TYPE_SOUNDMANAGER = 4; + public final static int HOST_API_TYPE_COREAUDIO = 5; + public final static int HOST_API_TYPE_OSS = 7; + public final static int HOST_API_TYPE_ALSA = 8; + public final static int HOST_API_TYPE_AL = 9; + public final static int HOST_API_TYPE_BEOS = 10; + public final static int HOST_API_TYPE_WDMKS = 11; + public final static int HOST_API_TYPE_JACK = 12; + public final static int HOST_API_TYPE_WASAPI = 13; + public final static int HOST_API_TYPE_AUDIOSCIENCE = 14; + public final static int HOST_API_TYPE_COUNT = 15; + + static + { + String os = System.getProperty( "os.name" ).toLowerCase(); + // On Windows we have separate libraries for 32 and 64-bit JVMs. + if( os.indexOf( "win" ) >= 0 ) + { + if( System.getProperty( "os.arch" ).contains( "64" ) ) + { + System.loadLibrary( "jportaudio_x64" ); + } + else + { + System.loadLibrary( "jportaudio_x86" ); + } + } + else + { + System.loadLibrary( "jportaudio" ); + } + System.out.println( "---- JPortAudio version " + getVersion() + ", " + + getVersionText() ); + } + + /** + * @return the release number of the currently running PortAudio build, eg + * 1900. + */ + public native static int getVersion(); + + /** + * @return a textual description of the current PortAudio build, eg + * "PortAudio V19-devel 13 October 2002". + */ + public native static String getVersionText(); + + /** + * Library initialization function - call this before using PortAudio. This + * function initializes internal data structures and prepares underlying + * host APIs for use. With the exception of getVersion(), getVersionText(), + * and getErrorText(), this function MUST be called before using any other + * PortAudio API functions. + */ + public native static void initialize(); + + /** + * Library termination function - call this when finished using PortAudio. + * This function deallocates all resources allocated by PortAudio since it + * was initialized by a call to initialize(). In cases where Pa_Initialise() + * has been called multiple times, each call must be matched with a + * corresponding call to terminate(). The final matching call to terminate() + * will automatically close any PortAudio streams that are still open. + */ + public native static void terminate(); + + /** + * @return the number of available devices. The number of available devices + * may be zero. + */ + public native static int getDeviceCount(); + + private native static void getDeviceInfo( int index, DeviceInfo deviceInfo ); + + /** + * @param index + * A valid device index in the range 0 to (getDeviceCount()-1) + * @return An DeviceInfo structure. + * @throws RuntimeException + * if the device parameter is out of range. + */ + public static DeviceInfo getDeviceInfo( int index ) + { + DeviceInfo deviceInfo = new DeviceInfo(); + getDeviceInfo( index, deviceInfo ); + return deviceInfo; + } + + /** + * @return the number of available host APIs. + */ + public native static int getHostApiCount(); + + private native static void getHostApiInfo( int index, + HostApiInfo hostApiInfo ); + + /** + * @param index + * @return information about the Host API + */ + public static HostApiInfo getHostApiInfo( int index ) + { + HostApiInfo hostApiInfo = new HostApiInfo(); + getHostApiInfo( index, hostApiInfo ); + return hostApiInfo; + } + + /** + * @param hostApiType + * A unique host API identifier, for example + * HOST_API_TYPE_COREAUDIO. + * @return a runtime host API index + */ + public native static int hostApiTypeIdToHostApiIndex( int hostApiType ); + + /** + * @param hostApiIndex + * A valid host API index ranging from 0 to (getHostApiCount()-1) + * @param apiDeviceIndex + * A valid per-host device index in the range 0 to + * (getHostApiInfo(hostApi).deviceCount-1) + * @return standard PortAudio device index + */ + public native static int hostApiDeviceIndexToDeviceIndex( int hostApiIndex, + int apiDeviceIndex ); + + public native static int getDefaultInputDevice(); + + public native static int getDefaultOutputDevice(); + + public native static int getDefaultHostApi(); + + /** + * @param inputStreamParameters + * input description, may be null + * @param outputStreamParameters + * output description, may be null + * @param sampleRate + * typically 44100 or 48000, or maybe 22050, 16000, 8000, 96000 + * @return 0 if supported or a negative error + */ + public native static int isFormatSupported( + StreamParameters inputStreamParameters, + StreamParameters outputStreamParameters, int sampleRate ); + + private native static void openStream( BlockingStream blockingStream, + StreamParameters inputStreamParameters, + StreamParameters outputStreamParameters, int sampleRate, + int framesPerBuffer, int flags ); + + /** + * + * @param inputStreamParameters + * input description, may be null + * @param outputStreamParameters + * output description, may be null + * @param sampleRate + * typically 44100 or 48000, or maybe 22050, 16000, 8000, 96000 + * @param framesPerBuffer + * @param flags + * @return + */ + public static BlockingStream openStream( + StreamParameters inputStreamParameters, + StreamParameters outputStreamParameters, int sampleRate, + int framesPerBuffer, int flags ) + { + BlockingStream blockingStream = new BlockingStream(); + openStream( blockingStream, inputStreamParameters, + outputStreamParameters, sampleRate, framesPerBuffer, flags ); + return blockingStream; + } + +} diff --git a/3rdparty/portaudio/bindings/java/jportaudio/src/com/portaudio/StreamInfo.java b/3rdparty/portaudio/bindings/java/jportaudio/src/com/portaudio/StreamInfo.java new file mode 100644 index 0000000..685f94d --- /dev/null +++ b/3rdparty/portaudio/bindings/java/jportaudio/src/com/portaudio/StreamInfo.java @@ -0,0 +1,60 @@ +/* + * Portable Audio I/O Library + * Java Binding for PortAudio + * + * Based on the Open Source API proposed by Ross Bencina + * Copyright (c) 2008 Ross Bencina + * + * Permission is hereby granted, free of charge, to any person obtaining + * a copy of this software and associated documentation files + * (the "Software"), to deal in the Software without restriction, + * including without limitation the rights to use, copy, modify, merge, + * publish, distribute, sublicense, and/or sell copies of the Software, + * and to permit persons to whom the Software is furnished to do so, + * subject to the following conditions: + * + * The above copyright notice and this permission notice shall be + * included in all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. + * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR + * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF + * CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION + * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ + +/* + * The text above constitutes the entire PortAudio license; however, + * the PortAudio community also makes the following non-binding requests: + * + * Any person wishing to distribute modifications to the Software is + * requested to send the modifications to the original developer so that + * they can be incorporated into the canonical version. It is also + * requested that these non-binding requests be included along with the + * license above. + */ + + +/** @file + @ingroup bindings_java + + @brief Information about a JPortAudio Stream. +*/ + +package com.portaudio; + +/** + * Equivalent to PaStreamInfo + * @see PortAudio + * @author Phil Burk + * + */ +public class StreamInfo +{ + public int structVersion; + public double outputLatency; + public double inputLatency; + public double sampleRate; +} diff --git a/3rdparty/portaudio/bindings/java/jportaudio/src/com/portaudio/StreamParameters.java b/3rdparty/portaudio/bindings/java/jportaudio/src/com/portaudio/StreamParameters.java new file mode 100644 index 0000000..707dab5 --- /dev/null +++ b/3rdparty/portaudio/bindings/java/jportaudio/src/com/portaudio/StreamParameters.java @@ -0,0 +1,57 @@ +/* + * Portable Audio I/O Library + * Java Binding for PortAudio + * + * Based on the Open Source API proposed by Ross Bencina + * Copyright (c) 2008 Ross Bencina + * + * Permission is hereby granted, free of charge, to any person obtaining + * a copy of this software and associated documentation files + * (the "Software"), to deal in the Software without restriction, + * including without limitation the rights to use, copy, modify, merge, + * publish, distribute, sublicense, and/or sell copies of the Software, + * and to permit persons to whom the Software is furnished to do so, + * subject to the following conditions: + * + * The above copyright notice and this permission notice shall be + * included in all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. + * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR + * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF + * CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION + * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ + +/* + * The text above constitutes the entire PortAudio license; however, + * the PortAudio community also makes the following non-binding requests: + * + * Any person wishing to distribute modifications to the Software is + * requested to send the modifications to the original developer so that + * they can be incorporated into the canonical version. It is also + * requested that these non-binding requests be included along with the + * license above. + */ + +/** @file + @ingroup bindings_java + + @brief Options to use when opening a stream. +*/ +package com.portaudio; +/** + * Equivalent to PaStreamParameters + * @see PortAudio + * @author Phil Burk + * + */ +public class StreamParameters +{ + public int device = 0; + public int channelCount = 2; + public int sampleFormat = PortAudio.FORMAT_FLOAT_32; + public double suggestedLatency = 0.050; +} diff --git a/3rdparty/portaudio/bindings/java/scripts/make_header.bat b/3rdparty/portaudio/bindings/java/scripts/make_header.bat new file mode 100644 index 0000000..3c4f58a --- /dev/null +++ b/3rdparty/portaudio/bindings/java/scripts/make_header.bat @@ -0,0 +1,4 @@ +REM Generate the JNI header file from the Java code for JPortAudio +REM by Phil Burk + +javah -classpath ../jportaudio/bin -d ../c/src com.portaudio.PortAudio com.portaudio.BlockingStream -- cgit v1.2.1