diff --git a/jme3-android-native/openalsoft.gradle b/jme3-android-native/openalsoft.gradle index d32a804b8..133a1729e 100644 --- a/jme3-android-native/openalsoft.gradle +++ b/jme3-android-native/openalsoft.gradle @@ -72,20 +72,13 @@ task copyJmeOpenALSoft(type: Copy, dependsOn:copyOpenALSoft) { into outputDir } -task generateOpenAlSoftHeaders(dependsOn: copyJmeOpenALSoft) << { - String destDirPath = openalsoftBuildJniDir - String classes = "" - .concat("com.jme3.audio.android.AndroidOpenALSoftAudioRenderer, ") -// println "openalsoft classes = " + classes -// println "openalsoft destDir = " + destDirPath -// println "openalsoft classpath = " + project.projectClassPath - - exec { - executable org.gradle.internal.jvm.Jvm.current().getExecutable('javah') - args '-d', destDirPath - args '-classpath', project.projectClassPath - args "com.jme3.audio.android.AndroidOpenALSoftAudioRenderer" - } +task generateOpenAlSoftHeaders(type:Exec, dependsOn: copyJmeOpenALSoft) { + executable org.gradle.internal.jvm.Jvm.current().getExecutable('javah') + args '-d', openalsoftJmeAndroidPath + args '-classpath', project.projectClassPath + args "com.jme3.audio.android.AndroidAL" + args "com.jme3.audio.android.AndroidALC" + args "com.jme3.audio.android.AndroidEFX" } task buildOpenAlSoftNativeLib(type: Exec, dependsOn: generateOpenAlSoftHeaders) { diff --git a/jme3-android-native/src/native/jme_openalsoft/Android.mk b/jme3-android-native/src/native/jme_openalsoft/Android.mk index cac2e4df8..23d14b3ba 100644 --- a/jme3-android-native/src/native/jme_openalsoft/Android.mk +++ b/jme3-android-native/src/native/jme_openalsoft/Android.mk @@ -62,7 +62,9 @@ LOCAL_SRC_FILES := Alc/backends/opensl.c \ OpenAL32/alSource.c \ OpenAL32/alState.c \ OpenAL32/sample_cvt.c \ - com_jme3_audio_android_AndroidOpenALSoftAudioRenderer.cpp + com_jme3_audio_android_AndroidAL.c \ + com_jme3_audio_android_AndroidALC.c \ + com_jme3_audio_android_AndroidEFX.c include $(BUILD_SHARED_LIBRARY) diff --git a/jme3-android-native/src/native/jme_openalsoft/com_jme3_audio_android_AndroidAL.c b/jme3-android-native/src/native/jme_openalsoft/com_jme3_audio_android_AndroidAL.c new file mode 100644 index 000000000..0b6fb61b7 --- /dev/null +++ b/jme3-android-native/src/native/jme_openalsoft/com_jme3_audio_android_AndroidAL.c @@ -0,0 +1,134 @@ +#include "com_jme3_audio_android_AndroidAL.h" +#include "AL/al.h" +#include "AL/alext.h" + +JNIEXPORT jstring JNICALL Java_com_jme3_audio_android_AndroidAL_alGetString + (JNIEnv* env, jobject obj, jint param) +{ + return (*env)->NewStringUTF(env, alGetString(param)); +} + +JNIEXPORT jint JNICALL Java_com_jme3_audio_android_AndroidAL_alGenSources + (JNIEnv *env, jobject obj) +{ + ALuint source; + alGenSources(1, &source); + return source; +} + +JNIEXPORT jint JNICALL Java_com_jme3_audio_android_AndroidAL_alGetError + (JNIEnv *env, jobject obj) +{ + return alGetError(); +} + +JNIEXPORT void JNICALL Java_com_jme3_audio_android_AndroidAL_alDeleteSources + (JNIEnv* env, jobject obj, jint numSources, jobject intbufSources) +{ + ALuint* pIntBufSources = (ALuint*) (*env)->GetDirectBufferAddress(env, intbufSources); + alDeleteSources((ALsizei)numSources, pIntBufSources); +} + +JNIEXPORT void JNICALL Java_com_jme3_audio_android_AndroidAL_alGenBuffers + (JNIEnv* env, jobject obj, jint numBuffers, jobject intbufBuffers) +{ + ALuint* pIntBufBuffers = (ALuint*) (*env)->GetDirectBufferAddress(env, intbufBuffers); + alGenBuffers((ALsizei)numBuffers, pIntBufBuffers); +} + +JNIEXPORT void JNICALL Java_com_jme3_audio_android_AndroidAL_alDeleteBuffers + (JNIEnv* env, jobject obj, jint numBuffers, jobject intbufBuffers) +{ + ALuint* pIntBufBuffers = (ALuint*) (*env)->GetDirectBufferAddress(env, intbufBuffers); + alDeleteBuffers((ALsizei)numBuffers, pIntBufBuffers); +} + +JNIEXPORT void JNICALL Java_com_jme3_audio_android_AndroidAL_alSourceStop + (JNIEnv *env, jobject obj, jint source) +{ + alSourceStop((ALuint)source); +} + +JNIEXPORT void JNICALL Java_com_jme3_audio_android_AndroidAL_alSourcei + (JNIEnv *env, jobject obj, jint source, jint param, jint value) +{ + alSourcei((ALuint)source, (ALenum)param, (ALint)value); +} + +JNIEXPORT void JNICALL Java_com_jme3_audio_android_AndroidAL_alBufferData + (JNIEnv* env, jobject obj, jint buffer, jint format, jobject bufferData, jint bufferSize, jint frequency) +{ + ALuint* pBufferData = (ALuint*) (*env)->GetDirectBufferAddress(env, bufferData); + alBufferData((ALuint)buffer, (ALenum)format, pBufferData, (ALsizei)bufferSize, (ALsizei)frequency); +} + +JNIEXPORT void JNICALL Java_com_jme3_audio_android_AndroidAL_alSourcePlay + (JNIEnv *env, jobject obj, jint source) +{ + alSourcePlay((ALuint)source); +} + +JNIEXPORT void JNICALL Java_com_jme3_audio_android_AndroidAL_alSourcePause + (JNIEnv *env, jobject obj, jint source) +{ + alSourcePause((ALuint)source); +} + +JNIEXPORT void JNICALL Java_com_jme3_audio_android_AndroidAL_alSourcef + (JNIEnv *env, jobject obj, jint source, jint param, jfloat value) +{ + alSourcef((ALuint)source, (ALenum)param, (ALfloat)value); +} + +JNIEXPORT void JNICALL Java_com_jme3_audio_android_AndroidAL_alSource3f + (JNIEnv *env, jobject obj, jint source, jint param, jfloat value1, jfloat value2, jfloat value3) +{ + alSource3f((ALuint)source, (ALenum)param, (ALfloat)value1, (ALfloat)value2, (ALfloat)value3); +} + +JNIEXPORT jint JNICALL Java_com_jme3_audio_android_AndroidAL_alGetSourcei + (JNIEnv *env, jobject obj, jint source, jint param) +{ + ALint result; + alGetSourcei((ALuint)source, (ALenum)param, &result); + return (jint)result; +} + +JNIEXPORT void JNICALL Java_com_jme3_audio_android_AndroidAL_alSourceUnqueueBuffers + (JNIEnv* env, jobject obj, jint source, jint numBuffers, jobject buffers) +{ + ALuint* pBuffers = (ALuint*) (*env)->GetDirectBufferAddress(env, buffers); + alSourceUnqueueBuffers((ALuint)source, (ALsizei)numBuffers, pBuffers); +} + +JNIEXPORT void JNICALL Java_com_jme3_audio_android_AndroidAL_alSourceQueueBuffers + (JNIEnv* env, jobject obj, jint source, jint numBuffers, jobject buffers) +{ + ALuint* pBuffers = (ALuint*) (*env)->GetDirectBufferAddress(env, buffers); + alSourceQueueBuffers((ALuint)source, (ALsizei)numBuffers, pBuffers); +} + +JNIEXPORT void JNICALL Java_com_jme3_audio_android_AndroidAL_alListener + (JNIEnv* env, jobject obj, jint param, jobject bufferData) +{ + ALfloat* pBufferData = (ALfloat*) (*env)->GetDirectBufferAddress(env, bufferData); + alListenerfv((ALenum)param, pBufferData); +} + +JNIEXPORT void JNICALL Java_com_jme3_audio_android_AndroidAL_alListenerf + (JNIEnv *env, jobject obj, jint param, jfloat value) +{ + alListenerf((ALenum)param, (ALfloat)value); +} + +JNIEXPORT void JNICALL Java_com_jme3_audio_android_AndroidAL_alListener3f + (JNIEnv *env, jobject obj, jint param, jfloat value1, jfloat value2, jfloat value3) +{ + alListener3f((ALenum)param, (ALfloat)value1, (ALfloat)value2, (ALfloat)value3); +} + +JNIEXPORT void JNICALL Java_com_jme3_audio_android_AndroidAL_alSource3i + (JNIEnv *env, jobject obj, jint source, jint param, jint value1, jint value2, jint value3) +{ + alSource3i((ALuint)source, (ALenum)param, (ALint)value1, (ALint)value2, (ALint)value3); +} diff --git a/jme3-android-native/src/native/jme_openalsoft/com_jme3_audio_android_AndroidAL.h b/jme3-android-native/src/native/jme_openalsoft/com_jme3_audio_android_AndroidAL.h new file mode 100644 index 000000000..1fa80bbf4 --- /dev/null +++ b/jme3-android-native/src/native/jme_openalsoft/com_jme3_audio_android_AndroidAL.h @@ -0,0 +1,173 @@ +/* DO NOT EDIT THIS FILE - it is machine generated */ +#include +/* Header for class com_jme3_audio_android_AndroidAL */ + +#ifndef _Included_com_jme3_audio_android_AndroidAL +#define _Included_com_jme3_audio_android_AndroidAL +#ifdef __cplusplus +extern "C" { +#endif +/* + * Class: com_jme3_audio_android_AndroidAL + * Method: alGetString + * Signature: (I)Ljava/lang/String; + */ +JNIEXPORT jstring JNICALL Java_com_jme3_audio_android_AndroidAL_alGetString + (JNIEnv *, jobject, jint); + +/* + * Class: com_jme3_audio_android_AndroidAL + * Method: alGenSources + * Signature: ()I + */ +JNIEXPORT jint JNICALL Java_com_jme3_audio_android_AndroidAL_alGenSources + (JNIEnv *, jobject); + +/* + * Class: com_jme3_audio_android_AndroidAL + * Method: alGetError + * Signature: ()I + */ +JNIEXPORT jint JNICALL Java_com_jme3_audio_android_AndroidAL_alGetError + (JNIEnv *, jobject); + +/* + * Class: com_jme3_audio_android_AndroidAL + * Method: alDeleteSources + * Signature: (ILjava/nio/IntBuffer;)V + */ +JNIEXPORT void JNICALL Java_com_jme3_audio_android_AndroidAL_alDeleteSources + (JNIEnv *, jobject, jint, jobject); + +/* + * Class: com_jme3_audio_android_AndroidAL + * Method: alGenBuffers + * Signature: (ILjava/nio/IntBuffer;)V + */ +JNIEXPORT void JNICALL Java_com_jme3_audio_android_AndroidAL_alGenBuffers + (JNIEnv *, jobject, jint, jobject); + +/* + * Class: com_jme3_audio_android_AndroidAL + * Method: alDeleteBuffers + * Signature: (ILjava/nio/IntBuffer;)V + */ +JNIEXPORT void JNICALL Java_com_jme3_audio_android_AndroidAL_alDeleteBuffers + (JNIEnv *, jobject, jint, jobject); + +/* + * Class: com_jme3_audio_android_AndroidAL + * Method: alSourceStop + * Signature: (I)V + */ +JNIEXPORT void JNICALL Java_com_jme3_audio_android_AndroidAL_alSourceStop + (JNIEnv *, jobject, jint); + +/* + * Class: com_jme3_audio_android_AndroidAL + * Method: alSourcei + * Signature: (III)V + */ +JNIEXPORT void JNICALL Java_com_jme3_audio_android_AndroidAL_alSourcei + (JNIEnv *, jobject, jint, jint, jint); + +/* + * Class: com_jme3_audio_android_AndroidAL + * Method: alBufferData + * Signature: (IILjava/nio/ByteBuffer;II)V + */ +JNIEXPORT void JNICALL Java_com_jme3_audio_android_AndroidAL_alBufferData + (JNIEnv *, jobject, jint, jint, jobject, jint, jint); + +/* + * Class: com_jme3_audio_android_AndroidAL + * Method: alSourcePlay + * Signature: (I)V + */ +JNIEXPORT void JNICALL Java_com_jme3_audio_android_AndroidAL_alSourcePlay + (JNIEnv *, jobject, jint); + +/* + * Class: com_jme3_audio_android_AndroidAL + * Method: alSourcePause + * Signature: (I)V + */ +JNIEXPORT void JNICALL Java_com_jme3_audio_android_AndroidAL_alSourcePause + (JNIEnv *, jobject, jint); + +/* + * Class: com_jme3_audio_android_AndroidAL + * Method: alSourcef + * Signature: (IIF)V + */ +JNIEXPORT void JNICALL Java_com_jme3_audio_android_AndroidAL_alSourcef + (JNIEnv *, jobject, jint, jint, jfloat); + +/* + * Class: com_jme3_audio_android_AndroidAL + * Method: alSource3f + * Signature: (IIFFF)V + */ +JNIEXPORT void JNICALL Java_com_jme3_audio_android_AndroidAL_alSource3f + (JNIEnv *, jobject, jint, jint, jfloat, jfloat, jfloat); + +/* + * Class: com_jme3_audio_android_AndroidAL + * Method: alGetSourcei + * Signature: (II)I + */ +JNIEXPORT jint JNICALL Java_com_jme3_audio_android_AndroidAL_alGetSourcei + (JNIEnv *, jobject, jint, jint); + +/* + * Class: com_jme3_audio_android_AndroidAL + * Method: alSourceUnqueueBuffers + * Signature: (IILjava/nio/IntBuffer;)V + */ +JNIEXPORT void JNICALL Java_com_jme3_audio_android_AndroidAL_alSourceUnqueueBuffers + (JNIEnv *, jobject, jint, jint, jobject); + +/* + * Class: com_jme3_audio_android_AndroidAL + * Method: alSourceQueueBuffers + * Signature: (IILjava/nio/IntBuffer;)V + */ +JNIEXPORT void JNICALL Java_com_jme3_audio_android_AndroidAL_alSourceQueueBuffers + (JNIEnv *, jobject, jint, jint, jobject); + +/* + * Class: com_jme3_audio_android_AndroidAL + * Method: alListener + * Signature: (ILjava/nio/FloatBuffer;)V + */ +JNIEXPORT void JNICALL Java_com_jme3_audio_android_AndroidAL_alListener + (JNIEnv *, jobject, jint, jobject); + +/* + * Class: com_jme3_audio_android_AndroidAL + * Method: alListenerf + * Signature: (IF)V + */ +JNIEXPORT void JNICALL Java_com_jme3_audio_android_AndroidAL_alListenerf + (JNIEnv *, jobject, jint, jfloat); + +/* + * Class: com_jme3_audio_android_AndroidAL + * Method: alListener3f + * Signature: (IFFF)V + */ +JNIEXPORT void JNICALL Java_com_jme3_audio_android_AndroidAL_alListener3f + (JNIEnv *, jobject, jint, jfloat, jfloat, jfloat); + +/* + * Class: com_jme3_audio_android_AndroidAL + * Method: alSource3i + * Signature: (IIIII)V + */ +JNIEXPORT void JNICALL Java_com_jme3_audio_android_AndroidAL_alSource3i + (JNIEnv *, jobject, jint, jint, jint, jint, jint); + +#ifdef __cplusplus +} +#endif +#endif diff --git a/jme3-android-native/src/native/jme_openalsoft/com_jme3_audio_android_AndroidALC.c b/jme3-android-native/src/native/jme_openalsoft/com_jme3_audio_android_AndroidALC.c new file mode 100644 index 000000000..4438910cc --- /dev/null +++ b/jme3-android-native/src/native/jme_openalsoft/com_jme3_audio_android_AndroidALC.c @@ -0,0 +1,174 @@ +#include "util.h" +#include "com_jme3_audio_android_AndroidALC.h" +#include "AL/alc.h" +#include "AL/alext.h" + +static jboolean created = JNI_FALSE; + +/* InitAL opens the default device and sets up a context using default + * attributes, making the program ready to call OpenAL functions. */ +static int InitAL() +{ + ALCdevice *device = NULL; + ALCcontext *ctx = NULL; + + /* Open and initialize a device with default settings */ + device = alcOpenDevice(NULL); + + if(device == NULL) + { + fprintf(stderr, "Could not open a device!\n"); + goto cleanup; + } + + ctx = alcCreateContext(device, NULL); + + if (ctx == NULL) + { + fprintf(stderr, "Could not create context!\n"); + goto cleanup; + } + + if (!alcMakeContextCurrent(ctx)) + { + fprintf(stderr, "Could not make context current!\n"); + goto cleanup; + } + + return 0; + +cleanup: + if (ctx != NULL) alcDestroyContext(ctx); + if (device != NULL) alcCloseDevice(device); + return 1; +} + +/* CloseAL closes the device belonging to the current context, and destroys the + * context. */ +static void CloseAL() +{ + ALCdevice *device; + ALCcontext *ctx; + + ctx = alcGetCurrentContext(); + + if (ctx == NULL) + { + return; + } + + device = alcGetContextsDevice(ctx); + + if (device == NULL) + { + return; + } + + if(!alcMakeContextCurrent(NULL)) { + return; + } + + alcDestroyContext(ctx); + alcCloseDevice(device); +} + +static ALCdevice* GetALCDevice() +{ + ALCdevice *device; + ALCcontext *ctx; + + ctx = alcGetCurrentContext(); + + if (ctx != NULL) + { + device = alcGetContextsDevice(ctx); + + if (device != NULL) + { + return device; + } + } + + return NULL; +} + +JNIEXPORT jboolean JNICALL Java_com_jme3_audio_android_AndroidALC_isCreated + (JNIEnv* env, jobject obj) +{ + return created; +} + + +JNIEXPORT void JNICALL Java_com_jme3_audio_android_AndroidALC_createALC + (JNIEnv* env, jobject obj) +{ + created = (InitAL() == 0); +} + +JNIEXPORT void JNICALL Java_com_jme3_audio_android_AndroidALC_destroyALC + (JNIEnv* env, jobject obj) +{ + CloseAL(); + created = JNI_FALSE; +} + +JNIEXPORT jstring JNICALL Java_com_jme3_audio_android_AndroidALC_alcGetString + (JNIEnv* env, jobject obj, jint param) +{ + ALCdevice* device = GetALCDevice(); + if (device == NULL) return NULL; + return (*env)->NewStringUTF(env, alcGetString(device, param)); +} + +JNIEXPORT jboolean JNICALL Java_com_jme3_audio_android_AndroidALC_alcIsExtensionPresent + (JNIEnv* env, jobject obj, jstring extension) +{ + ALCdevice* device = GetALCDevice(); + + if (device == NULL) return JNI_FALSE; + + const char* strExtension = (*env)->GetStringUTFChars(env, extension, NULL); + + if (strExtension == NULL) + { + return JNI_FALSE; + } + + jboolean result = alcIsExtensionPresent(device, strExtension); + + (*env)->ReleaseStringUTFChars(env, extension, strExtension); + + return result; +} + +JNIEXPORT void JNICALL Java_com_jme3_audio_android_AndroidALC_alcGetInteger + (JNIEnv* env, jobject obj, jint param, jobject buffer, jint bufferSize) +{ + ALCdevice* device = GetALCDevice(); + + if (device == NULL) return; + + ALCint* pBuffers = (ALCint*) (*env)->GetDirectBufferAddress(env, buffer); + + alcGetIntegerv(device, (ALCenum)param, (ALCsizei)bufferSize, pBuffers); +} + +JNIEXPORT void JNICALL Java_com_jme3_audio_android_AndroidALC_alcDevicePauseSOFT + (JNIEnv* env, jobject obj) +{ + ALCdevice* device = GetALCDevice(); + + if (device == NULL) return; + + alcDevicePauseSOFT(device); +} + +JNIEXPORT void JNICALL Java_com_jme3_audio_android_AndroidALC_alcDeviceResumeSOFT + (JNIEnv* env, jobject obj) +{ + ALCdevice* device = GetALCDevice(); + + if (device == NULL) return; + + alcDeviceResumeSOFT(device); +} \ No newline at end of file diff --git a/jme3-android-native/src/native/jme_openalsoft/com_jme3_audio_android_AndroidALC.h b/jme3-android-native/src/native/jme_openalsoft/com_jme3_audio_android_AndroidALC.h new file mode 100644 index 000000000..e50b7b511 --- /dev/null +++ b/jme3-android-native/src/native/jme_openalsoft/com_jme3_audio_android_AndroidALC.h @@ -0,0 +1,77 @@ +/* DO NOT EDIT THIS FILE - it is machine generated */ +#include +/* Header for class com_jme3_audio_android_AndroidALC */ + +#ifndef _Included_com_jme3_audio_android_AndroidALC +#define _Included_com_jme3_audio_android_AndroidALC +#ifdef __cplusplus +extern "C" { +#endif +/* + * Class: com_jme3_audio_android_AndroidALC + * Method: createALC + * Signature: ()V + */ +JNIEXPORT void JNICALL Java_com_jme3_audio_android_AndroidALC_createALC + (JNIEnv *, jobject); + +/* + * Class: com_jme3_audio_android_AndroidALC + * Method: destroyALC + * Signature: ()V + */ +JNIEXPORT void JNICALL Java_com_jme3_audio_android_AndroidALC_destroyALC + (JNIEnv *, jobject); + +/* + * Class: com_jme3_audio_android_AndroidALC + * Method: isCreated + * Signature: ()Z + */ +JNIEXPORT jboolean JNICALL Java_com_jme3_audio_android_AndroidALC_isCreated + (JNIEnv *, jobject); + +/* + * Class: com_jme3_audio_android_AndroidALC + * Method: alcGetString + * Signature: (I)Ljava/lang/String; + */ +JNIEXPORT jstring JNICALL Java_com_jme3_audio_android_AndroidALC_alcGetString + (JNIEnv *, jobject, jint); + +/* + * Class: com_jme3_audio_android_AndroidALC + * Method: alcIsExtensionPresent + * Signature: (Ljava/lang/String;)Z + */ +JNIEXPORT jboolean JNICALL Java_com_jme3_audio_android_AndroidALC_alcIsExtensionPresent + (JNIEnv *, jobject, jstring); + +/* + * Class: com_jme3_audio_android_AndroidALC + * Method: alcGetInteger + * Signature: (ILjava/nio/IntBuffer;I)V + */ +JNIEXPORT void JNICALL Java_com_jme3_audio_android_AndroidALC_alcGetInteger + (JNIEnv *, jobject, jint, jobject, jint); + +/* + * Class: com_jme3_audio_android_AndroidALC + * Method: alcDevicePauseSOFT + * Signature: ()V + */ +JNIEXPORT void JNICALL Java_com_jme3_audio_android_AndroidALC_alcDevicePauseSOFT + (JNIEnv *, jobject); + +/* + * Class: com_jme3_audio_android_AndroidALC + * Method: alcDeviceResumeSOFT + * Signature: ()V + */ +JNIEXPORT void JNICALL Java_com_jme3_audio_android_AndroidALC_alcDeviceResumeSOFT + (JNIEnv *, jobject); + +#ifdef __cplusplus +} +#endif +#endif diff --git a/jme3-android-native/src/native/jme_openalsoft/com_jme3_audio_android_AndroidEFX.c b/jme3-android-native/src/native/jme_openalsoft/com_jme3_audio_android_AndroidEFX.c new file mode 100644 index 000000000..ea50c2672 --- /dev/null +++ b/jme3-android-native/src/native/jme_openalsoft/com_jme3_audio_android_AndroidEFX.c @@ -0,0 +1,75 @@ +#include "util.h" +#include "com_jme3_audio_android_AndroidEFX.h" +#include "AL/alext.h" + +JNIEXPORT void JNICALL Java_com_jme3_audio_android_AndroidEFX_alGenAuxiliaryEffectSlots + (JNIEnv* env, jobject obj, jint numSlots, jobject buffer) +{ + ALuint* pBuffers = (ALuint*) (*env)->GetDirectBufferAddress(env, buffer); + alGenAuxiliaryEffectSlots((ALsizei)numSlots, pBuffers); +} + +JNIEXPORT void JNICALL Java_com_jme3_audio_android_AndroidEFX_alGenEffects + (JNIEnv* env, jobject obj, jint numEffects, jobject buffer) +{ + ALuint* pBuffers = (ALuint*) (*env)->GetDirectBufferAddress(env, buffer); + alGenEffects((ALsizei)numEffects, pBuffers); +} + +JNIEXPORT void JNICALL Java_com_jme3_audio_android_AndroidEFX_alEffecti + (JNIEnv* env, jobject obj, jint effect, jint param, jint value) +{ + alEffecti((ALuint)effect, (ALenum)param, (ALint)value); +} + +JNIEXPORT void JNICALL Java_com_jme3_audio_android_AndroidEFX_alAuxiliaryEffectSloti + (JNIEnv* env, jobject obj, jint effectSlot, jint param, jint value) +{ + alAuxiliaryEffectSloti((ALuint)effectSlot, (ALenum)param, (ALint)value); +} + +JNIEXPORT void JNICALL Java_com_jme3_audio_android_AndroidEFX_alDeleteEffects + (JNIEnv* env, jobject obj, jint numEffects, jobject buffer) +{ + ALuint* pBuffers = (ALuint*) (*env)->GetDirectBufferAddress(env, buffer); + alDeleteEffects((ALsizei)numEffects, pBuffers); +} + +JNIEXPORT void JNICALL Java_com_jme3_audio_android_AndroidEFX_alDeleteAuxiliaryEffectSlots + (JNIEnv* env, jobject obj, jint numEffectSlots, jobject buffer) +{ + ALuint* pBuffers = (ALuint*) (*env)->GetDirectBufferAddress(env, buffer); + alDeleteAuxiliaryEffectSlots((ALsizei)numEffectSlots, pBuffers); +} + +JNIEXPORT void JNICALL Java_com_jme3_audio_android_AndroidEFX_alGenFilters + (JNIEnv* env, jobject obj, jint numFilters, jobject buffer) +{ + ALuint* pBuffers = (ALuint*) (*env)->GetDirectBufferAddress(env, buffer); + alGenFilters((ALsizei)numFilters, pBuffers); +} + +JNIEXPORT void JNICALL Java_com_jme3_audio_android_AndroidEFX_alFilteri + (JNIEnv* env, jobject obj, jint filter, jint param, jint value) +{ + alFilteri((ALuint)filter, (ALenum)param, (ALint)value); +} + +JNIEXPORT void JNICALL Java_com_jme3_audio_android_AndroidEFX_alFilterf + (JNIEnv* env, jobject obj, jint filter, jint param, jfloat value) +{ + alFilterf((ALuint)filter, (ALenum)param, (ALfloat)value); +} + +JNIEXPORT void JNICALL Java_com_jme3_audio_android_AndroidEFX_alDeleteFilters + (JNIEnv* env, jobject obj, jint numFilters, jobject buffer) +{ + ALuint* pBuffers = (ALuint*) (*env)->GetDirectBufferAddress(env, buffer); + alDeleteFilters((ALsizei)numFilters, pBuffers); +} + +JNIEXPORT void JNICALL Java_com_jme3_audio_android_AndroidEFX_alEffectf + (JNIEnv* env, jobject obj, jint effect, jint param, jfloat value) +{ + alEffectf((ALuint)effect, (ALenum)param, (ALfloat)value); +} \ No newline at end of file diff --git a/jme3-android-native/src/native/jme_openalsoft/com_jme3_audio_android_AndroidEFX.h b/jme3-android-native/src/native/jme_openalsoft/com_jme3_audio_android_AndroidEFX.h new file mode 100644 index 000000000..4bdd94f07 --- /dev/null +++ b/jme3-android-native/src/native/jme_openalsoft/com_jme3_audio_android_AndroidEFX.h @@ -0,0 +1,101 @@ +/* DO NOT EDIT THIS FILE - it is machine generated */ +#include +/* Header for class com_jme3_audio_android_AndroidEFX */ + +#ifndef _Included_com_jme3_audio_android_AndroidEFX +#define _Included_com_jme3_audio_android_AndroidEFX +#ifdef __cplusplus +extern "C" { +#endif +/* + * Class: com_jme3_audio_android_AndroidEFX + * Method: alGenAuxiliaryEffectSlots + * Signature: (ILjava/nio/IntBuffer;)V + */ +JNIEXPORT void JNICALL Java_com_jme3_audio_android_AndroidEFX_alGenAuxiliaryEffectSlots + (JNIEnv *, jobject, jint, jobject); + +/* + * Class: com_jme3_audio_android_AndroidEFX + * Method: alGenEffects + * Signature: (ILjava/nio/IntBuffer;)V + */ +JNIEXPORT void JNICALL Java_com_jme3_audio_android_AndroidEFX_alGenEffects + (JNIEnv *, jobject, jint, jobject); + +/* + * Class: com_jme3_audio_android_AndroidEFX + * Method: alEffecti + * Signature: (III)V + */ +JNIEXPORT void JNICALL Java_com_jme3_audio_android_AndroidEFX_alEffecti + (JNIEnv *, jobject, jint, jint, jint); + +/* + * Class: com_jme3_audio_android_AndroidEFX + * Method: alAuxiliaryEffectSloti + * Signature: (III)V + */ +JNIEXPORT void JNICALL Java_com_jme3_audio_android_AndroidEFX_alAuxiliaryEffectSloti + (JNIEnv *, jobject, jint, jint, jint); + +/* + * Class: com_jme3_audio_android_AndroidEFX + * Method: alDeleteEffects + * Signature: (ILjava/nio/IntBuffer;)V + */ +JNIEXPORT void JNICALL Java_com_jme3_audio_android_AndroidEFX_alDeleteEffects + (JNIEnv *, jobject, jint, jobject); + +/* + * Class: com_jme3_audio_android_AndroidEFX + * Method: alDeleteAuxiliaryEffectSlots + * Signature: (ILjava/nio/IntBuffer;)V + */ +JNIEXPORT void JNICALL Java_com_jme3_audio_android_AndroidEFX_alDeleteAuxiliaryEffectSlots + (JNIEnv *, jobject, jint, jobject); + +/* + * Class: com_jme3_audio_android_AndroidEFX + * Method: alGenFilters + * Signature: (ILjava/nio/IntBuffer;)V + */ +JNIEXPORT void JNICALL Java_com_jme3_audio_android_AndroidEFX_alGenFilters + (JNIEnv *, jobject, jint, jobject); + +/* + * Class: com_jme3_audio_android_AndroidEFX + * Method: alFilteri + * Signature: (III)V + */ +JNIEXPORT void JNICALL Java_com_jme3_audio_android_AndroidEFX_alFilteri + (JNIEnv *, jobject, jint, jint, jint); + +/* + * Class: com_jme3_audio_android_AndroidEFX + * Method: alFilterf + * Signature: (IIF)V + */ +JNIEXPORT void JNICALL Java_com_jme3_audio_android_AndroidEFX_alFilterf + (JNIEnv *, jobject, jint, jint, jfloat); + +/* + * Class: com_jme3_audio_android_AndroidEFX + * Method: alDeleteFilters + * Signature: (ILjava/nio/IntBuffer;)V + */ +JNIEXPORT void JNICALL Java_com_jme3_audio_android_AndroidEFX_alDeleteFilters + (JNIEnv *, jobject, jint, jobject); + +/* + * Class: com_jme3_audio_android_AndroidEFX + * Method: alEffectf + * Signature: (IIF)V + */ +JNIEXPORT void JNICALL Java_com_jme3_audio_android_AndroidEFX_alEffectf + (JNIEnv *, jobject, jint, jint, jfloat); + +#ifdef __cplusplus +} +#endif +#endif diff --git a/jme3-android-native/src/native/jme_openalsoft/com_jme3_audio_android_AndroidOpenALSoftAudioRenderer.cpp b/jme3-android-native/src/native/jme_openalsoft/com_jme3_audio_android_AndroidOpenALSoftAudioRenderer.cpp deleted file mode 100644 index 3f118e497..000000000 --- a/jme3-android-native/src/native/jme_openalsoft/com_jme3_audio_android_AndroidOpenALSoftAudioRenderer.cpp +++ /dev/null @@ -1,483 +0,0 @@ -#include "com_jme3_audio_android_AndroidOpenALSoftAudioRenderer.h" -#include "AL/alc.h" -#include "AL/al.h" -#include "AL/alext.h" -// for __android_log_print(ANDROID_LOG_INFO, "YourApp", "formatted message"); -#include -#include -#include -#include -#include -#include -#include - -#ifdef __cplusplus -extern "C" { -#endif - -static jboolean created = JNI_FALSE; - -#define BUFFER_COUNT 1 -ALuint* buffers[BUFFER_COUNT] = { 0 }; -ALuint* source = 0; - -int getError() { - int errorcode = alGetError(); -// __android_log_print(ANDROID_LOG_INFO, "OpenAL Soft", "getError: %d", errorcode); - return errorcode; -} - -/* InitAL opens the default device and sets up a context using default - * attributes, making the program ready to call OpenAL functions. */ -int InitAL() -{ - ALCdevice *device; - ALCcontext *ctx; - - /* Open and initialize a device with default settings */ - device = alcOpenDevice(NULL); - if(!device) - { - fprintf(stderr, "Could not open a device!\n"); - return 1; - } - - ctx = alcCreateContext(device, NULL); -// __android_log_print(ANDROID_LOG_INFO, "OpenAL Soft", "NULL: %d", NULL); -// __android_log_print(ANDROID_LOG_INFO, "OpenAL Soft", "Created context: %d", ctx); -// __android_log_print(ANDROID_LOG_INFO, "OpenAL Soft", "Created context addr: %d", &ctx); - if(ctx == NULL || alcMakeContextCurrent(ctx) == ALC_FALSE) - { - if(ctx != NULL) - alcDestroyContext(ctx); - alcCloseDevice(device); - fprintf(stderr, "Could not set a context!\n"); - return 1; - } - - printf("Opened \"%s\"\n", alcGetString(device, ALC_DEVICE_SPECIFIER)); - __android_log_print(ANDROID_LOG_INFO, "OpenAL Soft", "Opened %s", alcGetString(device, ALC_DEVICE_SPECIFIER)); - return 0; -} - -/* CloseAL closes the device belonging to the current context, and destroys the - * context. */ -void CloseAL() -{ - ALCdevice *device; - ALCcontext *ctx; - ALCboolean result; - -// __android_log_print(ANDROID_LOG_INFO, "OpenAL Soft", "Getting current context"); - ctx = alcGetCurrentContext(); -// getError(); - if(ctx == NULL){ - __android_log_print(ANDROID_LOG_INFO, "OpenAL Soft", "No context found"); - return; - } - -// __android_log_print(ANDROID_LOG_INFO, "OpenAL Soft", "Getting current context device"); - device = alcGetContextsDevice(ctx); - if(device == NULL) { - __android_log_print(ANDROID_LOG_INFO, "OpenAL Soft", "No device found"); - return; - } else { -// __android_log_print(ANDROID_LOG_INFO, "OpenAL Soft", "alcGetContextsDevice device: %d", device); -// __android_log_print(ANDROID_LOG_INFO, "OpenAL Soft", "alcGetContextsDevice device addr: %d", &device); - } -// getError(); - -// __android_log_print(ANDROID_LOG_INFO, "OpenAL Soft", "Setting context to NULL"); - result = alcMakeContextCurrent(NULL); -// __android_log_print(ANDROID_LOG_INFO, "OpenAL Soft", "alcMakeContextCurrent returned"); -// __android_log_print(ANDROID_LOG_INFO, "OpenAL Soft", "alcMakeContextCurrent returned with result: %d", result); - if(!result) { - __android_log_print(ANDROID_LOG_INFO, "OpenAL Soft", "alcMakeContextCurrent failed"); - return; - } - -// __android_log_print(ANDROID_LOG_INFO, "OpenAL Soft", "Destroying context: %d", ctx); -// __android_log_print(ANDROID_LOG_INFO, "OpenAL Soft", "Destroying context addr: %d", &ctx); - alcDestroyContext(ctx); - -// __android_log_print(ANDROID_LOG_INFO, "OpenAL Soft", "Closing device"); - result = alcCloseDevice(device); -// __android_log_print(ANDROID_LOG_INFO, "OpenAL Soft", "alcCloseDevice result: %d", result); -} - - -JNIEXPORT jboolean JNICALL Java_com_jme3_audio_android_AndroidOpenALSoftAudioRenderer_alIsCreated - (JNIEnv* env, jclass) -{ - return created; -} - - -JNIEXPORT jboolean JNICALL Java_com_jme3_audio_android_AndroidOpenALSoftAudioRenderer_alCreate - (JNIEnv* env, jclass) -{ - __android_log_print(ANDROID_LOG_INFO, "OpenAL Soft", "Starting Audio Engine"); - - InitAL(); - created = JNI_TRUE; - return created; - -} - -JNIEXPORT jboolean JNICALL Java_com_jme3_audio_android_AndroidOpenALSoftAudioRenderer_alDestroy - (JNIEnv* env, jclass) -{ - -// __android_log_print(ANDROID_LOG_INFO, "OpenAL Soft", "alDestroy"); - CloseAL(); - created = JNI_FALSE; - return created; - -} - -JNIEXPORT jstring JNICALL Java_com_jme3_audio_android_AndroidOpenALSoftAudioRenderer_alcGetString - (JNIEnv* env, jclass, jint param) -{ -// __android_log_print(ANDROID_LOG_INFO, "OpenAL Soft", "alcGetString for param: %d", param); - - ALCdevice *device; - ALCcontext *ctx; - - ctx = alcGetCurrentContext(); - if(ctx != NULL) { - device = alcGetContextsDevice(ctx); -// __android_log_print(ANDROID_LOG_INFO, "OpenAL Soft", "alcGetString param value: %s", alcGetString(device, param)); - return env->NewStringUTF(alcGetString(device, param)); - } -} - -JNIEXPORT jstring JNICALL Java_com_jme3_audio_android_AndroidOpenALSoftAudioRenderer_alGetString - (JNIEnv* env, jclass, jint param) -{ -// __android_log_print(ANDROID_LOG_INFO, "OpenAL Soft", "alGetString for param: %d", param); -// __android_log_print(ANDROID_LOG_INFO, "OpenAL Soft", "alGetString param value: %s", alGetString(param)); - return env->NewStringUTF(alGetString(param)); -} - -JNIEXPORT jint JNICALL Java_com_jme3_audio_android_AndroidOpenALSoftAudioRenderer_alGenSources - (JNIEnv *, jclass) -{ - ALuint source; - alGenSources(1, &source); -// __android_log_print(ANDROID_LOG_INFO, "OpenAL Soft", "alGenSources: %d", source); - return source; -} - -JNIEXPORT jint JNICALL Java_com_jme3_audio_android_AndroidOpenALSoftAudioRenderer_alGetError - (JNIEnv *, jclass) -{ - return getError(); -} - -JNIEXPORT void JNICALL Java_com_jme3_audio_android_AndroidOpenALSoftAudioRenderer_alDeleteSources - (JNIEnv* env, jclass, jint numSources, jobject intbufSources) -{ -// __android_log_print(ANDROID_LOG_INFO, "OpenAL Soft", "alDeleteSources numSources: %d", numSources); - - ALuint* pIntBufSources = (ALuint*) env->GetDirectBufferAddress(intbufSources); - alDeleteSources((ALsizei)numSources, pIntBufSources); -} - -JNIEXPORT void JNICALL Java_com_jme3_audio_android_AndroidOpenALSoftAudioRenderer_alGenBuffers - (JNIEnv* env, jclass, jint numBuffers, jobject intbufBuffers) -{ - ALuint* pIntBufBuffers = (ALuint*) env->GetDirectBufferAddress(intbufBuffers); - alGenBuffers((ALsizei)numBuffers, pIntBufBuffers); -// for (int i=0; iGetDirectBufferAddress(intbufBuffers); -// __android_log_print(ANDROID_LOG_INFO, "OpenAL Soft", "alDeleteBuffers Buffers: %d", *pIntBufBuffers); -// for (int i=0; iGetDirectBufferAddress(bufferData); - alBufferData((ALuint)buffer, (ALenum)format, pBufferData, (ALsizei)bufferSize, (ALsizei)frequency); -} - -JNIEXPORT void JNICALL Java_com_jme3_audio_android_AndroidOpenALSoftAudioRenderer_alSourcePlay - (JNIEnv *, jclass, jint source) -{ -// __android_log_print(ANDROID_LOG_INFO, "OpenAL Soft", "alSourcePlay for source: %d", source); - alSourcePlay((ALuint)source); -} - -JNIEXPORT void JNICALL Java_com_jme3_audio_android_AndroidOpenALSoftAudioRenderer_alSourcePause - (JNIEnv *, jclass, jint source) -{ -// __android_log_print(ANDROID_LOG_INFO, "OpenAL Soft", "alSourcePause for source: %d", source); - alSourcePause((ALuint)source); -} - -JNIEXPORT void JNICALL Java_com_jme3_audio_android_AndroidOpenALSoftAudioRenderer_alSourcef - (JNIEnv *, jclass, jint source, jint param, jfloat value) -{ -// __android_log_print(ANDROID_LOG_INFO, "OpenAL Soft", "alSourcef for source: %d, param: %d, value: %f", source, param, value); - alSourcef((ALuint)source, (ALenum)param, (ALfloat)value); -} - -JNIEXPORT void JNICALL Java_com_jme3_audio_android_AndroidOpenALSoftAudioRenderer_alSource3f - (JNIEnv *, jclass, jint source, jint param, jfloat value1, jfloat value2, jfloat value3) -{ -// __android_log_print(ANDROID_LOG_INFO, "OpenAL Soft", "alSource3f for source: %d, param: %d, value1: %f, value2: %f, value3: %f", source, param, value1, value2, value3); - alSource3f((ALuint)source, (ALenum)param, (ALfloat)value1, (ALfloat)value2, (ALfloat)value3); -} - -JNIEXPORT jint JNICALL Java_com_jme3_audio_android_AndroidOpenALSoftAudioRenderer_alGetSourcei - (JNIEnv *, jclass, jint source, jint param) -{ -// __android_log_print(ANDROID_LOG_INFO, "OpenAL Soft", "alGetSourcei for source: %d, param: %d", source, param); - ALint result; - alGetSourcei((ALuint)source, (ALenum)param, &result); - return (jint)result; -} - -JNIEXPORT void JNICALL Java_com_jme3_audio_android_AndroidOpenALSoftAudioRenderer_alSourceUnqueueBuffers - (JNIEnv* env, jclass, jint source, jint numBuffers, jobject buffers) -{ -// __android_log_print(ANDROID_LOG_INFO, "OpenAL Soft", "alSourceUnqueueBuffers for source: %d, numBuffers: %d", source, numBuffers); - ALuint* pBuffers = (ALuint*) env->GetDirectBufferAddress(buffers); - -// for (ALuint i=0; iGetDirectBufferAddress(buffers); - alSourceQueueBuffers((ALuint)source, (ALsizei)numBuffers, pBuffers); -// for (ALuint i=0; iGetDirectBufferAddress(bufferData); - alListenerfv((ALenum)param, pBufferData); -// getError(); -// for (int i=0; i<4; i++) { -// __android_log_print(ANDROID_LOG_INFO, "OpenAL Soft", "alListener[%d]: %f", i, *(pBufferData+(i*sizeof(ALfloat)))); -// } - -} - -JNIEXPORT void JNICALL Java_com_jme3_audio_android_AndroidOpenALSoftAudioRenderer_alListenerf - (JNIEnv *, jclass, jint param, jfloat value) -{ -// __android_log_print(ANDROID_LOG_INFO, "OpenAL Soft", "alListenerf for param: %d, value: %f", param, value); - alListenerf((ALenum)param, (ALfloat)value); -} - -JNIEXPORT void JNICALL Java_com_jme3_audio_android_AndroidOpenALSoftAudioRenderer_alListener3f - (JNIEnv *, jclass, jint param, jfloat value1, jfloat value2, jfloat value3) -{ -// __android_log_print(ANDROID_LOG_INFO, "OpenAL Soft", "alListener3f for param: %d, value1: %f, value2: %f, value3: %f", param, value1, value2, value3); - alListener3f((ALenum)param, (ALfloat)value1, (ALfloat)value2, (ALfloat)value3); -} - -JNIEXPORT jboolean JNICALL Java_com_jme3_audio_android_AndroidOpenALSoftAudioRenderer_alcIsExtensionPresent - (JNIEnv* env, jclass, jstring extension) -{ - - ALCdevice *device; - ALCcontext *ctx; - ALboolean result; -// char buf[128]; - const char* strExtension; - jsize strLength = env->GetStringUTFLength(extension); - - ctx = alcGetCurrentContext(); - if(ctx != NULL) { - device = alcGetContextsDevice(ctx); - - if (device != NULL) { - strExtension = env->GetStringUTFChars(extension, NULL); - if (strExtension == NULL) { - return JNI_FALSE; /* OutOfMemoryError already thrown */ - } -// __android_log_print(ANDROID_LOG_INFO, "OpenAL Soft", "alcIsExtensionPresent for param: %s with size: %d", strExtension, strLength); - - result = alcIsExtensionPresent(device, strExtension); -// __android_log_print(ANDROID_LOG_INFO, "OpenAL Soft", "alcIsExtensionPresent found: %d", result); - - env->ReleaseStringUTFChars(extension, strExtension); - - return (jboolean)result; - } else { - __android_log_print(ANDROID_LOG_INFO, "OpenAL Soft", "device is null in alcIsExtensionPresent"); - } - - } else { - __android_log_print(ANDROID_LOG_INFO, "OpenAL Soft", "current context is null in alcIsExtensionPresent"); - } - - return JNI_FALSE; -} - -JNIEXPORT void JNICALL Java_com_jme3_audio_android_AndroidOpenALSoftAudioRenderer_alcGetInteger - (JNIEnv* env, jclass, jint param, jobject buffer, jint bufferSize) -{ - ALCdevice *device; - ALCcontext *ctx; - -// __android_log_print(ANDROID_LOG_INFO, "OpenAL Soft", "alcGetInteger for param: %d", param); - ALCint* pBuffers = (ALCint*) env->GetDirectBufferAddress(buffer); - - ctx = alcGetCurrentContext(); - if(ctx != NULL) { - device = alcGetContextsDevice(ctx); - - if (device != NULL) { - alcGetIntegerv(device, (ALCenum)param, (ALCsizei)bufferSize, pBuffers); - } else { - __android_log_print(ANDROID_LOG_INFO, "OpenAL Soft", "device is null in alcGetInteger"); - } - - } else { - __android_log_print(ANDROID_LOG_INFO, "OpenAL Soft", "current context is null in alcGetInteger"); - } -} - -JNIEXPORT void JNICALL Java_com_jme3_audio_android_AndroidOpenALSoftAudioRenderer_alGenAuxiliaryEffectSlots - (JNIEnv* env, jclass, jint numSlots, jobject buffer) -{ -// __android_log_print(ANDROID_LOG_INFO, "OpenAL Soft", "alGenAuxiliaryEffectSlots for numSlots: %d", numSlots); - ALuint* pBuffers = (ALuint*) env->GetDirectBufferAddress(buffer); - alGenAuxiliaryEffectSlots((ALsizei)numSlots, pBuffers); -} - -JNIEXPORT void JNICALL Java_com_jme3_audio_android_AndroidOpenALSoftAudioRenderer_alGenEffects - (JNIEnv* env, jclass, jint numEffects, jobject buffer) -{ -// __android_log_print(ANDROID_LOG_INFO, "OpenAL Soft", "alGenEffects for numEffects: %d", numEffects); - ALuint* pBuffers = (ALuint*) env->GetDirectBufferAddress(buffer); - alGenEffects((ALsizei)numEffects, pBuffers); -} - -JNIEXPORT void JNICALL Java_com_jme3_audio_android_AndroidOpenALSoftAudioRenderer_alEffecti - (JNIEnv *, jclass, jint effect, jint param, jint value) -{ -// __android_log_print(ANDROID_LOG_INFO, "OpenAL Soft", "alEffecti for effect: %d, param: %d, value: %d", effect, param, value); - alEffecti((ALuint)effect, (ALenum)param, (ALint)value); -} - -JNIEXPORT void JNICALL Java_com_jme3_audio_android_AndroidOpenALSoftAudioRenderer_alAuxiliaryEffectSloti - (JNIEnv *, jclass, jint effectSlot, jint param, jint value) -{ -// __android_log_print(ANDROID_LOG_INFO, "OpenAL Soft", "alAuxiliaryEffectSloti for effect: %d, param: %d, value: %d", effectSlot, param, value); - alAuxiliaryEffectSloti((ALuint)effectSlot, (ALenum)param, (ALint)value); -} - -JNIEXPORT void JNICALL Java_com_jme3_audio_android_AndroidOpenALSoftAudioRenderer_alDeleteEffects - (JNIEnv* env, jclass, jint numEffects, jobject buffer) -{ -// __android_log_print(ANDROID_LOG_INFO, "OpenAL Soft", "alDeleteEffects for numEffects: %d", numEffects); - ALuint* pBuffers = (ALuint*) env->GetDirectBufferAddress(buffer); - alDeleteEffects((ALsizei)numEffects, pBuffers); -} - -JNIEXPORT void JNICALL Java_com_jme3_audio_android_AndroidOpenALSoftAudioRenderer_alDeleteAuxiliaryEffectSlots - (JNIEnv* env, jclass, jint numEffectSlots, jobject buffer) -{ -// __android_log_print(ANDROID_LOG_INFO, "OpenAL Soft", "alDeleteAuxiliaryEffectSlots for numEffectSlots: %d", numEffectSlots); - ALuint* pBuffers = (ALuint*) env->GetDirectBufferAddress(buffer); - alDeleteAuxiliaryEffectSlots((ALsizei)numEffectSlots, pBuffers); -} - -JNIEXPORT void JNICALL Java_com_jme3_audio_android_AndroidOpenALSoftAudioRenderer_alGenFilters - (JNIEnv* env, jclass, jint numFilters, jobject buffer) -{ -// __android_log_print(ANDROID_LOG_INFO, "OpenAL Soft", "alGenFilters for numFilters: %d", numFilters); - ALuint* pBuffers = (ALuint*) env->GetDirectBufferAddress(buffer); - alGenFilters((ALsizei)numFilters, pBuffers); -} - -JNIEXPORT void JNICALL Java_com_jme3_audio_android_AndroidOpenALSoftAudioRenderer_alFilteri - (JNIEnv *, jclass, jint filter, jint param, jint value) -{ -// __android_log_print(ANDROID_LOG_INFO, "OpenAL Soft", "alFilteri for filter: %d, param: %d, value: %d", filter, param, value); - alFilteri((ALuint)filter, (ALenum)param, (ALint)value); -} - -JNIEXPORT void JNICALL Java_com_jme3_audio_android_AndroidOpenALSoftAudioRenderer_alFilterf - (JNIEnv *, jclass, jint filter, jint param, jfloat value) -{ -// __android_log_print(ANDROID_LOG_INFO, "OpenAL Soft", "alFilterf for filter: %d, param: %d, value: %f", filter, param, value); - alFilterf((ALuint)filter, (ALenum)param, (ALfloat)value); -} - -JNIEXPORT void JNICALL Java_com_jme3_audio_android_AndroidOpenALSoftAudioRenderer_alSource3i - (JNIEnv *, jclass, jint source, jint param, jint value1, jint value2, jint value3) -{ -// __android_log_print(ANDROID_LOG_INFO, "OpenAL Soft", "alSource3i for source: %d, param: %d, value1: %d, value2: %d, value3: %d", source, param, value1, value2, value3); - alSource3i((ALuint)source, (ALenum)param, (ALint)value1, (ALint)value2, (ALint)value3); -} - -JNIEXPORT void JNICALL Java_com_jme3_audio_android_AndroidOpenALSoftAudioRenderer_alDeleteFilters - (JNIEnv* env, jclass, jint numFilters, jobject buffer) -{ -// __android_log_print(ANDROID_LOG_INFO, "OpenAL Soft", "alDeleteFilters for numFilters: %d", numFilters); - ALuint* pBuffers = (ALuint*) env->GetDirectBufferAddress(buffer); - alDeleteFilters((ALsizei)numFilters, pBuffers); -} - -JNIEXPORT void JNICALL Java_com_jme3_audio_android_AndroidOpenALSoftAudioRenderer_alEffectf - (JNIEnv *, jclass, jint effect, jint param, jfloat value) -{ -// __android_log_print(ANDROID_LOG_INFO, "OpenAL Soft", "alEffectf for effect: %d, param: %d, value: %d", effect, param, value); - alEffectf((ALuint)effect, (ALenum)param, (ALfloat)value); -} - - -#ifdef __cplusplus -} -#endif diff --git a/jme3-android-native/src/native/jme_openalsoft/util.h b/jme3-android-native/src/native/jme_openalsoft/util.h new file mode 100644 index 000000000..5322d5634 --- /dev/null +++ b/jme3-android-native/src/native/jme_openalsoft/util.h @@ -0,0 +1,15 @@ +#ifndef JME_UTIL_H +#define JME_UTIL_H + +#include +#include + +#ifndef NDEBUG +#include +#define LOGI(fmt, ...) __android_log_print(ANDROID_LOG_INFO, \ + "OpenALSoft", fmt, ##__VA_ARGS__); +#else +#define LOGI(fmt, ...) +#endif + +#endif \ No newline at end of file diff --git a/jme3-android/src/main/java/com/jme3/app/AndroidHarness.java b/jme3-android/src/main/java/com/jme3/app/AndroidHarness.java index 0f50e0543..db1d52358 100644 --- a/jme3-android/src/main/java/com/jme3/app/AndroidHarness.java +++ b/jme3-android/src/main/java/com/jme3/app/AndroidHarness.java @@ -15,7 +15,6 @@ import android.widget.FrameLayout; import android.widget.ImageView; import android.widget.TextView; import com.jme3.audio.AudioRenderer; -import com.jme3.audio.android.AndroidAudioRenderer; import com.jme3.input.JoyInput; import com.jme3.input.TouchInput; import com.jme3.input.android.AndroidSensorJoyInput; @@ -522,12 +521,9 @@ public class AndroidHarness extends Activity implements TouchListener, DialogInt if (app != null) { //resume the audio - AudioRenderer result = app.getAudioRenderer(); - if (result != null) { - if (result instanceof AndroidAudioRenderer) { - AndroidAudioRenderer renderer = (AndroidAudioRenderer) result; - renderer.resumeAll(); - } + AudioRenderer audioRenderer = app.getAudioRenderer(); + if (audioRenderer != null) { + audioRenderer.resumeAll(); } //resume the sensors (aka joysticks) if (app.getContext() != null) { @@ -560,13 +556,9 @@ public class AndroidHarness extends Activity implements TouchListener, DialogInt if (app != null) { //pause the audio - AudioRenderer result = app.getAudioRenderer(); - if (result != null) { - logger.log(Level.FINE, "pause: {0}", result.getClass().getSimpleName()); - if (result instanceof AndroidAudioRenderer) { - AndroidAudioRenderer renderer = (AndroidAudioRenderer) result; - renderer.pauseAll(); - } + AudioRenderer audioRenderer = app.getAudioRenderer(); + if (audioRenderer != null) { + audioRenderer.pauseAll(); } //pause the sensors (aka joysticks) if (app.getContext() != null) { diff --git a/jme3-android/src/main/java/com/jme3/audio/android/AndroidAL.java b/jme3-android/src/main/java/com/jme3/audio/android/AndroidAL.java new file mode 100644 index 000000000..2a0634c91 --- /dev/null +++ b/jme3-android/src/main/java/com/jme3/audio/android/AndroidAL.java @@ -0,0 +1,53 @@ +package com.jme3.audio.android; + +import com.jme3.audio.openal.AL; +import java.nio.ByteBuffer; +import java.nio.FloatBuffer; +import java.nio.IntBuffer; + +public final class AndroidAL implements AL { + + public AndroidAL() { + } + + public native String alGetString(int parameter); + + public native int alGenSources(); + + public native int alGetError(); + + public native void alDeleteSources(int numSources, IntBuffer sources); + + public native void alGenBuffers(int numBuffers, IntBuffer buffers); + + public native void alDeleteBuffers(int numBuffers, IntBuffer buffers); + + public native void alSourceStop(int source); + + public native void alSourcei(int source, int param, int value); + + public native void alBufferData(int buffer, int format, ByteBuffer data, int size, int frequency); + + public native void alSourcePlay(int source); + + public native void alSourcePause(int source); + + public native void alSourcef(int source, int param, float value); + + public native void alSource3f(int source, int param, float value1, float value2, float value3); + + public native int alGetSourcei(int source, int param); + + public native void alSourceUnqueueBuffers(int source, int numBuffers, IntBuffer buffers); + + public native void alSourceQueueBuffers(int source, int numBuffers, IntBuffer buffers); + + public native void alListener(int param, FloatBuffer data); + + public native void alListenerf(int param, float value); + + public native void alListener3f(int param, float value1, float value2, float value3); + + public native void alSource3i(int source, int param, int value1, int value2, int value3); + +} diff --git a/jme3-android/src/main/java/com/jme3/audio/android/AndroidALC.java b/jme3-android/src/main/java/com/jme3/audio/android/AndroidALC.java new file mode 100644 index 000000000..a2f0a4eb6 --- /dev/null +++ b/jme3-android/src/main/java/com/jme3/audio/android/AndroidALC.java @@ -0,0 +1,30 @@ +package com.jme3.audio.android; + +import com.jme3.audio.openal.ALC; +import java.nio.IntBuffer; + +public final class AndroidALC implements ALC { + + static { + System.loadLibrary("openalsoftjme"); + } + + public AndroidALC() { + } + + public native void createALC(); + + public native void destroyALC(); + + public native boolean isCreated(); + + public native String alcGetString(int parameter); + + public native boolean alcIsExtensionPresent(String extension); + + public native void alcGetInteger(int param, IntBuffer buffer, int size); + + public native void alcDevicePauseSOFT(); + + public native void alcDeviceResumeSOFT(); +} diff --git a/jme3-android/src/main/java/com/jme3/audio/android/AndroidAudioRenderer.java b/jme3-android/src/main/java/com/jme3/audio/android/AndroidAudioRenderer.java deleted file mode 100644 index 0cde16aa5..000000000 --- a/jme3-android/src/main/java/com/jme3/audio/android/AndroidAudioRenderer.java +++ /dev/null @@ -1,24 +0,0 @@ -package com.jme3.audio.android; - -import com.jme3.audio.AudioRenderer; - -/** - * Android specific AudioRenderer interface that supports pausing and resuming - * audio files when the app is minimized or placed in the background - * - * @author iwgeric - */ -public interface AndroidAudioRenderer extends AudioRenderer { - - /** - * Pauses all Playing audio. To be used when the app is placed in the - * background. - */ - public void pauseAll(); - - /** - * Resumes all Paused audio. To be used when the app is brought back to - * the foreground. - */ - public void resumeAll(); -} diff --git a/jme3-android/src/main/java/com/jme3/audio/android/AndroidEFX.java b/jme3-android/src/main/java/com/jme3/audio/android/AndroidEFX.java new file mode 100644 index 000000000..271d2d507 --- /dev/null +++ b/jme3-android/src/main/java/com/jme3/audio/android/AndroidEFX.java @@ -0,0 +1,32 @@ +package com.jme3.audio.android; + +import com.jme3.audio.openal.EFX; +import java.nio.IntBuffer; + +public class AndroidEFX implements EFX { + + public AndroidEFX() { + } + + public native void alGenAuxiliaryEffectSlots(int numSlots, IntBuffer buffers); + + public native void alGenEffects(int numEffects, IntBuffer buffers); + + public native void alEffecti(int effect, int param, int value); + + public native void alAuxiliaryEffectSloti(int effectSlot, int param, int value); + + public native void alDeleteEffects(int numEffects, IntBuffer buffers); + + public native void alDeleteAuxiliaryEffectSlots(int numEffectSlots, IntBuffer buffers); + + public native void alGenFilters(int numFilters, IntBuffer buffers); + + public native void alFilteri(int filter, int param, int value); + + public native void alFilterf(int filter, int param, float value); + + public native void alDeleteFilters(int numFilters, IntBuffer buffers); + + public native void alEffectf(int effect, int param, float value); +} diff --git a/jme3-android/src/main/java/com/jme3/audio/android/AndroidMediaPlayerAudioRenderer.java b/jme3-android/src/main/java/com/jme3/audio/android/AndroidMediaPlayerAudioRenderer.java index 52c4c8fdb..05779ab07 100644 --- a/jme3-android/src/main/java/com/jme3/audio/android/AndroidMediaPlayerAudioRenderer.java +++ b/jme3-android/src/main/java/com/jme3/audio/android/AndroidMediaPlayerAudioRenderer.java @@ -54,7 +54,7 @@ import java.util.logging.Logger; * @author larynx * @author plan_rich */ -public class AndroidMediaPlayerAudioRenderer implements AndroidAudioRenderer, +public class AndroidMediaPlayerAudioRenderer implements AudioRenderer, SoundPool.OnLoadCompleteListener, MediaPlayer.OnCompletionListener { private static final Logger logger = Logger.getLogger(AndroidMediaPlayerAudioRenderer.class.getName()); diff --git a/jme3-android/src/main/java/com/jme3/audio/android/AndroidOpenALSoftAudioRenderer.java b/jme3-android/src/main/java/com/jme3/audio/android/AndroidOpenALSoftAudioRenderer.java deleted file mode 100644 index e5c98ebec..000000000 --- a/jme3-android/src/main/java/com/jme3/audio/android/AndroidOpenALSoftAudioRenderer.java +++ /dev/null @@ -1,1423 +0,0 @@ -/* - * Copyright (c) 2009-2012 jMonkeyEngine - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are - * met: - * - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * - * * Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * * Neither the name of 'jMonkeyEngine' nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED - * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR - * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, - * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR - * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF - * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING - * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ -package com.jme3.audio.android; - -import com.jme3.audio.*; -import com.jme3.audio.AudioSource.Status; -import com.jme3.math.Vector3f; -import com.jme3.util.BufferUtils; -import com.jme3.util.NativeObjectManager; -import java.nio.ByteBuffer; -import java.nio.FloatBuffer; -import java.nio.IntBuffer; -import java.util.ArrayList; -import java.util.concurrent.atomic.AtomicBoolean; -import java.util.logging.Level; -import java.util.logging.Logger; - -public class AndroidOpenALSoftAudioRenderer implements AndroidAudioRenderer, Runnable { - - private static final Logger logger = Logger.getLogger(AndroidOpenALSoftAudioRenderer.class.getName()); - private final NativeObjectManager objManager = new NativeObjectManager(); - // When multiplied by STREAMING_BUFFER_COUNT, will equal 44100 * 2 * 2 - // which is exactly 1 second of audio. - private static final int BUFFER_SIZE = 35280; - private static final int STREAMING_BUFFER_COUNT = 5; - private final static int MAX_NUM_CHANNELS = 64; - private IntBuffer ib = BufferUtils.createIntBuffer(1); - private final FloatBuffer fb = BufferUtils.createVector3Buffer(2); - private final ByteBuffer nativeBuf = BufferUtils.createByteBuffer(BUFFER_SIZE); - private final byte[] arrayBuf = new byte[BUFFER_SIZE]; - private int[] channels; - private AudioSource[] chanSrcs; - private int nextChan = 0; - private ArrayList freeChans = new ArrayList(); - private Listener listener; - private boolean audioDisabled = false; - private boolean supportEfx = false; - private int auxSends = 0; - private int reverbFx = -1; - private int reverbFxSlot = -1; - // Update audio 20 times per second - private static final float UPDATE_RATE = 0.05f; - private final Thread audioThread = new Thread(this, "jME3 Audio Thread"); - private final AtomicBoolean threadLock = new AtomicBoolean(false); - private boolean initialized = false; - - public AndroidOpenALSoftAudioRenderer() { - } - - public void initialize() { - if (!audioThread.isAlive()) { - audioThread.setDaemon(true); - audioThread.setPriority(Thread.NORM_PRIORITY + 1); - audioThread.start(); - } else { - throw new IllegalStateException("Initialize already called"); - } - } - - private void checkDead() { - if (audioThread.getState() == Thread.State.TERMINATED) { - throw new IllegalStateException("Audio thread is terminated"); - } - } - - public void run() { - initInThread(); - synchronized (threadLock) { - threadLock.set(true); - threadLock.notifyAll(); - } - - initialized = true; - - long updateRateNanos = (long) (UPDATE_RATE * 1000000000); - mainloop: - while (true) { - long startTime = System.nanoTime(); - - if (Thread.interrupted()) { - break; - } - - synchronized (threadLock) { - updateInThread(UPDATE_RATE); - } - - long endTime = System.nanoTime(); - long diffTime = endTime - startTime; - - if (diffTime < updateRateNanos) { - long desiredEndTime = startTime + updateRateNanos; - while (System.nanoTime() < desiredEndTime) { - try { - Thread.sleep(1); - } catch (InterruptedException ex) { - break mainloop; - } - } - } - } - - initialized = false; - - synchronized (threadLock) { - cleanupInThread(); - } - } - - public void initInThread() { - try { - if (!alIsCreated()) { - //AL.create(); - alCreate(); - checkError(false); - } -// } catch (OpenALException ex) { -// logger.log(Level.SEVERE, "Failed to load audio library", ex); -// audioDisabled = true; -// return; -// } catch (LWJGLException ex) { -// logger.log(Level.SEVERE, "Failed to load audio library", ex); -// audioDisabled = true; -// return; - } catch (UnsatisfiedLinkError ex) { - logger.log(Level.SEVERE, "Failed to load audio library", ex); - audioDisabled = true; - return; - } - - //ALCdevice device = AL.getDevice(); /* device maintained in jni */ - //String deviceName = ALC10.alcGetString(device, ALC10.ALC_DEVICE_SPECIFIER); - String deviceName = alcGetString(AL.ALC_DEVICE_SPECIFIER); - - logger.log(Level.INFO, "Audio Device: {0}", deviceName); - //logger.log(Level.INFO, "Audio Vendor: {0}", alGetString(AL_VENDOR)); - //logger.log(Level.INFO, "Audio Renderer: {0}", alGetString(AL_RENDERER)); - //logger.log(Level.INFO, "Audio Version: {0}", alGetString(AL_VERSION)); - logger.log(Level.INFO, "Audio Vendor: {0}", alGetString(AL.AL_VENDOR)); - logger.log(Level.INFO, "Audio Renderer: {0}", alGetString(AL.AL_RENDERER)); - logger.log(Level.INFO, "Audio Version: {0}", alGetString(AL.AL_VERSION)); - - // Find maximum # of sources supported by this implementation - ArrayList channelList = new ArrayList(); - for (int i = 0; i < MAX_NUM_CHANNELS; i++) { - int chan = alGenSources(); - //if (alGetError() != 0) { - if (checkError(false) != 0) { - break; - } else { - channelList.add(chan); - } - } - - channels = new int[channelList.size()]; - for (int i = 0; i < channels.length; i++) { - channels[i] = channelList.get(i); - } - - ib = BufferUtils.createIntBuffer(channels.length); - chanSrcs = new AudioSource[channels.length]; - - logger.log(Level.INFO, "AudioRenderer supports {0} channels", channels.length); - - //supportEfx = alcIsExtensionPresent(device, "ALC_EXT_EFX"); - supportEfx = alcIsExtensionPresent(AL.ALC_EXT_EFX_NAME); - - if (supportEfx) { - ib.position(0).limit(1); - //ALC10.alcGetInteger(device, EFX10.ALC_EFX_MAJOR_VERSION, ib); - alcGetInteger(AL.ALC_EFX_MAJOR_VERSION, ib, 1); - int major = ib.get(0); - ib.position(0).limit(1); - //ALC10.alcGetInteger(device, EFX10.ALC_EFX_MINOR_VERSION, ib); - alcGetInteger(AL.ALC_EFX_MINOR_VERSION, ib, 1); - int minor = ib.get(0); - logger.log(Level.INFO, "Audio effect extension version: {0}.{1}", new Object[]{major, minor}); - - //ALC10.alcGetInteger(device, EFX10.ALC_MAX_AUXILIARY_SENDS, ib); - alcGetInteger(AL.ALC_MAX_AUXILIARY_SENDS, ib, 1); - auxSends = ib.get(0); - logger.log(Level.INFO, "Audio max auxilary sends: {0}", auxSends); - - // create slot - ib.position(0).limit(1); - //EFX10.alGenAuxiliaryEffectSlots(ib); - alGenAuxiliaryEffectSlots(1, ib); - reverbFxSlot = ib.get(0); - - // create effect - ib.position(0).limit(1); - //EFX10.alGenEffects(ib); - alGenEffects(1, ib); - reverbFx = ib.get(0); - //EFX10.alEffecti(reverbFx, EFX10.AL_EFFECT_TYPE, EFX10.AL_EFFECT_REVERB); - alEffecti(reverbFx, AL.AL_EFFECT_TYPE, AL.AL_EFFECT_REVERB); - - // attach reverb effect to effect slot - //EFX10.alAuxiliaryEffectSloti(reverbFxSlot, EFX10.AL_EFFECTSLOT_EFFECT, reverbFx); - alAuxiliaryEffectSloti(reverbFxSlot, AL.AL_EFFECTSLOT_EFFECT, reverbFx); - } else { - logger.log(Level.WARNING, "OpenAL EFX not available! Audio effects won't work."); - } - } - - public void cleanupInThread() { - if (audioDisabled) { - //AL.destroy(); - alDestroy(); - checkError(true); - return; - } - - // stop any playing channels - for (int i = 0; i < chanSrcs.length; i++) { - if (chanSrcs[i] != null) { - clearChannel(i); - } - } - - // delete channel-based sources - ib.clear(); - ib.put(channels); - ib.flip(); - //alDeleteSources(ib); - alDeleteSources(channels.length, ib); - checkError(true); - - // delete audio buffers and filters - objManager.deleteAllObjects(this); - - if (supportEfx) { - ib.position(0).limit(1); - ib.put(0, reverbFx); - //EFX10.alDeleteEffects(ib); - alDeleteEffects(1, ib); - - // If this is not allocated, why is it deleted? - // Commented out to fix native crash in OpenAL. - ib.position(0).limit(1); - ib.put(0, reverbFxSlot); - //EFX10.alDeleteAuxiliaryEffectSlots(ib); - alDeleteAuxiliaryEffectSlots(1, ib); - } - - //AL.destroy(); - logger.log(Level.INFO, "Destroying OpenAL Soft Renderer"); - alDestroy(); - } - - public void cleanup() { - // kill audio thread - if (audioThread.isAlive()) { - audioThread.interrupt(); - } - } - - private void updateFilter(Filter f) { - int id = f.getId(); - if (id == -1) { - ib.position(0).limit(1); - //EFX10.alGenFilters(ib); - alGenFilters(1, ib); - id = ib.get(0); - f.setId(id); - - objManager.registerObject(f); - } - - if (f instanceof LowPassFilter) { - LowPassFilter lpf = (LowPassFilter) f; - //EFX10.alFilteri(id, EFX10.AL_FILTER_TYPE, EFX10.AL_FILTER_LOWPASS); - alFilteri(id, AL.AL_FILTER_TYPE, AL.AL_FILTER_LOWPASS); - //EFX10.alFilterf(id, EFX10.AL_LOWPASS_GAIN, lpf.getVolume()); - alFilterf(id, AL.AL_LOWPASS_GAIN, lpf.getVolume()); - //EFX10.alFilterf(id, EFX10.AL_LOWPASS_GAINHF, lpf.getHighFreqVolume()); - alFilterf(id, AL.AL_LOWPASS_GAINHF, lpf.getHighFreqVolume()); - } else { - throw new UnsupportedOperationException("Filter type unsupported: " - + f.getClass().getName()); - } - - f.clearUpdateNeeded(); - } - - public void updateSourceParam(AudioSource src, AudioParam param) { - checkDead(); - synchronized (threadLock) { - while (!threadLock.get()) { - try { - threadLock.wait(); - } catch (InterruptedException ex) { - } - } - if (audioDisabled) { - return; - } - - // There is a race condition in AudioSource that can - // cause this to be called for a node that has been - // detached from its channel. For example, setVolume() - // called from the render thread may see that that AudioSource - // still has a channel value but the audio thread may - // clear that channel before setVolume() gets to call - // updateSourceParam() (because the audio stopped playing - // on its own right as the volume was set). In this case, - // it should be safe to just ignore the update - if (src.getChannel() < 0) { - return; - } - - assert src.getChannel() >= 0; - - int id = channels[src.getChannel()]; - switch (param) { - case Position: - if (!src.isPositional()) { - return; - } - - Vector3f pos = src.getPosition(); - //alSource3f(id, AL_POSITION, pos.x, pos.y, pos.z); - alSource3f(id, AL.AL_POSITION, pos.x, pos.y, pos.z); - checkError(true); - break; - case Velocity: - if (!src.isPositional()) { - return; - } - - Vector3f vel = src.getVelocity(); - //alSource3f(id, AL_VELOCITY, vel.x, vel.y, vel.z); - alSource3f(id, AL.AL_VELOCITY, vel.x, vel.y, vel.z); - checkError(true); - break; - case MaxDistance: - if (!src.isPositional()) { - return; - } - - //alSourcef(id, AL_MAX_DISTANCE, src.getMaxDistance()); - alSourcef(id, AL.AL_MAX_DISTANCE, src.getMaxDistance()); - checkError(true); - break; - case RefDistance: - if (!src.isPositional()) { - return; - } - - //alSourcef(id, AL_REFERENCE_DISTANCE, src.getRefDistance()); - alSourcef(id, AL.AL_REFERENCE_DISTANCE, src.getRefDistance()); - checkError(true); - break; - case ReverbFilter: - if (!supportEfx || !src.isPositional() || !src.isReverbEnabled()) { - return; - } - - int filter = AL.AL_FILTER_NULL; - if (src.getReverbFilter() != null) { - Filter f = src.getReverbFilter(); - if (f.isUpdateNeeded()) { - updateFilter(f); - } - filter = f.getId(); - } - //AL11.alSource3i(id, EFX10.AL_AUXILIARY_SEND_FILTER, reverbFxSlot, 0, filter); - alSource3i(id, AL.AL_AUXILIARY_SEND_FILTER, reverbFxSlot, 0, filter); - break; - case ReverbEnabled: - if (!supportEfx || !src.isPositional()) { - return; - } - - if (src.isReverbEnabled()) { - updateSourceParam(src, AudioParam.ReverbFilter); - } else { - //AL11.alSource3i(id, EFX10.AL_AUXILIARY_SEND_FILTER, 0, 0, EFX10.AL_FILTER_NULL); - alSource3i(id, AL.AL_AUXILIARY_SEND_FILTER, 0, 0, AL.AL_FILTER_NULL); - } - break; - case IsPositional: - if (!src.isPositional()) { - // Play in headspace - //alSourcei(id, AL_SOURCE_RELATIVE, AL_TRUE); - alSourcei(id, AL.AL_SOURCE_RELATIVE, AL.AL_TRUE); - checkError(true); - //alSource3f(id, AL_POSITION, 0, 0, 0); - alSource3f(id, AL.AL_POSITION, 0, 0, 0); - checkError(true); - //alSource3f(id, AL_VELOCITY, 0, 0, 0); - alSource3f(id, AL.AL_VELOCITY, 0, 0, 0); - checkError(true); - - // Disable reverb - //AL11.alSource3i(id, EFX10.AL_AUXILIARY_SEND_FILTER, 0, 0, EFX10.AL_FILTER_NULL); - alSource3i(id, AL.AL_AUXILIARY_SEND_FILTER, 0, 0, AL.AL_FILTER_NULL); - } else { - //alSourcei(id, AL_SOURCE_RELATIVE, AL_FALSE); - alSourcei(id, AL.AL_SOURCE_RELATIVE, AL.AL_FALSE); - checkError(true); - updateSourceParam(src, AudioParam.Position); - updateSourceParam(src, AudioParam.Velocity); - updateSourceParam(src, AudioParam.MaxDistance); - updateSourceParam(src, AudioParam.RefDistance); - updateSourceParam(src, AudioParam.ReverbEnabled); - } - break; - case Direction: - if (!src.isDirectional()) { - return; - } - - Vector3f dir = src.getDirection(); - //alSource3f(id, AL_DIRECTION, dir.x, dir.y, dir.z); - alSource3f(id, AL.AL_DIRECTION, dir.x, dir.y, dir.z); - checkError(true); - break; - case InnerAngle: - if (!src.isDirectional()) { - return; - } - - //alSourcef(id, AL_CONE_INNER_ANGLE, src.getInnerAngle()); - alSourcef(id, AL.AL_CONE_INNER_ANGLE, src.getInnerAngle()); - checkError(true); - break; - case OuterAngle: - if (!src.isDirectional()) { - return; - } - - //alSourcef(id, AL_CONE_OUTER_ANGLE, src.getOuterAngle()); - alSourcef(id, AL.AL_CONE_OUTER_ANGLE, src.getOuterAngle()); - checkError(true); - break; - case IsDirectional: - if (src.isDirectional()) { - updateSourceParam(src, AudioParam.Direction); - updateSourceParam(src, AudioParam.InnerAngle); - updateSourceParam(src, AudioParam.OuterAngle); - //alSourcef(id, AL_CONE_OUTER_GAIN, 0); - alSourcef(id, AL.AL_CONE_OUTER_GAIN, 0); - checkError(true); - } else { - //alSourcef(id, AL_CONE_INNER_ANGLE, 360); - alSourcef(id, AL.AL_CONE_INNER_ANGLE, 360); - checkError(true); - //alSourcef(id, AL_CONE_OUTER_ANGLE, 360); - alSourcef(id, AL.AL_CONE_OUTER_ANGLE, 360); - checkError(true); - //alSourcef(id, AL_CONE_OUTER_GAIN, 1f); - alSourcef(id, AL.AL_CONE_OUTER_GAIN, 1f); - checkError(true); - } - break; - case DryFilter: - if (!supportEfx) { - return; - } - - if (src.getDryFilter() != null) { - Filter f = src.getDryFilter(); - if (f.isUpdateNeeded()) { - updateFilter(f); - - // NOTE: must re-attach filter for changes to apply. - //alSourcei(id, EFX10.AL_DIRECT_FILTER, f.getId()); - alSourcei(id, AL.AL_DIRECT_FILTER, f.getId()); - } - } else { - //alSourcei(id, EFX10.AL_DIRECT_FILTER, EFX10.AL_FILTER_NULL); - alSourcei(id, AL.AL_DIRECT_FILTER, AL.AL_FILTER_NULL); - } - break; - case Looping: - if (src.isLooping()) { - if (!(src.getAudioData() instanceof AudioStream)) { - //alSourcei(id, AL_LOOPING, AL_TRUE); - alSourcei(id, AL.AL_LOOPING, AL.AL_TRUE); - checkError(true); - } - } else { - //alSourcei(id, AL_LOOPING, AL_FALSE); - alSourcei(id, AL.AL_LOOPING, AL.AL_FALSE); - checkError(true); - } - break; - case Volume: - //alSourcef(id, AL_GAIN, src.getVolume()); - alSourcef(id, AL.AL_GAIN, src.getVolume()); - checkError(true); - break; - case Pitch: - //alSourcef(id, AL_PITCH, src.getPitch()); - alSourcef(id, AL.AL_PITCH, src.getPitch()); - checkError(true); - break; - } - } - } - - private void setSourceParams(int id, AudioSource src, boolean forceNonLoop) { - if (src.isPositional()) { - Vector3f pos = src.getPosition(); - Vector3f vel = src.getVelocity(); - //alSource3f(id, AL_POSITION, pos.x, pos.y, pos.z); - alSource3f(id, AL.AL_POSITION, pos.x, pos.y, pos.z); - checkError(true); - //alSource3f(id, AL_VELOCITY, vel.x, vel.y, vel.z); - alSource3f(id, AL.AL_VELOCITY, vel.x, vel.y, vel.z); - checkError(true); - //alSourcef(id, AL_MAX_DISTANCE, src.getMaxDistance()); - alSourcef(id, AL.AL_MAX_DISTANCE, src.getMaxDistance()); - checkError(true); - //alSourcef(id, AL_REFERENCE_DISTANCE, src.getRefDistance()); - alSourcef(id, AL.AL_REFERENCE_DISTANCE, src.getRefDistance()); - checkError(true); - //alSourcei(id, AL_SOURCE_RELATIVE, AL_FALSE); - alSourcei(id, AL.AL_SOURCE_RELATIVE, AL.AL_FALSE); - checkError(true); - - if (src.isReverbEnabled() && supportEfx) { - //int filter = EFX10.AL_FILTER_NULL; - int filter = AL.AL_FILTER_NULL; - if (src.getReverbFilter() != null) { - Filter f = src.getReverbFilter(); - if (f.isUpdateNeeded()) { - updateFilter(f); - } - filter = f.getId(); - } - //AL11.alSource3i(id, EFX10.AL_AUXILIARY_SEND_FILTER, reverbFxSlot, 0, filter); - alSource3i(id, AL.AL_AUXILIARY_SEND_FILTER, reverbFxSlot, 0, filter); - } - } else { - // play in headspace - //alSourcei(id, AL_SOURCE_RELATIVE, AL_TRUE); - alSourcei(id, AL.AL_SOURCE_RELATIVE, AL.AL_TRUE); - checkError(true); - //alSource3f(id, AL_POSITION, 0, 0, 0); - alSource3f(id, AL.AL_POSITION, 0, 0, 0); - checkError(true); - //alSource3f(id, AL_VELOCITY, 0, 0, 0); - alSource3f(id, AL.AL_VELOCITY, 0, 0, 0); - checkError(true); - } - - if (src.getDryFilter() != null && supportEfx) { - Filter f = src.getDryFilter(); - if (f.isUpdateNeeded()) { - updateFilter(f); - - // NOTE: must re-attach filter for changes to apply. - //alSourcei(id, EFX10.AL_DIRECT_FILTER, f.getId()); - alSourcei(id, AL.AL_DIRECT_FILTER, f.getId()); - } - } - - if (forceNonLoop) { - //alSourcei(id, AL_LOOPING, AL_FALSE); - alSourcei(id, AL.AL_LOOPING, AL.AL_FALSE); - checkError(true); - } else { - //alSourcei(id, AL_LOOPING, src.isLooping() ? AL_TRUE : AL_FALSE); - alSourcei(id, AL.AL_LOOPING, src.isLooping() ? AL.AL_TRUE : AL.AL_FALSE); - checkError(true); - } - //alSourcef(id, AL_GAIN, src.getVolume()); - alSourcef(id, AL.AL_GAIN, src.getVolume()); - checkError(true); - //alSourcef(id, AL_PITCH, src.getPitch()); - alSourcef(id, AL.AL_PITCH, src.getPitch()); - checkError(true); - //alSourcef(id, AL11.AL_SEC_OFFSET, src.getTimeOffset()); - alSourcef(id, AL.AL_SEC_OFFSET, src.getTimeOffset()); - checkError(true); - - if (src.isDirectional()) { - Vector3f dir = src.getDirection(); - //alSource3f(id, AL_DIRECTION, dir.x, dir.y, dir.z); - alSource3f(id, AL.AL_DIRECTION, dir.x, dir.y, dir.z); - checkError(true); - //alSourcef(id, AL_CONE_INNER_ANGLE, src.getInnerAngle()); - alSourcef(id, AL.AL_CONE_INNER_ANGLE, src.getInnerAngle()); - checkError(true); - //alSourcef(id, AL_CONE_OUTER_ANGLE, src.getOuterAngle()); - alSourcef(id, AL.AL_CONE_OUTER_ANGLE, src.getOuterAngle()); - checkError(true); - //alSourcef(id, AL_CONE_OUTER_GAIN, 0); - alSourcef(id, AL.AL_CONE_OUTER_GAIN, 0); - checkError(true); - } else { - //alSourcef(id, AL_CONE_INNER_ANGLE, 360); - alSourcef(id, AL.AL_CONE_INNER_ANGLE, 360); - checkError(true); - //alSourcef(id, AL_CONE_OUTER_ANGLE, 360); - alSourcef(id, AL.AL_CONE_OUTER_ANGLE, 360); - checkError(true); - //alSourcef(id, AL_CONE_OUTER_GAIN, 1f); - alSourcef(id, AL.AL_CONE_OUTER_GAIN, 1f); - checkError(true); - } - } - - public void updateListenerParam(Listener listener, ListenerParam param) { - checkDead(); - synchronized (threadLock) { - while (!threadLock.get()) { - try { - threadLock.wait(); - } catch (InterruptedException ex) { - } - } - if (audioDisabled) { - return; - } - - switch (param) { - case Position: - Vector3f pos = listener.getLocation(); - //alListener3f(AL_POSITION, pos.x, pos.y, pos.z); - alListener3f(AL.AL_POSITION, pos.x, pos.y, pos.z); - checkError(true); - break; - case Rotation: - Vector3f dir = listener.getDirection(); - Vector3f up = listener.getUp(); - fb.rewind(); - fb.put(dir.x).put(dir.y).put(dir.z); - fb.put(up.x).put(up.y).put(up.z); - fb.flip(); - //alListener(AL_ORIENTATION, fb); - alListener(AL.AL_ORIENTATION, fb); - checkError(true); - break; - case Velocity: - Vector3f vel = listener.getVelocity(); - //alListener3f(AL_VELOCITY, vel.x, vel.y, vel.z); - alListener3f(AL.AL_VELOCITY, vel.x, vel.y, vel.z); - checkError(true); - break; - case Volume: - //alListenerf(AL_GAIN, listener.getVolume()); - alListenerf(AL.AL_GAIN, listener.getVolume()); - checkError(true); - break; - } - } - } - - private void setListenerParams(Listener listener) { - Vector3f pos = listener.getLocation(); - Vector3f vel = listener.getVelocity(); - Vector3f dir = listener.getDirection(); - Vector3f up = listener.getUp(); - - //alListener3f(AL_POSITION, pos.x, pos.y, pos.z); - alListener3f(AL.AL_POSITION, pos.x, pos.y, pos.z); - checkError(true); - //alListener3f(AL_VELOCITY, vel.x, vel.y, vel.z); - alListener3f(AL.AL_VELOCITY, vel.x, vel.y, vel.z); - checkError(true); - fb.rewind(); - fb.put(dir.x).put(dir.y).put(dir.z); - fb.put(up.x).put(up.y).put(up.z); - fb.flip(); - //alListener(AL_ORIENTATION, fb); - alListener(AL.AL_ORIENTATION, fb); - checkError(true); - //alListenerf(AL_GAIN, listener.getVolume()); - alListenerf(AL.AL_GAIN, listener.getVolume()); - checkError(true); - } - - private int newChannel() { - if (freeChans.size() > 0) { - return freeChans.remove(0); - } else if (nextChan < channels.length) { - return nextChan++; - } else { - return -1; - } - } - - private void freeChannel(int index) { - if (index == nextChan - 1) { - nextChan--; - } else { - freeChans.add(index); - } - } - - public void setEnvironment(Environment env) { - checkDead(); - synchronized (threadLock) { - while (!threadLock.get()) { - try { - threadLock.wait(); - } catch (InterruptedException ex) { - } - } - if (audioDisabled || !supportEfx) { - return; - } - - //EFX10.alEffectf(reverbFx, EFX10.AL_REVERB_DENSITY, env.getDensity()); - alEffectf(reverbFx, AL.AL_REVERB_DENSITY, env.getDensity()); - //EFX10.alEffectf(reverbFx, EFX10.AL_REVERB_DIFFUSION, env.getDiffusion()); - alEffectf(reverbFx, AL.AL_REVERB_DIFFUSION, env.getDiffusion()); - //EFX10.alEffectf(reverbFx, EFX10.AL_REVERB_GAIN, env.getGain()); - alEffectf(reverbFx, AL.AL_REVERB_GAIN, env.getGain()); - //EFX10.alEffectf(reverbFx, EFX10.AL_REVERB_GAINHF, env.getGainHf()); - alEffectf(reverbFx, AL.AL_REVERB_GAINHF, env.getGainHf()); - //EFX10.alEffectf(reverbFx, EFX10.AL_REVERB_DECAY_TIME, env.getDecayTime()); - alEffectf(reverbFx, AL.AL_REVERB_DECAY_TIME, env.getDecayTime()); - //EFX10.alEffectf(reverbFx, EFX10.AL_REVERB_DECAY_HFRATIO, env.getDecayHFRatio()); - alEffectf(reverbFx, AL.AL_REVERB_DECAY_HFRATIO, env.getDecayHFRatio()); - //EFX10.alEffectf(reverbFx, EFX10.AL_REVERB_REFLECTIONS_GAIN, env.getReflectGain()); - alEffectf(reverbFx, AL.AL_REVERB_REFLECTIONS_GAIN, env.getReflectGain()); - //EFX10.alEffectf(reverbFx, EFX10.AL_REVERB_REFLECTIONS_DELAY, env.getReflectDelay()); - alEffectf(reverbFx, AL.AL_REVERB_REFLECTIONS_DELAY, env.getReflectDelay()); - //EFX10.alEffectf(reverbFx, EFX10.AL_REVERB_LATE_REVERB_GAIN, env.getLateReverbGain()); - alEffectf(reverbFx, AL.AL_REVERB_LATE_REVERB_GAIN, env.getLateReverbGain()); - //EFX10.alEffectf(reverbFx, EFX10.AL_REVERB_LATE_REVERB_DELAY, env.getLateReverbDelay()); - alEffectf(reverbFx, AL.AL_REVERB_LATE_REVERB_DELAY, env.getLateReverbDelay()); - //EFX10.alEffectf(reverbFx, EFX10.AL_REVERB_AIR_ABSORPTION_GAINHF, env.getAirAbsorbGainHf()); - alEffectf(reverbFx, AL.AL_REVERB_AIR_ABSORPTION_GAINHF, env.getAirAbsorbGainHf()); - //EFX10.alEffectf(reverbFx, EFX10.AL_REVERB_ROOM_ROLLOFF_FACTOR, env.getRoomRolloffFactor()); - alEffectf(reverbFx, AL.AL_REVERB_ROOM_ROLLOFF_FACTOR, env.getRoomRolloffFactor()); - - // attach effect to slot - //EFX10.alAuxiliaryEffectSloti(reverbFxSlot, EFX10.AL_EFFECTSLOT_EFFECT, reverbFx); - alAuxiliaryEffectSloti(reverbFxSlot, AL.AL_EFFECTSLOT_EFFECT, reverbFx); - } - } - - private boolean fillBuffer(AudioStream stream, int id) { - int size = 0; - int result; - - while (size < arrayBuf.length) { - result = stream.readSamples(arrayBuf, size, arrayBuf.length - size); - - if (result > 0) { - size += result; - } else { - break; - } - } - - if (size == 0) { - return false; - } - - nativeBuf.clear(); - nativeBuf.put(arrayBuf, 0, size); - nativeBuf.flip(); - - //alBufferData(id, convertFormat(stream), nativeBuf, stream.getSampleRate()); - alBufferData(id, convertFormat(stream), nativeBuf, size, stream.getSampleRate()); - checkError(true); - - return true; - } - - private boolean fillStreamingSource(int sourceId, AudioStream stream) { - if (!stream.isOpen()) { - return false; - } - - boolean active = true; - //int processed = alGetSourcei(sourceId, AL_BUFFERS_PROCESSED); - int processed = alGetSourcei(sourceId, AL.AL_BUFFERS_PROCESSED); - checkError(true); - - //while((processed--) != 0){ - if (processed > 0) { - int buffer; - - ib.position(0).limit(1); - //alSourceUnqueueBuffers(sourceId, ib); - alSourceUnqueueBuffers(sourceId, 1, ib); - checkError(true); - buffer = ib.get(0); - - active = fillBuffer(stream, buffer); - - ib.position(0).limit(1); - ib.put(0, buffer); - //alSourceQueueBuffers(sourceId, ib); - alSourceQueueBuffers(sourceId, 1, ib); - checkError(true); - } - - if (!active && stream.isOpen()) { - stream.close(); - } - - return active; - } - - private boolean attachStreamToSource(int sourceId, AudioStream stream) { - boolean active = true; - int activeBufferCount = 0; - for (int id : stream.getIds()) { - active = fillBuffer(stream, id); - ib.position(0).limit(1); - ib.put(id).flip(); - //alSourceQueueBuffers(sourceId, ib); - // OpenAL Soft does not like 0 size buffer data in alSourceQueueBuffers - // Produces error code 40964 (0xA004) = AL_INVALID_OPERATION and - // does not return (crashes) so that the error code can be checked. - // active is FALSE when the data size is 0 - if (active) { - alSourceQueueBuffers(sourceId, 1, ib); - checkError(true); - activeBufferCount++; - } - } - // adjust the steam id array if the audio data is smaller than STREAMING_BUFFER_COUNT - // this is to avoid an error with OpenAL Soft when alSourceUnenqueueBuffers - // is called with more buffers than were originally used with alSourceQueueBuffers - if (activeBufferCount < STREAMING_BUFFER_COUNT) { - int[] newIds = new int[activeBufferCount]; - for (int i=0; i freeChans = new ArrayList(); + private final ArrayList freeChans = new ArrayList(); private Listener listener; private boolean audioDisabled = false; private boolean supportEfx = false; + private boolean supportPauseDevice = false; private int auxSends = 0; private int reverbFx = -1; private int reverbFxSlot = -1; @@ -75,7 +77,14 @@ public class LwjglAudioRenderer implements AudioRenderer, Runnable { private final Thread audioThread = new Thread(this, "jME3 Audio Thread"); private final AtomicBoolean threadLock = new AtomicBoolean(false); - public LwjglAudioRenderer() { + private final AL al; + private final ALC alc; + private final EFX efx; + + public ALAudioRenderer(AL al, ALC alc, EFX efx) { + this.al = al; + this.alc = alc; + this.efx = efx; } public void initialize() { @@ -136,36 +145,30 @@ public class LwjglAudioRenderer implements AudioRenderer, Runnable { public void initInThread() { try { - if (!AL.isCreated()) { - AL.create(); + if (!alc.isCreated()) { + alc.createALC(); } - } catch (OpenALException ex) { - logger.log(Level.SEVERE, "Failed to load audio library", ex); - audioDisabled = true; - return; - } catch (LWJGLException ex) { - logger.log(Level.SEVERE, "Failed to load audio library", ex); - audioDisabled = true; - return; } catch (UnsatisfiedLinkError ex) { logger.log(Level.SEVERE, "Failed to load audio library", ex); audioDisabled = true; return; } - ALCdevice device = AL.getDevice(); - String deviceName = ALC10.alcGetString(device, ALC10.ALC_DEVICE_SPECIFIER); + String deviceName = alc.alcGetString(ALC.ALC_DEVICE_SPECIFIER); logger.log(Level.INFO, "Audio Device: {0}", deviceName); - logger.log(Level.INFO, "Audio Vendor: {0}", alGetString(AL_VENDOR)); - logger.log(Level.INFO, "Audio Renderer: {0}", alGetString(AL_RENDERER)); - logger.log(Level.INFO, "Audio Version: {0}", alGetString(AL_VERSION)); + logger.log(Level.INFO, "Audio Vendor: {0}", al.alGetString(AL_VENDOR)); + logger.log(Level.INFO, "Audio Renderer: {0}", al.alGetString(AL_RENDERER)); + logger.log(Level.INFO, "Audio Version: {0}", al.alGetString(AL_VERSION)); + logger.log(Level.INFO, "ALC extensions: {0}", alc.alcGetString(ALC.ALC_EXTENSIONS)); + logger.log(Level.INFO, "AL extensions: {0}", al.alGetString(AL_EXTENSIONS)); + // Find maximum # of sources supported by this implementation ArrayList channelList = new ArrayList(); for (int i = 0; i < MAX_NUM_CHANNELS; i++) { - int chan = alGenSources(); - if (alGetError() != 0) { + int chan = al.alGenSources(); + if (al.alGetError() != 0) { break; } else { channelList.add(chan); @@ -182,33 +185,41 @@ public class LwjglAudioRenderer implements AudioRenderer, Runnable { logger.log(Level.INFO, "AudioRenderer supports {0} channels", channels.length); - supportEfx = ALC10.alcIsExtensionPresent(device, "ALC_EXT_EFX"); + // Pause device is a feature used specifically on Android + // where the application could be closed but still running, + // thus the audio context remains open but no audio should be playing. + supportPauseDevice = alc.alcIsExtensionPresent("ALC_SOFT_pause_device"); + if (!supportPauseDevice) { + logger.log(Level.WARNING, "Pausing audio device not supported."); + } + + supportEfx = alc.alcIsExtensionPresent("ALC_EXT_EFX"); if (supportEfx) { ib.position(0).limit(1); - ALC10.alcGetInteger(device, EFX10.ALC_EFX_MAJOR_VERSION, ib); + alc.alcGetInteger(EFX.ALC_EFX_MAJOR_VERSION, ib, 1); int major = ib.get(0); ib.position(0).limit(1); - ALC10.alcGetInteger(device, EFX10.ALC_EFX_MINOR_VERSION, ib); + alc.alcGetInteger(EFX.ALC_EFX_MINOR_VERSION, ib, 1); int minor = ib.get(0); logger.log(Level.INFO, "Audio effect extension version: {0}.{1}", new Object[]{major, minor}); - ALC10.alcGetInteger(device, EFX10.ALC_MAX_AUXILIARY_SENDS, ib); + alc.alcGetInteger(EFX.ALC_MAX_AUXILIARY_SENDS, ib, 1); auxSends = ib.get(0); logger.log(Level.INFO, "Audio max auxilary sends: {0}", auxSends); // create slot ib.position(0).limit(1); - EFX10.alGenAuxiliaryEffectSlots(ib); + efx.alGenAuxiliaryEffectSlots(1, ib); reverbFxSlot = ib.get(0); // create effect ib.position(0).limit(1); - EFX10.alGenEffects(ib); + efx.alGenEffects(1, ib); reverbFx = ib.get(0); - EFX10.alEffecti(reverbFx, EFX10.AL_EFFECT_TYPE, EFX10.AL_EFFECT_REVERB); + efx.alEffecti(reverbFx, EFX.AL_EFFECT_TYPE, EFX.AL_EFFECT_REVERB); // attach reverb effect to effect slot - EFX10.alAuxiliaryEffectSloti(reverbFxSlot, EFX10.AL_EFFECTSLOT_EFFECT, reverbFx); + efx.alAuxiliaryEffectSloti(reverbFxSlot, EFX.AL_EFFECTSLOT_EFFECT, reverbFx); } else { logger.log(Level.WARNING, "OpenAL EFX not available! Audio effects won't work."); } @@ -216,7 +227,7 @@ public class LwjglAudioRenderer implements AudioRenderer, Runnable { public void cleanupInThread() { if (audioDisabled) { - AL.destroy(); + alc.destroyALC(); return; } @@ -231,7 +242,7 @@ public class LwjglAudioRenderer implements AudioRenderer, Runnable { ib.clear(); ib.put(channels); ib.flip(); - alDeleteSources(ib); + al.alDeleteSources(channels.length, ib); // delete audio buffers and filters objManager.deleteAllObjects(this); @@ -239,16 +250,16 @@ public class LwjglAudioRenderer implements AudioRenderer, Runnable { if (supportEfx) { ib.position(0).limit(1); ib.put(0, reverbFx); - EFX10.alDeleteEffects(ib); + efx.alDeleteEffects(1, ib); // If this is not allocated, why is it deleted? // Commented out to fix native crash in OpenAL. ib.position(0).limit(1); ib.put(0, reverbFxSlot); - EFX10.alDeleteAuxiliaryEffectSlots(ib); + efx.alDeleteAuxiliaryEffectSlots(1, ib); } - AL.destroy(); + alc.destroyALC(); } public void cleanup() { @@ -266,7 +277,7 @@ public class LwjglAudioRenderer implements AudioRenderer, Runnable { int id = f.getId(); if (id == -1) { ib.position(0).limit(1); - EFX10.alGenFilters(ib); + efx.alGenFilters(1, ib); id = ib.get(0); f.setId(id); @@ -275,9 +286,9 @@ public class LwjglAudioRenderer implements AudioRenderer, Runnable { if (f instanceof LowPassFilter) { LowPassFilter lpf = (LowPassFilter) f; - EFX10.alFilteri(id, EFX10.AL_FILTER_TYPE, EFX10.AL_FILTER_LOWPASS); - EFX10.alFilterf(id, EFX10.AL_LOWPASS_GAIN, lpf.getVolume()); - EFX10.alFilterf(id, EFX10.AL_LOWPASS_GAINHF, lpf.getHighFreqVolume()); + efx.alFilteri(id, EFX.AL_FILTER_TYPE, EFX.AL_FILTER_LOWPASS); + efx.alFilterf(id, EFX.AL_LOWPASS_GAIN, lpf.getVolume()); + efx.alFilterf(id, EFX.AL_LOWPASS_GAINHF, lpf.getHighFreqVolume()); } else { throw new UnsupportedOperationException("Filter type unsupported: " + f.getClass().getName()); @@ -322,7 +333,7 @@ public class LwjglAudioRenderer implements AudioRenderer, Runnable { } Vector3f pos = src.getPosition(); - alSource3f(id, AL_POSITION, pos.x, pos.y, pos.z); + al.alSource3f(id, AL_POSITION, pos.x, pos.y, pos.z); break; case Velocity: if (!src.isPositional()) { @@ -330,28 +341,28 @@ public class LwjglAudioRenderer implements AudioRenderer, Runnable { } Vector3f vel = src.getVelocity(); - alSource3f(id, AL_VELOCITY, vel.x, vel.y, vel.z); + al.alSource3f(id, AL_VELOCITY, vel.x, vel.y, vel.z); break; case MaxDistance: if (!src.isPositional()) { return; } - alSourcef(id, AL_MAX_DISTANCE, src.getMaxDistance()); + al.alSourcef(id, AL_MAX_DISTANCE, src.getMaxDistance()); break; case RefDistance: if (!src.isPositional()) { return; } - alSourcef(id, AL_REFERENCE_DISTANCE, src.getRefDistance()); + al.alSourcef(id, AL_REFERENCE_DISTANCE, src.getRefDistance()); break; case ReverbFilter: if (!supportEfx || !src.isPositional() || !src.isReverbEnabled()) { return; } - int filter = EFX10.AL_FILTER_NULL; + int filter = EFX.AL_FILTER_NULL; if (src.getReverbFilter() != null) { Filter f = src.getReverbFilter(); if (f.isUpdateNeeded()) { @@ -359,7 +370,7 @@ public class LwjglAudioRenderer implements AudioRenderer, Runnable { } filter = f.getId(); } - AL11.alSource3i(id, EFX10.AL_AUXILIARY_SEND_FILTER, reverbFxSlot, 0, filter); + al.alSource3i(id, EFX.AL_AUXILIARY_SEND_FILTER, reverbFxSlot, 0, filter); break; case ReverbEnabled: if (!supportEfx || !src.isPositional()) { @@ -369,20 +380,20 @@ public class LwjglAudioRenderer implements AudioRenderer, Runnable { if (src.isReverbEnabled()) { updateSourceParam(src, AudioParam.ReverbFilter); } else { - AL11.alSource3i(id, EFX10.AL_AUXILIARY_SEND_FILTER, 0, 0, EFX10.AL_FILTER_NULL); + al.alSource3i(id, EFX.AL_AUXILIARY_SEND_FILTER, 0, 0, EFX.AL_FILTER_NULL); } break; case IsPositional: if (!src.isPositional()) { // Play in headspace - alSourcei(id, AL_SOURCE_RELATIVE, AL_TRUE); - alSource3f(id, AL_POSITION, 0, 0, 0); - alSource3f(id, AL_VELOCITY, 0, 0, 0); + al.alSourcei(id, AL_SOURCE_RELATIVE, AL_TRUE); + al.alSource3f(id, AL_POSITION, 0, 0, 0); + al.alSource3f(id, AL_VELOCITY, 0, 0, 0); // Disable reverb - AL11.alSource3i(id, EFX10.AL_AUXILIARY_SEND_FILTER, 0, 0, EFX10.AL_FILTER_NULL); + al.alSource3i(id, EFX.AL_AUXILIARY_SEND_FILTER, 0, 0, EFX.AL_FILTER_NULL); } else { - alSourcei(id, AL_SOURCE_RELATIVE, AL_FALSE); + al.alSourcei(id, AL_SOURCE_RELATIVE, AL_FALSE); updateSourceParam(src, AudioParam.Position); updateSourceParam(src, AudioParam.Velocity); updateSourceParam(src, AudioParam.MaxDistance); @@ -396,32 +407,32 @@ public class LwjglAudioRenderer implements AudioRenderer, Runnable { } Vector3f dir = src.getDirection(); - alSource3f(id, AL_DIRECTION, dir.x, dir.y, dir.z); + al.alSource3f(id, AL_DIRECTION, dir.x, dir.y, dir.z); break; case InnerAngle: if (!src.isDirectional()) { return; } - alSourcef(id, AL_CONE_INNER_ANGLE, src.getInnerAngle()); + al.alSourcef(id, AL_CONE_INNER_ANGLE, src.getInnerAngle()); break; case OuterAngle: if (!src.isDirectional()) { return; } - alSourcef(id, AL_CONE_OUTER_ANGLE, src.getOuterAngle()); + al.alSourcef(id, AL_CONE_OUTER_ANGLE, src.getOuterAngle()); break; case IsDirectional: if (src.isDirectional()) { updateSourceParam(src, AudioParam.Direction); updateSourceParam(src, AudioParam.InnerAngle); updateSourceParam(src, AudioParam.OuterAngle); - alSourcef(id, AL_CONE_OUTER_GAIN, 0); + al.alSourcef(id, AL_CONE_OUTER_GAIN, 0); } else { - alSourcef(id, AL_CONE_INNER_ANGLE, 360); - alSourcef(id, AL_CONE_OUTER_ANGLE, 360); - alSourcef(id, AL_CONE_OUTER_GAIN, 1f); + al.alSourcef(id, AL_CONE_INNER_ANGLE, 360); + al.alSourcef(id, AL_CONE_OUTER_ANGLE, 360); + al.alSourcef(id, AL_CONE_OUTER_GAIN, 1f); } break; case DryFilter: @@ -435,26 +446,26 @@ public class LwjglAudioRenderer implements AudioRenderer, Runnable { updateFilter(f); // NOTE: must re-attach filter for changes to apply. - alSourcei(id, EFX10.AL_DIRECT_FILTER, f.getId()); + al.alSourcei(id, EFX.AL_DIRECT_FILTER, f.getId()); } } else { - alSourcei(id, EFX10.AL_DIRECT_FILTER, EFX10.AL_FILTER_NULL); + al.alSourcei(id, EFX.AL_DIRECT_FILTER, EFX.AL_FILTER_NULL); } break; case Looping: if (src.isLooping()) { if (!(src.getAudioData() instanceof AudioStream)) { - alSourcei(id, AL_LOOPING, AL_TRUE); + al.alSourcei(id, AL_LOOPING, AL_TRUE); } } else { - alSourcei(id, AL_LOOPING, AL_FALSE); + al.alSourcei(id, AL_LOOPING, AL_FALSE); } break; case Volume: - alSourcef(id, AL_GAIN, src.getVolume()); + al.alSourcef(id, AL_GAIN, src.getVolume()); break; case Pitch: - alSourcef(id, AL_PITCH, src.getPitch()); + al.alSourcef(id, AL_PITCH, src.getPitch()); break; } } @@ -464,14 +475,14 @@ public class LwjglAudioRenderer implements AudioRenderer, Runnable { if (src.isPositional()) { Vector3f pos = src.getPosition(); Vector3f vel = src.getVelocity(); - alSource3f(id, AL_POSITION, pos.x, pos.y, pos.z); - alSource3f(id, AL_VELOCITY, vel.x, vel.y, vel.z); - alSourcef(id, AL_MAX_DISTANCE, src.getMaxDistance()); - alSourcef(id, AL_REFERENCE_DISTANCE, src.getRefDistance()); - alSourcei(id, AL_SOURCE_RELATIVE, AL_FALSE); + al.alSource3f(id, AL_POSITION, pos.x, pos.y, pos.z); + al.alSource3f(id, AL_VELOCITY, vel.x, vel.y, vel.z); + al.alSourcef(id, AL_MAX_DISTANCE, src.getMaxDistance()); + al.alSourcef(id, AL_REFERENCE_DISTANCE, src.getRefDistance()); + al.alSourcei(id, AL_SOURCE_RELATIVE, AL_FALSE); if (src.isReverbEnabled() && supportEfx) { - int filter = EFX10.AL_FILTER_NULL; + int filter = EFX.AL_FILTER_NULL; if (src.getReverbFilter() != null) { Filter f = src.getReverbFilter(); if (f.isUpdateNeeded()) { @@ -479,13 +490,13 @@ public class LwjglAudioRenderer implements AudioRenderer, Runnable { } filter = f.getId(); } - AL11.alSource3i(id, EFX10.AL_AUXILIARY_SEND_FILTER, reverbFxSlot, 0, filter); + al.alSource3i(id, EFX.AL_AUXILIARY_SEND_FILTER, reverbFxSlot, 0, filter); } } else { // play in headspace - alSourcei(id, AL_SOURCE_RELATIVE, AL_TRUE); - alSource3f(id, AL_POSITION, 0, 0, 0); - alSource3f(id, AL_VELOCITY, 0, 0, 0); + al.alSourcei(id, AL_SOURCE_RELATIVE, AL_TRUE); + al.alSource3f(id, AL_POSITION, 0, 0, 0); + al.alSource3f(id, AL_VELOCITY, 0, 0, 0); } if (src.getDryFilter() != null && supportEfx) { @@ -494,29 +505,29 @@ public class LwjglAudioRenderer implements AudioRenderer, Runnable { updateFilter(f); // NOTE: must re-attach filter for changes to apply. - alSourcei(id, EFX10.AL_DIRECT_FILTER, f.getId()); + al.alSourcei(id, EFX.AL_DIRECT_FILTER, f.getId()); } } if (forceNonLoop) { - alSourcei(id, AL_LOOPING, AL_FALSE); + al.alSourcei(id, AL_LOOPING, AL_FALSE); } else { - alSourcei(id, AL_LOOPING, src.isLooping() ? AL_TRUE : AL_FALSE); + al.alSourcei(id, AL_LOOPING, src.isLooping() ? AL_TRUE : AL_FALSE); } - alSourcef(id, AL_GAIN, src.getVolume()); - alSourcef(id, AL_PITCH, src.getPitch()); - alSourcef(id, AL11.AL_SEC_OFFSET, src.getTimeOffset()); + al.alSourcef(id, AL_GAIN, src.getVolume()); + al.alSourcef(id, AL_PITCH, src.getPitch()); + al.alSourcef(id, AL_SEC_OFFSET, src.getTimeOffset()); if (src.isDirectional()) { Vector3f dir = src.getDirection(); - alSource3f(id, AL_DIRECTION, dir.x, dir.y, dir.z); - alSourcef(id, AL_CONE_INNER_ANGLE, src.getInnerAngle()); - alSourcef(id, AL_CONE_OUTER_ANGLE, src.getOuterAngle()); - alSourcef(id, AL_CONE_OUTER_GAIN, 0); + al.alSource3f(id, AL_DIRECTION, dir.x, dir.y, dir.z); + al.alSourcef(id, AL_CONE_INNER_ANGLE, src.getInnerAngle()); + al.alSourcef(id, AL_CONE_OUTER_ANGLE, src.getOuterAngle()); + al.alSourcef(id, AL_CONE_OUTER_GAIN, 0); } else { - alSourcef(id, AL_CONE_INNER_ANGLE, 360); - alSourcef(id, AL_CONE_OUTER_ANGLE, 360); - alSourcef(id, AL_CONE_OUTER_GAIN, 1f); + al.alSourcef(id, AL_CONE_INNER_ANGLE, 360); + al.alSourcef(id, AL_CONE_OUTER_ANGLE, 360); + al.alSourcef(id, AL_CONE_OUTER_GAIN, 1f); } } @@ -536,7 +547,7 @@ public class LwjglAudioRenderer implements AudioRenderer, Runnable { switch (param) { case Position: Vector3f pos = listener.getLocation(); - alListener3f(AL_POSITION, pos.x, pos.y, pos.z); + al.alListener3f(AL_POSITION, pos.x, pos.y, pos.z); break; case Rotation: Vector3f dir = listener.getDirection(); @@ -545,14 +556,14 @@ public class LwjglAudioRenderer implements AudioRenderer, Runnable { fb.put(dir.x).put(dir.y).put(dir.z); fb.put(up.x).put(up.y).put(up.z); fb.flip(); - alListener(AL_ORIENTATION, fb); + al.alListener(AL_ORIENTATION, fb); break; case Velocity: Vector3f vel = listener.getVelocity(); - alListener3f(AL_VELOCITY, vel.x, vel.y, vel.z); + al.alListener3f(AL_VELOCITY, vel.x, vel.y, vel.z); break; case Volume: - alListenerf(AL_GAIN, listener.getVolume()); + al.alListenerf(AL_GAIN, listener.getVolume()); break; } } @@ -564,14 +575,14 @@ public class LwjglAudioRenderer implements AudioRenderer, Runnable { Vector3f dir = listener.getDirection(); Vector3f up = listener.getUp(); - alListener3f(AL_POSITION, pos.x, pos.y, pos.z); - alListener3f(AL_VELOCITY, vel.x, vel.y, vel.z); + al.alListener3f(AL_POSITION, pos.x, pos.y, pos.z); + al.alListener3f(AL_VELOCITY, vel.x, vel.y, vel.z); fb.rewind(); fb.put(dir.x).put(dir.y).put(dir.z); fb.put(up.x).put(up.y).put(up.z); fb.flip(); - alListener(AL_ORIENTATION, fb); - alListenerf(AL_GAIN, listener.getVolume()); + al.alListener(AL_ORIENTATION, fb); + al.alListenerf(AL_GAIN, listener.getVolume()); } private int newChannel() { @@ -605,21 +616,21 @@ public class LwjglAudioRenderer implements AudioRenderer, Runnable { return; } - EFX10.alEffectf(reverbFx, EFX10.AL_REVERB_DENSITY, env.getDensity()); - EFX10.alEffectf(reverbFx, EFX10.AL_REVERB_DIFFUSION, env.getDiffusion()); - EFX10.alEffectf(reverbFx, EFX10.AL_REVERB_GAIN, env.getGain()); - EFX10.alEffectf(reverbFx, EFX10.AL_REVERB_GAINHF, env.getGainHf()); - EFX10.alEffectf(reverbFx, EFX10.AL_REVERB_DECAY_TIME, env.getDecayTime()); - EFX10.alEffectf(reverbFx, EFX10.AL_REVERB_DECAY_HFRATIO, env.getDecayHFRatio()); - EFX10.alEffectf(reverbFx, EFX10.AL_REVERB_REFLECTIONS_GAIN, env.getReflectGain()); - EFX10.alEffectf(reverbFx, EFX10.AL_REVERB_REFLECTIONS_DELAY, env.getReflectDelay()); - EFX10.alEffectf(reverbFx, EFX10.AL_REVERB_LATE_REVERB_GAIN, env.getLateReverbGain()); - EFX10.alEffectf(reverbFx, EFX10.AL_REVERB_LATE_REVERB_DELAY, env.getLateReverbDelay()); - EFX10.alEffectf(reverbFx, EFX10.AL_REVERB_AIR_ABSORPTION_GAINHF, env.getAirAbsorbGainHf()); - EFX10.alEffectf(reverbFx, EFX10.AL_REVERB_ROOM_ROLLOFF_FACTOR, env.getRoomRolloffFactor()); + efx.alEffectf(reverbFx, EFX.AL_REVERB_DENSITY, env.getDensity()); + efx.alEffectf(reverbFx, EFX.AL_REVERB_DIFFUSION, env.getDiffusion()); + efx.alEffectf(reverbFx, EFX.AL_REVERB_GAIN, env.getGain()); + efx.alEffectf(reverbFx, EFX.AL_REVERB_GAINHF, env.getGainHf()); + efx.alEffectf(reverbFx, EFX.AL_REVERB_DECAY_TIME, env.getDecayTime()); + efx.alEffectf(reverbFx, EFX.AL_REVERB_DECAY_HFRATIO, env.getDecayHFRatio()); + efx.alEffectf(reverbFx, EFX.AL_REVERB_REFLECTIONS_GAIN, env.getReflectGain()); + efx.alEffectf(reverbFx, EFX.AL_REVERB_REFLECTIONS_DELAY, env.getReflectDelay()); + efx.alEffectf(reverbFx, EFX.AL_REVERB_LATE_REVERB_GAIN, env.getLateReverbGain()); + efx.alEffectf(reverbFx, EFX.AL_REVERB_LATE_REVERB_DELAY, env.getLateReverbDelay()); + efx.alEffectf(reverbFx, EFX.AL_REVERB_AIR_ABSORPTION_GAINHF, env.getAirAbsorbGainHf()); + efx.alEffectf(reverbFx, EFX.AL_REVERB_ROOM_ROLLOFF_FACTOR, env.getRoomRolloffFactor()); // attach effect to slot - EFX10.alAuxiliaryEffectSloti(reverbFxSlot, EFX10.AL_EFFECTSLOT_EFFECT, reverbFx); + efx.alAuxiliaryEffectSloti(reverbFxSlot, EFX.AL_EFFECTSLOT_EFFECT, reverbFx); } } @@ -645,7 +656,7 @@ public class LwjglAudioRenderer implements AudioRenderer, Runnable { nativeBuf.put(arrayBuf, 0, size); nativeBuf.flip(); - alBufferData(id, convertFormat(stream), nativeBuf, stream.getSampleRate()); + al.alBufferData(id, convertFormat(stream), nativeBuf, size, stream.getSampleRate()); return true; } @@ -656,21 +667,21 @@ public class LwjglAudioRenderer implements AudioRenderer, Runnable { } boolean active = true; - int processed = alGetSourcei(sourceId, AL_BUFFERS_PROCESSED); + int processed = al.alGetSourcei(sourceId, AL_BUFFERS_PROCESSED); // while((processed--) != 0){ if (processed > 0) { int buffer; ib.position(0).limit(1); - alSourceUnqueueBuffers(sourceId, ib); + al.alSourceUnqueueBuffers(sourceId, 1, ib); buffer = ib.get(0); active = fillBuffer(stream, buffer); ib.position(0).limit(1); ib.put(0, buffer); - alSourceQueueBuffers(sourceId, ib); + al.alSourceQueueBuffers(sourceId, 1, ib); } if (!active && stream.isOpen()) { @@ -686,13 +697,13 @@ public class LwjglAudioRenderer implements AudioRenderer, Runnable { active = fillBuffer(stream, id); ib.position(0).limit(1); ib.put(id).flip(); - alSourceQueueBuffers(sourceId, ib); + al.alSourceQueueBuffers(sourceId, 1, ib); } return active; } private boolean attachBufferToSource(int sourceId, AudioBuffer buffer) { - alSourcei(sourceId, AL_BUFFER, buffer.getId()); + al.alSourcei(sourceId, AL_BUFFER, buffer.getId()); return true; } @@ -711,25 +722,25 @@ public class LwjglAudioRenderer implements AudioRenderer, Runnable { AudioSource src = chanSrcs[index]; int sourceId = channels[index]; - alSourceStop(sourceId); + al.alSourceStop(sourceId); if (src.getAudioData() instanceof AudioStream) { AudioStream str = (AudioStream) src.getAudioData(); ib.position(0).limit(STREAMING_BUFFER_COUNT); ib.put(str.getIds()).flip(); - alSourceUnqueueBuffers(sourceId, ib); + al.alSourceUnqueueBuffers(sourceId, STREAMING_BUFFER_COUNT, ib); } else if (src.getAudioData() instanceof AudioBuffer) { - alSourcei(sourceId, AL_BUFFER, 0); + al.alSourcei(sourceId, AL_BUFFER, 0); } if (src.getDryFilter() != null && supportEfx) { // detach filter - alSourcei(sourceId, EFX10.AL_DIRECT_FILTER, EFX10.AL_FILTER_NULL); + al.alSourcei(sourceId, EFX.AL_DIRECT_FILTER, EFX.AL_FILTER_NULL); } if (src.isPositional()) { AudioSource pas = (AudioSource) src; if (pas.isReverbEnabled() && supportEfx) { - AL11.alSource3i(sourceId, EFX10.AL_AUXILIARY_SEND_FILTER, 0, 0, EFX10.AL_FILTER_NULL); + al.alSource3i(sourceId, EFX.AL_AUXILIARY_SEND_FILTER, 0, 0, EFX.AL_FILTER_NULL); } } @@ -764,7 +775,7 @@ public class LwjglAudioRenderer implements AudioRenderer, Runnable { // only buffered sources can be bound assert (boundSource && streaming) || (!streaming); - int state = alGetSourcei(sourceId, AL_SOURCE_STATE); + int state = al.alGetSourcei(sourceId, AL_SOURCE_STATE); boolean wantPlaying = src.getStatus() == Status.Playing; boolean stopped = state == AL_STOPPED; @@ -773,7 +784,7 @@ public class LwjglAudioRenderer implements AudioRenderer, Runnable { if (stream.isOpen()) { fillStreamingSource(sourceId, stream); if (stopped) { - alSourcePlay(sourceId); + al.alSourcePlay(sourceId); } } else { if (stopped) { @@ -833,6 +844,22 @@ public class LwjglAudioRenderer implements AudioRenderer, Runnable { setListenerParams(listener); } } + + public void pauseAll() { + if (!supportPauseDevice) { + throw new UnsupportedOperationException("Pause device is NOT supported!"); + } + + alc.alcDevicePauseSOFT(); + } + + public void resumeAll() { + if (!supportPauseDevice) { + throw new UnsupportedOperationException("Pause device is NOT supported!"); + } + + alc.alcDeviceResumeSOFT(); + } public void playSourceInstance(AudioSource src) { checkDead(); @@ -873,7 +900,7 @@ public class LwjglAudioRenderer implements AudioRenderer, Runnable { chanSrcs[index] = src; // play the channel - alSourcePlay(sourceId); + al.alSourcePlay(sourceId); } } @@ -915,7 +942,7 @@ public class LwjglAudioRenderer implements AudioRenderer, Runnable { attachAudioToSource(channels[index], data); } - alSourcePlay(channels[src.getChannel()]); + al.alSourcePlay(channels[src.getChannel()]); src.setStatus(Status.Playing); } } @@ -936,7 +963,7 @@ public class LwjglAudioRenderer implements AudioRenderer, Runnable { if (src.getStatus() == Status.Playing) { assert src.getChannel() != -1; - alSourcePause(channels[src.getChannel()]); + al.alSourcePause(channels[src.getChannel()]); src.setStatus(Status.Paused); } } @@ -1002,7 +1029,7 @@ public class LwjglAudioRenderer implements AudioRenderer, Runnable { int id = ab.getId(); if (ab.getId() == -1) { ib.position(0).limit(1); - alGenBuffers(ib); + al.alGenBuffers(1, ib); id = ib.get(0); ab.setId(id); @@ -1010,7 +1037,7 @@ public class LwjglAudioRenderer implements AudioRenderer, Runnable { } ab.getData().clear(); - alBufferData(id, convertFormat(ab), ab.getData(), ab.getSampleRate()); + al.alBufferData(id, convertFormat(ab), ab.getData(), ab.getData().capacity(), ab.getSampleRate()); ab.clearUpdateNeeded(); } @@ -1021,7 +1048,7 @@ public class LwjglAudioRenderer implements AudioRenderer, Runnable { int[] ids = new int[STREAMING_BUFFER_COUNT]; ib.position(0).limit(STREAMING_BUFFER_COUNT); - alGenBuffers(ib); + al.alGenBuffers(STREAMING_BUFFER_COUNT, ib); ib.position(0).limit(STREAMING_BUFFER_COUNT); ib.get(ids); @@ -1044,7 +1071,9 @@ public class LwjglAudioRenderer implements AudioRenderer, Runnable { public void deleteFilter(Filter filter) { int id = filter.getId(); if (id != -1) { - EFX10.alDeleteFilters(id); + ib.position(0).limit(1); + ib.put(id).flip(); + efx.alDeleteFilters(1, ib); } } @@ -1066,7 +1095,7 @@ public class LwjglAudioRenderer implements AudioRenderer, Runnable { if (id != -1) { ib.put(0, id); ib.position(0).limit(1); - alDeleteBuffers(ib); + al.alDeleteBuffers(1, ib); ab.resetObject(); } } else if (ad instanceof AudioStream) { @@ -1075,7 +1104,7 @@ public class LwjglAudioRenderer implements AudioRenderer, Runnable { if (ids != null) { ib.clear(); ib.put(ids).flip(); - alDeleteBuffers(ib); + al.alDeleteBuffers(ids.length, ib); as.resetObject(); } } diff --git a/jme3-core/src/main/java/com/jme3/audio/openal/ALC.java b/jme3-core/src/main/java/com/jme3/audio/openal/ALC.java new file mode 100644 index 000000000..a808ce376 --- /dev/null +++ b/jme3-core/src/main/java/com/jme3/audio/openal/ALC.java @@ -0,0 +1,73 @@ +package com.jme3.audio.openal; + +import java.nio.IntBuffer; + +public interface ALC { + + /** + * No error + */ + static final int ALC_NO_ERROR = 0; + + /** + * No device + */ + static final int ALC_INVALID_DEVICE = 0xA001; + + /** + * invalid context ID + */ + static final int ALC_INVALID_CONTEXT = 0xA002; + + /** + * bad enum + */ + static final int ALC_INVALID_ENUM = 0xA003; + + /** + * bad value + */ + static final int ALC_INVALID_VALUE = 0xA004; + + /** + * Out of memory. + */ + static final int ALC_OUT_OF_MEMORY = 0xA005; + + /** + * The Specifier string for default device + */ + static final int ALC_DEFAULT_DEVICE_SPECIFIER = 0x1004; + static final int ALC_DEVICE_SPECIFIER = 0x1005; + static final int ALC_EXTENSIONS = 0x1006; + + static final int ALC_MAJOR_VERSION = 0x1000; + static final int ALC_MINOR_VERSION = 0x1001; + + static final int ALC_ATTRIBUTES_SIZE = 0x1002; + static final int ALC_ALL_ATTRIBUTES = 0x1003; + + /** + * Capture extension + */ + static final int ALC_EXT_CAPTURE = 1; + static final int ALC_CAPTURE_DEVICE_SPECIFIER = 0x310; + static final int ALC_CAPTURE_DEFAULT_DEVICE_SPECIFIER = 0x311; + static final int ALC_CAPTURE_SAMPLES = 0x312; + + /** + * ALC_ENUMERATE_ALL_EXT enums + */ + static final int ALC_ENUMERATE_ALL_EXT = 1; + static final int ALC_DEFAULT_ALL_DEVICES_SPECIFIER = 0x1012; + static final int ALC_ALL_DEVICES_SPECIFIER = 0x1013; + + public void createALC(); + public void destroyALC(); + public boolean isCreated(); + public String alcGetString(int parameter); + public boolean alcIsExtensionPresent(String extension); + public void alcGetInteger(int param, IntBuffer buffer, int size); + public void alcDevicePauseSOFT(); + public void alcDeviceResumeSOFT(); +} diff --git a/jme3-core/src/main/java/com/jme3/audio/openal/ALUtil.java b/jme3-core/src/main/java/com/jme3/audio/openal/ALUtil.java new file mode 100644 index 000000000..9a69b6b37 --- /dev/null +++ b/jme3-core/src/main/java/com/jme3/audio/openal/ALUtil.java @@ -0,0 +1,43 @@ +package com.jme3.audio.openal; + +import static com.jme3.audio.openal.AL.*; + +public final class ALUtil { + + private ALUtil() { + } + + public static String getALErrorMessage(int errorCode) { + String errorText; + switch (errorCode) { + case AL_NO_ERROR: + errorText = "No Error"; + break; + case AL_INVALID_NAME: + errorText = "Invalid Name"; + break; + case AL_INVALID_ENUM: + errorText = "Invalid Enum"; + break; + case AL_INVALID_VALUE: + errorText = "Invalid Value"; + break; + case AL_INVALID_OPERATION: + errorText = "Invalid Operation"; + break; + case AL_OUT_OF_MEMORY: + errorText = "Out of Memory"; + break; + default: + errorText = "Unknown Error Code: " + String.valueOf(errorCode); + } + return errorText; + } + + public static void checkALError(AL al) { + int err = al.alGetError(); + if (err != AL_NO_ERROR) { + throw new RuntimeException("OpenAL Error: " + getALErrorMessage(err)); + } + } +} diff --git a/jme3-android/src/main/java/com/jme3/audio/android/AL.java b/jme3-core/src/main/java/com/jme3/audio/openal/EFX.java similarity index 73% rename from jme3-android/src/main/java/com/jme3/audio/android/AL.java rename to jme3-core/src/main/java/com/jme3/audio/openal/EFX.java index d8fea3933..89f0a6e0c 100644 --- a/jme3-android/src/main/java/com/jme3/audio/android/AL.java +++ b/jme3-core/src/main/java/com/jme3/audio/openal/EFX.java @@ -1,1054 +1,679 @@ -package com.jme3.audio.android; - -/** - * - * @author iwgeric - */ -public class AL { - - - - /* ********** */ - /* FROM ALC.h */ - /* ********** */ - -// typedef struct ALCdevice_struct ALCdevice; -// typedef struct ALCcontext_struct ALCcontext; - - - /** - * No error - */ - static final int ALC_NO_ERROR = 0; - - /** - * No device - */ - static final int ALC_INVALID_DEVICE = 0xA001; - - /** - * invalid context ID - */ - static final int ALC_INVALID_CONTEXT = 0xA002; - - /** - * bad enum - */ - static final int ALC_INVALID_ENUM = 0xA003; - - /** - * bad value - */ - static final int ALC_INVALID_VALUE = 0xA004; - - /** - * Out of memory. - */ - static final int ALC_OUT_OF_MEMORY = 0xA005; - - - /** - * The Specifier string for default device - */ - static final int ALC_DEFAULT_DEVICE_SPECIFIER = 0x1004; - static final int ALC_DEVICE_SPECIFIER = 0x1005; - static final int ALC_EXTENSIONS = 0x1006; - - static final int ALC_MAJOR_VERSION = 0x1000; - static final int ALC_MINOR_VERSION = 0x1001; - - static final int ALC_ATTRIBUTES_SIZE = 0x1002; - static final int ALC_ALL_ATTRIBUTES = 0x1003; - - - /** - * Capture extension - */ - static final int ALC_EXT_CAPTURE = 1; - static final int ALC_CAPTURE_DEVICE_SPECIFIER = 0x310; - static final int ALC_CAPTURE_DEFAULT_DEVICE_SPECIFIER = 0x311; - static final int ALC_CAPTURE_SAMPLES = 0x312; - - - /** - * ALC_ENUMERATE_ALL_EXT enums - */ - static final int ALC_ENUMERATE_ALL_EXT = 1; - static final int ALC_DEFAULT_ALL_DEVICES_SPECIFIER = 0x1012; - static final int ALC_ALL_DEVICES_SPECIFIER = 0x1013; - - - /* ********** */ - /* FROM AL.h */ - /* ********** */ - -/** Boolean False. */ - static final int AL_FALSE = 0; - -/** Boolean True. */ - static final int AL_TRUE = 1; - -/* "no distance model" or "no buffer" */ - static final int AL_NONE = 0; - -/** Indicate Source has relative coordinates. */ - static final int AL_SOURCE_RELATIVE = 0x202; - - - -/** - * Directional source, inner cone angle, in degrees. - * Range: [0-360] - * Default: 360 - */ - static final int AL_CONE_INNER_ANGLE = 0x1001; - -/** - * Directional source, outer cone angle, in degrees. - * Range: [0-360] - * Default: 360 - */ - static final int AL_CONE_OUTER_ANGLE = 0x1002; - -/** - * Specify the pitch to be applied at source. - * Range: [0.5-2.0] - * Default: 1.0 - */ - static final int AL_PITCH = 0x1003; - -/** - * Specify the current location in three dimensional space. - * OpenAL, like OpenGL, uses a right handed coordinate system, - * where in a frontal default view X (thumb) points right, - * Y points up (index finger), and Z points towards the - * viewer/camera (middle finger). - * To switch from a left handed coordinate system, flip the - * sign on the Z coordinate. - * Listener position is always in the world coordinate system. - */ - static final int AL_POSITION = 0x1004; - -/** Specify the current direction. */ - static final int AL_DIRECTION = 0x1005; - -/** Specify the current velocity in three dimensional space. */ - static final int AL_VELOCITY = 0x1006; - -/** - * Indicate whether source is looping. - * Type: ALboolean? - * Range: [AL_TRUE, AL_FALSE] - * Default: FALSE. - */ - static final int AL_LOOPING = 0x1007; - -/** - * Indicate the buffer to provide sound samples. - * Type: ALuint. - * Range: any valid Buffer id. - */ - static final int AL_BUFFER = 0x1009; - -/** - * Indicate the gain (volume amplification) applied. - * Type: ALfloat. - * Range: ]0.0- ] - * A value of 1.0 means un-attenuated/unchanged. - * Each division by 2 equals an attenuation of -6dB. - * Each multiplicaton with 2 equals an amplification of +6dB. - * A value of 0.0 is meaningless with respect to a logarithmic - * scale; it is interpreted as zero volume - the channel - * is effectively disabled. - */ - static final int AL_GAIN = 0x100A; - -/* - * Indicate minimum source attenuation - * Type: ALfloat - * Range: [0.0 - 1.0] - * - * Logarthmic - */ - static final int AL_MIN_GAIN = 0x100D; - -/** - * Indicate maximum source attenuation - * Type: ALfloat - * Range: [0.0 - 1.0] - * - * Logarthmic - */ - static final int AL_MAX_GAIN = 0x100E; - -/** - * Indicate listener orientation. - * - * at/up - */ - static final int AL_ORIENTATION = 0x100F; - -/** - * Source state information. - */ - static final int AL_SOURCE_STATE = 0x1010; - static final int AL_INITIAL = 0x1011; - static final int AL_PLAYING = 0x1012; - static final int AL_PAUSED = 0x1013; - static final int AL_STOPPED = 0x1014; - -/** - * Buffer Queue params - */ - static final int AL_BUFFERS_QUEUED = 0x1015; - static final int AL_BUFFERS_PROCESSED = 0x1016; - -/** - * Source buffer position information - */ - static final int AL_SEC_OFFSET = 0x1024; - static final int AL_SAMPLE_OFFSET = 0x1025; - static final int AL_BYTE_OFFSET = 0x1026; - -/* - * Source type (Static, Streaming or undetermined) - * Source is Static if a Buffer has been attached using AL_BUFFER - * Source is Streaming if one or more Buffers have been attached using alSourceQueueBuffers - * Source is undetermined when it has the NULL buffer attached - */ - static final int AL_SOURCE_TYPE = 0x1027; - static final int AL_STATIC = 0x1028; - static final int AL_STREAMING = 0x1029; - static final int AL_UNDETERMINED = 0x1030; - -/** Sound samples: format specifier. */ - static final int AL_FORMAT_MONO8 = 0x1100; - static final int AL_FORMAT_MONO16 = 0x1101; - static final int AL_FORMAT_STEREO8 = 0x1102; - static final int AL_FORMAT_STEREO16 = 0x1103; - -/** - * source specific reference distance - * Type: ALfloat - * Range: 0.0 - +inf - * - * At 0.0, no distance attenuation occurs. Default is - * 1.0. - */ - static final int AL_REFERENCE_DISTANCE = 0x1020; - -/** - * source specific rolloff factor - * Type: ALfloat - * Range: 0.0 - +inf - * - */ - static final int AL_ROLLOFF_FACTOR = 0x1021; - -/** - * Directional source, outer cone gain. - * - * Default: 0.0 - * Range: [0.0 - 1.0] - * Logarithmic - */ - static final int AL_CONE_OUTER_GAIN = 0x1022; - -/** - * Indicate distance above which sources are not - * attenuated using the inverse clamped distance model. - * - * Default: +inf - * Type: ALfloat - * Range: 0.0 - +inf - */ - static final int AL_MAX_DISTANCE = 0x1023; - -/** - * Sound samples: frequency, in units of Hertz [Hz]. - * This is the number of samples per second. Half of the - * sample frequency marks the maximum significant - * frequency component. - */ - static final int AL_FREQUENCY = 0x2001; - static final int AL_BITS = 0x2002; - static final int AL_CHANNELS = 0x2003; - static final int AL_SIZE = 0x2004; - -/** - * Buffer state. - * - * Not supported for public use (yet). - */ - static final int AL_UNUSED = 0x2010; - static final int AL_PENDING = 0x2011; - static final int AL_PROCESSED = 0x2012; - - -/** Errors: No Error. */ - static final int AL_NO_ERROR = 0; - -/** - * Invalid Name paramater passed to AL call. - */ - static final int AL_INVALID_NAME = 0xA001; - -/** - * Invalid parameter passed to AL call. - */ - static final int AL_INVALID_ENUM = 0xA002; - -/** - * Invalid enum parameter value. - */ - static final int AL_INVALID_VALUE = 0xA003; - -/** - * Illegal call. - */ - static final int AL_INVALID_OPERATION = 0xA004; - - -/** - * No mojo. - */ - static final int AL_OUT_OF_MEMORY = 0xA005; - - -/** Context strings: Vendor Name. */ - static final int AL_VENDOR = 0xB001; - static final int AL_VERSION = 0xB002; - static final int AL_RENDERER = 0xB003; - static final int AL_EXTENSIONS = 0xB004; - -/** Global tweakage. */ - -/** - * Doppler scale. Default 1.0 - */ - static final int AL_DOPPLER_FACTOR = 0xC000; - -/** - * Tweaks speed of propagation. - */ - static final int AL_DOPPLER_VELOCITY = 0xC001; - -/** - * Speed of Sound in units per second - */ - static final int AL_SPEED_OF_SOUND = 0xC003; - -/** - * Distance models - * - * used in conjunction with DistanceModel - * - * implicit: NONE, which disances distance attenuation. - */ - static final int AL_DISTANCE_MODEL = 0xD000; - static final int AL_INVERSE_DISTANCE = 0xD001; - static final int AL_INVERSE_DISTANCE_CLAMPED = 0xD002; - static final int AL_LINEAR_DISTANCE = 0xD003; - static final int AL_LINEAR_DISTANCE_CLAMPED = 0xD004; - static final int AL_EXPONENT_DISTANCE = 0xD005; - static final int AL_EXPONENT_DISTANCE_CLAMPED = 0xD006; - - /* ********** */ - /* FROM efx.h */ - /* ********** */ - - static final String ALC_EXT_EFX_NAME = "ALC_EXT_EFX"; - - static final int ALC_EFX_MAJOR_VERSION = 0x20001; - static final int ALC_EFX_MINOR_VERSION = 0x20002; - static final int ALC_MAX_AUXILIARY_SENDS = 0x20003; - - -///* Listener properties. */ -//#define AL_METERS_PER_UNIT 0x20004 -// -///* Source properties. */ - static final int AL_DIRECT_FILTER = 0x20005; - static final int AL_AUXILIARY_SEND_FILTER = 0x20006; -//#define AL_AIR_ABSORPTION_FACTOR 0x20007 -//#define AL_ROOM_ROLLOFF_FACTOR 0x20008 -//#define AL_CONE_OUTER_GAINHF 0x20009 - static final int AL_DIRECT_FILTER_GAINHF_AUTO = 0x2000A; -//#define AL_AUXILIARY_SEND_FILTER_GAIN_AUTO 0x2000B -//#define AL_AUXILIARY_SEND_FILTER_GAINHF_AUTO 0x2000C -// -// -///* Effect properties. */ -// -///* Reverb effect parameters */ - static final int AL_REVERB_DENSITY = 0x0001; - static final int AL_REVERB_DIFFUSION = 0x0002; - static final int AL_REVERB_GAIN = 0x0003; - static final int AL_REVERB_GAINHF = 0x0004; - static final int AL_REVERB_DECAY_TIME = 0x0005; - static final int AL_REVERB_DECAY_HFRATIO = 0x0006; - static final int AL_REVERB_REFLECTIONS_GAIN = 0x0007; - static final int AL_REVERB_REFLECTIONS_DELAY = 0x0008; - static final int AL_REVERB_LATE_REVERB_GAIN = 0x0009; - static final int AL_REVERB_LATE_REVERB_DELAY = 0x000A; - static final int AL_REVERB_AIR_ABSORPTION_GAINHF = 0x000B; - static final int AL_REVERB_ROOM_ROLLOFF_FACTOR = 0x000C; - static final int AL_REVERB_DECAY_HFLIMIT = 0x000D; - -///* EAX Reverb effect parameters */ -//#define AL_EAXREVERB_DENSITY 0x0001 -//#define AL_EAXREVERB_DIFFUSION 0x0002 -//#define AL_EAXREVERB_GAIN 0x0003 -//#define AL_EAXREVERB_GAINHF 0x0004 -//#define AL_EAXREVERB_GAINLF 0x0005 -//#define AL_EAXREVERB_DECAY_TIME 0x0006 -//#define AL_EAXREVERB_DECAY_HFRATIO 0x0007 -//#define AL_EAXREVERB_DECAY_LFRATIO 0x0008 -//#define AL_EAXREVERB_REFLECTIONS_GAIN 0x0009 -//#define AL_EAXREVERB_REFLECTIONS_DELAY 0x000A -//#define AL_EAXREVERB_REFLECTIONS_PAN 0x000B -//#define AL_EAXREVERB_LATE_REVERB_GAIN 0x000C -//#define AL_EAXREVERB_LATE_REVERB_DELAY 0x000D -//#define AL_EAXREVERB_LATE_REVERB_PAN 0x000E -//#define AL_EAXREVERB_ECHO_TIME 0x000F -//#define AL_EAXREVERB_ECHO_DEPTH 0x0010 -//#define AL_EAXREVERB_MODULATION_TIME 0x0011 -//#define AL_EAXREVERB_MODULATION_DEPTH 0x0012 -//#define AL_EAXREVERB_AIR_ABSORPTION_GAINHF 0x0013 -//#define AL_EAXREVERB_HFREFERENCE 0x0014 -//#define AL_EAXREVERB_LFREFERENCE 0x0015 -//#define AL_EAXREVERB_ROOM_ROLLOFF_FACTOR 0x0016 -//#define AL_EAXREVERB_DECAY_HFLIMIT 0x0017 -// -///* Chorus effect parameters */ -//#define AL_CHORUS_WAVEFORM 0x0001 -//#define AL_CHORUS_PHASE 0x0002 -//#define AL_CHORUS_RATE 0x0003 -//#define AL_CHORUS_DEPTH 0x0004 -//#define AL_CHORUS_FEEDBACK 0x0005 -//#define AL_CHORUS_DELAY 0x0006 -// -///* Distortion effect parameters */ -//#define AL_DISTORTION_EDGE 0x0001 -//#define AL_DISTORTION_GAIN 0x0002 -//#define AL_DISTORTION_LOWPASS_CUTOFF 0x0003 -//#define AL_DISTORTION_EQCENTER 0x0004 -//#define AL_DISTORTION_EQBANDWIDTH 0x0005 -// -///* Echo effect parameters */ -//#define AL_ECHO_DELAY 0x0001 -//#define AL_ECHO_LRDELAY 0x0002 -//#define AL_ECHO_DAMPING 0x0003 -//#define AL_ECHO_FEEDBACK 0x0004 -//#define AL_ECHO_SPREAD 0x0005 -// -///* Flanger effect parameters */ -//#define AL_FLANGER_WAVEFORM 0x0001 -//#define AL_FLANGER_PHASE 0x0002 -//#define AL_FLANGER_RATE 0x0003 -//#define AL_FLANGER_DEPTH 0x0004 -//#define AL_FLANGER_FEEDBACK 0x0005 -//#define AL_FLANGER_DELAY 0x0006 -// -///* Frequency shifter effect parameters */ -//#define AL_FREQUENCY_SHIFTER_FREQUENCY 0x0001 -//#define AL_FREQUENCY_SHIFTER_LEFT_DIRECTION 0x0002 -//#define AL_FREQUENCY_SHIFTER_RIGHT_DIRECTION 0x0003 -// -///* Vocal morpher effect parameters */ -//#define AL_VOCAL_MORPHER_PHONEMEA 0x0001 -//#define AL_VOCAL_MORPHER_PHONEMEA_COARSE_TUNING 0x0002 -//#define AL_VOCAL_MORPHER_PHONEMEB 0x0003 -//#define AL_VOCAL_MORPHER_PHONEMEB_COARSE_TUNING 0x0004 -//#define AL_VOCAL_MORPHER_WAVEFORM 0x0005 -//#define AL_VOCAL_MORPHER_RATE 0x0006 -// -///* Pitchshifter effect parameters */ -//#define AL_PITCH_SHIFTER_COARSE_TUNE 0x0001 -//#define AL_PITCH_SHIFTER_FINE_TUNE 0x0002 -// -///* Ringmodulator effect parameters */ -//#define AL_RING_MODULATOR_FREQUENCY 0x0001 -//#define AL_RING_MODULATOR_HIGHPASS_CUTOFF 0x0002 -//#define AL_RING_MODULATOR_WAVEFORM 0x0003 -// -///* Autowah effect parameters */ -//#define AL_AUTOWAH_ATTACK_TIME 0x0001 -//#define AL_AUTOWAH_RELEASE_TIME 0x0002 -//#define AL_AUTOWAH_RESONANCE 0x0003 -//#define AL_AUTOWAH_PEAK_GAIN 0x0004 -// -///* Compressor effect parameters */ -//#define AL_COMPRESSOR_ONOFF 0x0001 -// -///* Equalizer effect parameters */ -//#define AL_EQUALIZER_LOW_GAIN 0x0001 -//#define AL_EQUALIZER_LOW_CUTOFF 0x0002 -//#define AL_EQUALIZER_MID1_GAIN 0x0003 -//#define AL_EQUALIZER_MID1_CENTER 0x0004 -//#define AL_EQUALIZER_MID1_WIDTH 0x0005 -//#define AL_EQUALIZER_MID2_GAIN 0x0006 -//#define AL_EQUALIZER_MID2_CENTER 0x0007 -//#define AL_EQUALIZER_MID2_WIDTH 0x0008 -//#define AL_EQUALIZER_HIGH_GAIN 0x0009 -//#define AL_EQUALIZER_HIGH_CUTOFF 0x000A -// -///* Effect type */ -//#define AL_EFFECT_FIRST_PARAMETER 0x0000 -//#define AL_EFFECT_LAST_PARAMETER 0x8000 - static final int AL_EFFECT_TYPE = 0x8001; -// -///* Effect types, used with the AL_EFFECT_TYPE property */ -//#define AL_EFFECT_NULL 0x0000 - static final int AL_EFFECT_REVERB = 0x0001; -//#define AL_EFFECT_CHORUS 0x0002 -//#define AL_EFFECT_DISTORTION 0x0003 -//#define AL_EFFECT_ECHO 0x0004 -//#define AL_EFFECT_FLANGER 0x0005 -//#define AL_EFFECT_FREQUENCY_SHIFTER 0x0006 -//#define AL_EFFECT_VOCAL_MORPHER 0x0007 -//#define AL_EFFECT_PITCH_SHIFTER 0x0008 -//#define AL_EFFECT_RING_MODULATOR 0x0009 -//#define AL_EFFECT_AUTOWAH 0x000A -//#define AL_EFFECT_COMPRESSOR 0x000B -//#define AL_EFFECT_EQUALIZER 0x000C -//#define AL_EFFECT_EAXREVERB 0x8000 -// -///* Auxiliary Effect Slot properties. */ - static final int AL_EFFECTSLOT_EFFECT = 0x0001; -//#define AL_EFFECTSLOT_GAIN 0x0002 -//#define AL_EFFECTSLOT_AUXILIARY_SEND_AUTO 0x0003 -// -///* NULL Auxiliary Slot ID to disable a source send. */ -//#define AL_EFFECTSLOT_NULL 0x0000 -// -// -///* Filter properties. */ -// -///* Lowpass filter parameters */ - static final int AL_LOWPASS_GAIN = 0x0001; - static final int AL_LOWPASS_GAINHF = 0x0002; -// -///* Highpass filter parameters */ -//#define AL_HIGHPASS_GAIN 0x0001 -//#define AL_HIGHPASS_GAINLF 0x0002 -// -///* Bandpass filter parameters */ -//#define AL_BANDPASS_GAIN 0x0001 -//#define AL_BANDPASS_GAINLF 0x0002 -//#define AL_BANDPASS_GAINHF 0x0003 -// -///* Filter type */ -//#define AL_FILTER_FIRST_PARAMETER 0x0000 -//#define AL_FILTER_LAST_PARAMETER 0x8000 - static final int AL_FILTER_TYPE = 0x8001; -// -///* Filter types, used with the AL_FILTER_TYPE property */ - static final int AL_FILTER_NULL = 0x0000; - static final int AL_FILTER_LOWPASS = 0x0001; - static final int AL_FILTER_HIGHPASS = 0x0002; -//#define AL_FILTER_BANDPASS 0x0003 -// -///* Filter ranges and defaults. */ -// -///* Lowpass filter */ -//#define AL_LOWPASS_MIN_GAIN (0.0f) -//#define AL_LOWPASS_MAX_GAIN (1.0f) -//#define AL_LOWPASS_DEFAULT_GAIN (1.0f) -// -//#define AL_LOWPASS_MIN_GAINHF (0.0f) -//#define AL_LOWPASS_MAX_GAINHF (1.0f) -//#define AL_LOWPASS_DEFAULT_GAINHF (1.0f) -// -///* Highpass filter */ -//#define AL_HIGHPASS_MIN_GAIN (0.0f) -//#define AL_HIGHPASS_MAX_GAIN (1.0f) -//#define AL_HIGHPASS_DEFAULT_GAIN (1.0f) -// -//#define AL_HIGHPASS_MIN_GAINLF (0.0f) -//#define AL_HIGHPASS_MAX_GAINLF (1.0f) -//#define AL_HIGHPASS_DEFAULT_GAINLF (1.0f) -// -///* Bandpass filter */ -//#define AL_BANDPASS_MIN_GAIN (0.0f) -//#define AL_BANDPASS_MAX_GAIN (1.0f) -//#define AL_BANDPASS_DEFAULT_GAIN (1.0f) -// -//#define AL_BANDPASS_MIN_GAINHF (0.0f) -//#define AL_BANDPASS_MAX_GAINHF (1.0f) -//#define AL_BANDPASS_DEFAULT_GAINHF (1.0f) -// -//#define AL_BANDPASS_MIN_GAINLF (0.0f) -//#define AL_BANDPASS_MAX_GAINLF (1.0f) -//#define AL_BANDPASS_DEFAULT_GAINLF (1.0f) -// -// -///* Effect parameter ranges and defaults. */ -// -///* Standard reverb effect */ -//#define AL_REVERB_MIN_DENSITY (0.0f) -//#define AL_REVERB_MAX_DENSITY (1.0f) -//#define AL_REVERB_DEFAULT_DENSITY (1.0f) -// -//#define AL_REVERB_MIN_DIFFUSION (0.0f) -//#define AL_REVERB_MAX_DIFFUSION (1.0f) -//#define AL_REVERB_DEFAULT_DIFFUSION (1.0f) -// -//#define AL_REVERB_MIN_GAIN (0.0f) -//#define AL_REVERB_MAX_GAIN (1.0f) -//#define AL_REVERB_DEFAULT_GAIN (0.32f) -// -//#define AL_REVERB_MIN_GAINHF (0.0f) -//#define AL_REVERB_MAX_GAINHF (1.0f) -//#define AL_REVERB_DEFAULT_GAINHF (0.89f) -// -//#define AL_REVERB_MIN_DECAY_TIME (0.1f) -//#define AL_REVERB_MAX_DECAY_TIME (20.0f) -//#define AL_REVERB_DEFAULT_DECAY_TIME (1.49f) -// -//#define AL_REVERB_MIN_DECAY_HFRATIO (0.1f) -//#define AL_REVERB_MAX_DECAY_HFRATIO (2.0f) -//#define AL_REVERB_DEFAULT_DECAY_HFRATIO (0.83f) -// -//#define AL_REVERB_MIN_REFLECTIONS_GAIN (0.0f) -//#define AL_REVERB_MAX_REFLECTIONS_GAIN (3.16f) -//#define AL_REVERB_DEFAULT_REFLECTIONS_GAIN (0.05f) -// -//#define AL_REVERB_MIN_REFLECTIONS_DELAY (0.0f) -//#define AL_REVERB_MAX_REFLECTIONS_DELAY (0.3f) -//#define AL_REVERB_DEFAULT_REFLECTIONS_DELAY (0.007f) -// -//#define AL_REVERB_MIN_LATE_REVERB_GAIN (0.0f) -//#define AL_REVERB_MAX_LATE_REVERB_GAIN (10.0f) -//#define AL_REVERB_DEFAULT_LATE_REVERB_GAIN (1.26f) -// -//#define AL_REVERB_MIN_LATE_REVERB_DELAY (0.0f) -//#define AL_REVERB_MAX_LATE_REVERB_DELAY (0.1f) -//#define AL_REVERB_DEFAULT_LATE_REVERB_DELAY (0.011f) -// -//#define AL_REVERB_MIN_AIR_ABSORPTION_GAINHF (0.892f) -//#define AL_REVERB_MAX_AIR_ABSORPTION_GAINHF (1.0f) -//#define AL_REVERB_DEFAULT_AIR_ABSORPTION_GAINHF (0.994f) -// -//#define AL_REVERB_MIN_ROOM_ROLLOFF_FACTOR (0.0f) -//#define AL_REVERB_MAX_ROOM_ROLLOFF_FACTOR (10.0f) -//#define AL_REVERB_DEFAULT_ROOM_ROLLOFF_FACTOR (0.0f) -// -//#define AL_REVERB_MIN_DECAY_HFLIMIT AL_FALSE -//#define AL_REVERB_MAX_DECAY_HFLIMIT AL_TRUE -//#define AL_REVERB_DEFAULT_DECAY_HFLIMIT AL_TRUE -// -///* EAX reverb effect */ -//#define AL_EAXREVERB_MIN_DENSITY (0.0f) -//#define AL_EAXREVERB_MAX_DENSITY (1.0f) -//#define AL_EAXREVERB_DEFAULT_DENSITY (1.0f) -// -//#define AL_EAXREVERB_MIN_DIFFUSION (0.0f) -//#define AL_EAXREVERB_MAX_DIFFUSION (1.0f) -//#define AL_EAXREVERB_DEFAULT_DIFFUSION (1.0f) -// -//#define AL_EAXREVERB_MIN_GAIN (0.0f) -//#define AL_EAXREVERB_MAX_GAIN (1.0f) -//#define AL_EAXREVERB_DEFAULT_GAIN (0.32f) -// -//#define AL_EAXREVERB_MIN_GAINHF (0.0f) -//#define AL_EAXREVERB_MAX_GAINHF (1.0f) -//#define AL_EAXREVERB_DEFAULT_GAINHF (0.89f) -// -//#define AL_EAXREVERB_MIN_GAINLF (0.0f) -//#define AL_EAXREVERB_MAX_GAINLF (1.0f) -//#define AL_EAXREVERB_DEFAULT_GAINLF (1.0f) -// -//#define AL_EAXREVERB_MIN_DECAY_TIME (0.1f) -//#define AL_EAXREVERB_MAX_DECAY_TIME (20.0f) -//#define AL_EAXREVERB_DEFAULT_DECAY_TIME (1.49f) -// -//#define AL_EAXREVERB_MIN_DECAY_HFRATIO (0.1f) -//#define AL_EAXREVERB_MAX_DECAY_HFRATIO (2.0f) -//#define AL_EAXREVERB_DEFAULT_DECAY_HFRATIO (0.83f) -// -//#define AL_EAXREVERB_MIN_DECAY_LFRATIO (0.1f) -//#define AL_EAXREVERB_MAX_DECAY_LFRATIO (2.0f) -//#define AL_EAXREVERB_DEFAULT_DECAY_LFRATIO (1.0f) -// -//#define AL_EAXREVERB_MIN_REFLECTIONS_GAIN (0.0f) -//#define AL_EAXREVERB_MAX_REFLECTIONS_GAIN (3.16f) -//#define AL_EAXREVERB_DEFAULT_REFLECTIONS_GAIN (0.05f) -// -//#define AL_EAXREVERB_MIN_REFLECTIONS_DELAY (0.0f) -//#define AL_EAXREVERB_MAX_REFLECTIONS_DELAY (0.3f) -//#define AL_EAXREVERB_DEFAULT_REFLECTIONS_DELAY (0.007f) -// -//#define AL_EAXREVERB_DEFAULT_REFLECTIONS_PAN_XYZ (0.0f) -// -//#define AL_EAXREVERB_MIN_LATE_REVERB_GAIN (0.0f) -//#define AL_EAXREVERB_MAX_LATE_REVERB_GAIN (10.0f) -//#define AL_EAXREVERB_DEFAULT_LATE_REVERB_GAIN (1.26f) -// -//#define AL_EAXREVERB_MIN_LATE_REVERB_DELAY (0.0f) -//#define AL_EAXREVERB_MAX_LATE_REVERB_DELAY (0.1f) -//#define AL_EAXREVERB_DEFAULT_LATE_REVERB_DELAY (0.011f) -// -//#define AL_EAXREVERB_DEFAULT_LATE_REVERB_PAN_XYZ (0.0f) -// -//#define AL_EAXREVERB_MIN_ECHO_TIME (0.075f) -//#define AL_EAXREVERB_MAX_ECHO_TIME (0.25f) -//#define AL_EAXREVERB_DEFAULT_ECHO_TIME (0.25f) -// -//#define AL_EAXREVERB_MIN_ECHO_DEPTH (0.0f) -//#define AL_EAXREVERB_MAX_ECHO_DEPTH (1.0f) -//#define AL_EAXREVERB_DEFAULT_ECHO_DEPTH (0.0f) -// -//#define AL_EAXREVERB_MIN_MODULATION_TIME (0.04f) -//#define AL_EAXREVERB_MAX_MODULATION_TIME (4.0f) -//#define AL_EAXREVERB_DEFAULT_MODULATION_TIME (0.25f) -// -//#define AL_EAXREVERB_MIN_MODULATION_DEPTH (0.0f) -//#define AL_EAXREVERB_MAX_MODULATION_DEPTH (1.0f) -//#define AL_EAXREVERB_DEFAULT_MODULATION_DEPTH (0.0f) -// -//#define AL_EAXREVERB_MIN_AIR_ABSORPTION_GAINHF (0.892f) -//#define AL_EAXREVERB_MAX_AIR_ABSORPTION_GAINHF (1.0f) -//#define AL_EAXREVERB_DEFAULT_AIR_ABSORPTION_GAINHF (0.994f) -// -//#define AL_EAXREVERB_MIN_HFREFERENCE (1000.0f) -//#define AL_EAXREVERB_MAX_HFREFERENCE (20000.0f) -//#define AL_EAXREVERB_DEFAULT_HFREFERENCE (5000.0f) -// -//#define AL_EAXREVERB_MIN_LFREFERENCE (20.0f) -//#define AL_EAXREVERB_MAX_LFREFERENCE (1000.0f) -//#define AL_EAXREVERB_DEFAULT_LFREFERENCE (250.0f) -// -//#define AL_EAXREVERB_MIN_ROOM_ROLLOFF_FACTOR (0.0f) -//#define AL_EAXREVERB_MAX_ROOM_ROLLOFF_FACTOR (10.0f) -//#define AL_EAXREVERB_DEFAULT_ROOM_ROLLOFF_FACTOR (0.0f) -// -//#define AL_EAXREVERB_MIN_DECAY_HFLIMIT AL_FALSE -//#define AL_EAXREVERB_MAX_DECAY_HFLIMIT AL_TRUE -//#define AL_EAXREVERB_DEFAULT_DECAY_HFLIMIT AL_TRUE -// -///* Chorus effect */ -//#define AL_CHORUS_WAVEFORM_SINUSOID (0) -//#define AL_CHORUS_WAVEFORM_TRIANGLE (1) -// -//#define AL_CHORUS_MIN_WAVEFORM (0) -//#define AL_CHORUS_MAX_WAVEFORM (1) -//#define AL_CHORUS_DEFAULT_WAVEFORM (1) -// -//#define AL_CHORUS_MIN_PHASE (-180) -//#define AL_CHORUS_MAX_PHASE (180) -//#define AL_CHORUS_DEFAULT_PHASE (90) -// -//#define AL_CHORUS_MIN_RATE (0.0f) -//#define AL_CHORUS_MAX_RATE (10.0f) -//#define AL_CHORUS_DEFAULT_RATE (1.1f) -// -//#define AL_CHORUS_MIN_DEPTH (0.0f) -//#define AL_CHORUS_MAX_DEPTH (1.0f) -//#define AL_CHORUS_DEFAULT_DEPTH (0.1f) -// -//#define AL_CHORUS_MIN_FEEDBACK (-1.0f) -//#define AL_CHORUS_MAX_FEEDBACK (1.0f) -//#define AL_CHORUS_DEFAULT_FEEDBACK (0.25f) -// -//#define AL_CHORUS_MIN_DELAY (0.0f) -//#define AL_CHORUS_MAX_DELAY (0.016f) -//#define AL_CHORUS_DEFAULT_DELAY (0.016f) -// -///* Distortion effect */ -//#define AL_DISTORTION_MIN_EDGE (0.0f) -//#define AL_DISTORTION_MAX_EDGE (1.0f) -//#define AL_DISTORTION_DEFAULT_EDGE (0.2f) -// -//#define AL_DISTORTION_MIN_GAIN (0.01f) -//#define AL_DISTORTION_MAX_GAIN (1.0f) -//#define AL_DISTORTION_DEFAULT_GAIN (0.05f) -// -//#define AL_DISTORTION_MIN_LOWPASS_CUTOFF (80.0f) -//#define AL_DISTORTION_MAX_LOWPASS_CUTOFF (24000.0f) -//#define AL_DISTORTION_DEFAULT_LOWPASS_CUTOFF (8000.0f) -// -//#define AL_DISTORTION_MIN_EQCENTER (80.0f) -//#define AL_DISTORTION_MAX_EQCENTER (24000.0f) -//#define AL_DISTORTION_DEFAULT_EQCENTER (3600.0f) -// -//#define AL_DISTORTION_MIN_EQBANDWIDTH (80.0f) -//#define AL_DISTORTION_MAX_EQBANDWIDTH (24000.0f) -//#define AL_DISTORTION_DEFAULT_EQBANDWIDTH (3600.0f) -// -///* Echo effect */ -//#define AL_ECHO_MIN_DELAY (0.0f) -//#define AL_ECHO_MAX_DELAY (0.207f) -//#define AL_ECHO_DEFAULT_DELAY (0.1f) -// -//#define AL_ECHO_MIN_LRDELAY (0.0f) -//#define AL_ECHO_MAX_LRDELAY (0.404f) -//#define AL_ECHO_DEFAULT_LRDELAY (0.1f) -// -//#define AL_ECHO_MIN_DAMPING (0.0f) -//#define AL_ECHO_MAX_DAMPING (0.99f) -//#define AL_ECHO_DEFAULT_DAMPING (0.5f) -// -//#define AL_ECHO_MIN_FEEDBACK (0.0f) -//#define AL_ECHO_MAX_FEEDBACK (1.0f) -//#define AL_ECHO_DEFAULT_FEEDBACK (0.5f) -// -//#define AL_ECHO_MIN_SPREAD (-1.0f) -//#define AL_ECHO_MAX_SPREAD (1.0f) -//#define AL_ECHO_DEFAULT_SPREAD (-1.0f) -// -///* Flanger effect */ -//#define AL_FLANGER_WAVEFORM_SINUSOID (0) -//#define AL_FLANGER_WAVEFORM_TRIANGLE (1) -// -//#define AL_FLANGER_MIN_WAVEFORM (0) -//#define AL_FLANGER_MAX_WAVEFORM (1) -//#define AL_FLANGER_DEFAULT_WAVEFORM (1) -// -//#define AL_FLANGER_MIN_PHASE (-180) -//#define AL_FLANGER_MAX_PHASE (180) -//#define AL_FLANGER_DEFAULT_PHASE (0) -// -//#define AL_FLANGER_MIN_RATE (0.0f) -//#define AL_FLANGER_MAX_RATE (10.0f) -//#define AL_FLANGER_DEFAULT_RATE (0.27f) -// -//#define AL_FLANGER_MIN_DEPTH (0.0f) -//#define AL_FLANGER_MAX_DEPTH (1.0f) -//#define AL_FLANGER_DEFAULT_DEPTH (1.0f) -// -//#define AL_FLANGER_MIN_FEEDBACK (-1.0f) -//#define AL_FLANGER_MAX_FEEDBACK (1.0f) -//#define AL_FLANGER_DEFAULT_FEEDBACK (-0.5f) -// -//#define AL_FLANGER_MIN_DELAY (0.0f) -//#define AL_FLANGER_MAX_DELAY (0.004f) -//#define AL_FLANGER_DEFAULT_DELAY (0.002f) -// -///* Frequency shifter effect */ -//#define AL_FREQUENCY_SHIFTER_MIN_FREQUENCY (0.0f) -//#define AL_FREQUENCY_SHIFTER_MAX_FREQUENCY (24000.0f) -//#define AL_FREQUENCY_SHIFTER_DEFAULT_FREQUENCY (0.0f) -// -//#define AL_FREQUENCY_SHIFTER_MIN_LEFT_DIRECTION (0) -//#define AL_FREQUENCY_SHIFTER_MAX_LEFT_DIRECTION (2) -//#define AL_FREQUENCY_SHIFTER_DEFAULT_LEFT_DIRECTION (0) -// -//#define AL_FREQUENCY_SHIFTER_DIRECTION_DOWN (0) -//#define AL_FREQUENCY_SHIFTER_DIRECTION_UP (1) -//#define AL_FREQUENCY_SHIFTER_DIRECTION_OFF (2) -// -//#define AL_FREQUENCY_SHIFTER_MIN_RIGHT_DIRECTION (0) -//#define AL_FREQUENCY_SHIFTER_MAX_RIGHT_DIRECTION (2) -//#define AL_FREQUENCY_SHIFTER_DEFAULT_RIGHT_DIRECTION (0) -// -///* Vocal morpher effect */ -//#define AL_VOCAL_MORPHER_MIN_PHONEMEA (0) -//#define AL_VOCAL_MORPHER_MAX_PHONEMEA (29) -//#define AL_VOCAL_MORPHER_DEFAULT_PHONEMEA (0) -// -//#define AL_VOCAL_MORPHER_MIN_PHONEMEA_COARSE_TUNING (-24) -//#define AL_VOCAL_MORPHER_MAX_PHONEMEA_COARSE_TUNING (24) -//#define AL_VOCAL_MORPHER_DEFAULT_PHONEMEA_COARSE_TUNING (0) -// -//#define AL_VOCAL_MORPHER_MIN_PHONEMEB (0) -//#define AL_VOCAL_MORPHER_MAX_PHONEMEB (29) -//#define AL_VOCAL_MORPHER_DEFAULT_PHONEMEB (10) -// -//#define AL_VOCAL_MORPHER_MIN_PHONEMEB_COARSE_TUNING (-24) -//#define AL_VOCAL_MORPHER_MAX_PHONEMEB_COARSE_TUNING (24) -//#define AL_VOCAL_MORPHER_DEFAULT_PHONEMEB_COARSE_TUNING (0) -// -//#define AL_VOCAL_MORPHER_PHONEME_A (0) -//#define AL_VOCAL_MORPHER_PHONEME_E (1) -//#define AL_VOCAL_MORPHER_PHONEME_I (2) -//#define AL_VOCAL_MORPHER_PHONEME_O (3) -//#define AL_VOCAL_MORPHER_PHONEME_U (4) -//#define AL_VOCAL_MORPHER_PHONEME_AA (5) -//#define AL_VOCAL_MORPHER_PHONEME_AE (6) -//#define AL_VOCAL_MORPHER_PHONEME_AH (7) -//#define AL_VOCAL_MORPHER_PHONEME_AO (8) -//#define AL_VOCAL_MORPHER_PHONEME_EH (9) -//#define AL_VOCAL_MORPHER_PHONEME_ER (10) -//#define AL_VOCAL_MORPHER_PHONEME_IH (11) -//#define AL_VOCAL_MORPHER_PHONEME_IY (12) -//#define AL_VOCAL_MORPHER_PHONEME_UH (13) -//#define AL_VOCAL_MORPHER_PHONEME_UW (14) -//#define AL_VOCAL_MORPHER_PHONEME_B (15) -//#define AL_VOCAL_MORPHER_PHONEME_D (16) -//#define AL_VOCAL_MORPHER_PHONEME_F (17) -//#define AL_VOCAL_MORPHER_PHONEME_G (18) -//#define AL_VOCAL_MORPHER_PHONEME_J (19) -//#define AL_VOCAL_MORPHER_PHONEME_K (20) -//#define AL_VOCAL_MORPHER_PHONEME_L (21) -//#define AL_VOCAL_MORPHER_PHONEME_M (22) -//#define AL_VOCAL_MORPHER_PHONEME_N (23) -//#define AL_VOCAL_MORPHER_PHONEME_P (24) -//#define AL_VOCAL_MORPHER_PHONEME_R (25) -//#define AL_VOCAL_MORPHER_PHONEME_S (26) -//#define AL_VOCAL_MORPHER_PHONEME_T (27) -//#define AL_VOCAL_MORPHER_PHONEME_V (28) -//#define AL_VOCAL_MORPHER_PHONEME_Z (29) -// -//#define AL_VOCAL_MORPHER_WAVEFORM_SINUSOID (0) -//#define AL_VOCAL_MORPHER_WAVEFORM_TRIANGLE (1) -//#define AL_VOCAL_MORPHER_WAVEFORM_SAWTOOTH (2) -// -//#define AL_VOCAL_MORPHER_MIN_WAVEFORM (0) -//#define AL_VOCAL_MORPHER_MAX_WAVEFORM (2) -//#define AL_VOCAL_MORPHER_DEFAULT_WAVEFORM (0) -// -//#define AL_VOCAL_MORPHER_MIN_RATE (0.0f) -//#define AL_VOCAL_MORPHER_MAX_RATE (10.0f) -//#define AL_VOCAL_MORPHER_DEFAULT_RATE (1.41f) -// -///* Pitch shifter effect */ -//#define AL_PITCH_SHIFTER_MIN_COARSE_TUNE (-12) -//#define AL_PITCH_SHIFTER_MAX_COARSE_TUNE (12) -//#define AL_PITCH_SHIFTER_DEFAULT_COARSE_TUNE (12) -// -//#define AL_PITCH_SHIFTER_MIN_FINE_TUNE (-50) -//#define AL_PITCH_SHIFTER_MAX_FINE_TUNE (50) -//#define AL_PITCH_SHIFTER_DEFAULT_FINE_TUNE (0) -// -///* Ring modulator effect */ -//#define AL_RING_MODULATOR_MIN_FREQUENCY (0.0f) -//#define AL_RING_MODULATOR_MAX_FREQUENCY (8000.0f) -//#define AL_RING_MODULATOR_DEFAULT_FREQUENCY (440.0f) -// -//#define AL_RING_MODULATOR_MIN_HIGHPASS_CUTOFF (0.0f) -//#define AL_RING_MODULATOR_MAX_HIGHPASS_CUTOFF (24000.0f) -//#define AL_RING_MODULATOR_DEFAULT_HIGHPASS_CUTOFF (800.0f) -// -//#define AL_RING_MODULATOR_SINUSOID (0) -//#define AL_RING_MODULATOR_SAWTOOTH (1) -//#define AL_RING_MODULATOR_SQUARE (2) -// -//#define AL_RING_MODULATOR_MIN_WAVEFORM (0) -//#define AL_RING_MODULATOR_MAX_WAVEFORM (2) -//#define AL_RING_MODULATOR_DEFAULT_WAVEFORM (0) -// -///* Autowah effect */ -//#define AL_AUTOWAH_MIN_ATTACK_TIME (0.0001f) -//#define AL_AUTOWAH_MAX_ATTACK_TIME (1.0f) -//#define AL_AUTOWAH_DEFAULT_ATTACK_TIME (0.06f) -// -//#define AL_AUTOWAH_MIN_RELEASE_TIME (0.0001f) -//#define AL_AUTOWAH_MAX_RELEASE_TIME (1.0f) -//#define AL_AUTOWAH_DEFAULT_RELEASE_TIME (0.06f) -// -//#define AL_AUTOWAH_MIN_RESONANCE (2.0f) -//#define AL_AUTOWAH_MAX_RESONANCE (1000.0f) -//#define AL_AUTOWAH_DEFAULT_RESONANCE (1000.0f) -// -//#define AL_AUTOWAH_MIN_PEAK_GAIN (0.00003f) -//#define AL_AUTOWAH_MAX_PEAK_GAIN (31621.0f) -//#define AL_AUTOWAH_DEFAULT_PEAK_GAIN (11.22f) -// -///* Compressor effect */ -//#define AL_COMPRESSOR_MIN_ONOFF (0) -//#define AL_COMPRESSOR_MAX_ONOFF (1) -//#define AL_COMPRESSOR_DEFAULT_ONOFF (1) -// -///* Equalizer effect */ -//#define AL_EQUALIZER_MIN_LOW_GAIN (0.126f) -//#define AL_EQUALIZER_MAX_LOW_GAIN (7.943f) -//#define AL_EQUALIZER_DEFAULT_LOW_GAIN (1.0f) -// -//#define AL_EQUALIZER_MIN_LOW_CUTOFF (50.0f) -//#define AL_EQUALIZER_MAX_LOW_CUTOFF (800.0f) -//#define AL_EQUALIZER_DEFAULT_LOW_CUTOFF (200.0f) -// -//#define AL_EQUALIZER_MIN_MID1_GAIN (0.126f) -//#define AL_EQUALIZER_MAX_MID1_GAIN (7.943f) -//#define AL_EQUALIZER_DEFAULT_MID1_GAIN (1.0f) -// -//#define AL_EQUALIZER_MIN_MID1_CENTER (200.0f) -//#define AL_EQUALIZER_MAX_MID1_CENTER (3000.0f) -//#define AL_EQUALIZER_DEFAULT_MID1_CENTER (500.0f) -// -//#define AL_EQUALIZER_MIN_MID1_WIDTH (0.01f) -//#define AL_EQUALIZER_MAX_MID1_WIDTH (1.0f) -//#define AL_EQUALIZER_DEFAULT_MID1_WIDTH (1.0f) -// -//#define AL_EQUALIZER_MIN_MID2_GAIN (0.126f) -//#define AL_EQUALIZER_MAX_MID2_GAIN (7.943f) -//#define AL_EQUALIZER_DEFAULT_MID2_GAIN (1.0f) -// -//#define AL_EQUALIZER_MIN_MID2_CENTER (1000.0f) -//#define AL_EQUALIZER_MAX_MID2_CENTER (8000.0f) -//#define AL_EQUALIZER_DEFAULT_MID2_CENTER (3000.0f) -// -//#define AL_EQUALIZER_MIN_MID2_WIDTH (0.01f) -//#define AL_EQUALIZER_MAX_MID2_WIDTH (1.0f) -//#define AL_EQUALIZER_DEFAULT_MID2_WIDTH (1.0f) -// -//#define AL_EQUALIZER_MIN_HIGH_GAIN (0.126f) -//#define AL_EQUALIZER_MAX_HIGH_GAIN (7.943f) -//#define AL_EQUALIZER_DEFAULT_HIGH_GAIN (1.0f) -// -//#define AL_EQUALIZER_MIN_HIGH_CUTOFF (4000.0f) -//#define AL_EQUALIZER_MAX_HIGH_CUTOFF (16000.0f) -//#define AL_EQUALIZER_DEFAULT_HIGH_CUTOFF (6000.0f) -// -// -///* Source parameter value ranges and defaults. */ -//#define AL_MIN_AIR_ABSORPTION_FACTOR (0.0f) -//#define AL_MAX_AIR_ABSORPTION_FACTOR (10.0f) -//#define AL_DEFAULT_AIR_ABSORPTION_FACTOR (0.0f) -// -//#define AL_MIN_ROOM_ROLLOFF_FACTOR (0.0f) -//#define AL_MAX_ROOM_ROLLOFF_FACTOR (10.0f) -//#define AL_DEFAULT_ROOM_ROLLOFF_FACTOR (0.0f) -// -//#define AL_MIN_CONE_OUTER_GAINHF (0.0f) -//#define AL_MAX_CONE_OUTER_GAINHF (1.0f) -//#define AL_DEFAULT_CONE_OUTER_GAINHF (1.0f) -// -//#define AL_MIN_DIRECT_FILTER_GAINHF_AUTO AL_FALSE -//#define AL_MAX_DIRECT_FILTER_GAINHF_AUTO AL_TRUE -//#define AL_DEFAULT_DIRECT_FILTER_GAINHF_AUTO AL_TRUE -// -//#define AL_MIN_AUXILIARY_SEND_FILTER_GAIN_AUTO AL_FALSE -//#define AL_MAX_AUXILIARY_SEND_FILTER_GAIN_AUTO AL_TRUE -//#define AL_DEFAULT_AUXILIARY_SEND_FILTER_GAIN_AUTO AL_TRUE -// -//#define AL_MIN_AUXILIARY_SEND_FILTER_GAINHF_AUTO AL_FALSE -//#define AL_MAX_AUXILIARY_SEND_FILTER_GAINHF_AUTO AL_TRUE -//#define AL_DEFAULT_AUXILIARY_SEND_FILTER_GAINHF_AUTO AL_TRUE -// -// -///* Listener parameter value ranges and defaults. */ -//#define AL_MIN_METERS_PER_UNIT FLT_MIN -//#define AL_MAX_METERS_PER_UNIT FLT_MAX -//#define AL_DEFAULT_METERS_PER_UNIT (1.0f) - - - public static String GetALErrorMsg(int errorCode) { - String errorText; - switch (errorCode) { - case AL_NO_ERROR: - errorText = "No Error"; - break; - case AL_INVALID_NAME: - errorText = "Invalid Name"; - break; - case AL_INVALID_ENUM: - errorText = "Invalid Enum"; - break; - case AL_INVALID_VALUE: - errorText = "Invalid Value"; - break; - case AL_INVALID_OPERATION: - errorText = "Invalid Operation"; - break; - case AL_OUT_OF_MEMORY: - errorText = "Out of Memory"; - break; - default: - errorText = "Unknown Error Code: " + String.valueOf(errorCode); - } - return errorText; - } -} - +package com.jme3.audio.openal; + +import java.nio.IntBuffer; + +public interface EFX { + + static final String ALC_EXT_EFX_NAME = "ALC_EXT_EFX"; + + static final int ALC_EFX_MAJOR_VERSION = 0x20001; + static final int ALC_EFX_MINOR_VERSION = 0x20002; + static final int ALC_MAX_AUXILIARY_SENDS = 0x20003; + +///* Listener properties. */ +//#define AL_METERS_PER_UNIT 0x20004 +// +///* Source properties. */ + static final int AL_DIRECT_FILTER = 0x20005; + static final int AL_AUXILIARY_SEND_FILTER = 0x20006; +//#define AL_AIR_ABSORPTION_FACTOR 0x20007 +//#define AL_ROOM_ROLLOFF_FACTOR 0x20008 +//#define AL_CONE_OUTER_GAINHF 0x20009 + static final int AL_DIRECT_FILTER_GAINHF_AUTO = 0x2000A; +//#define AL_AUXILIARY_SEND_FILTER_GAIN_AUTO 0x2000B +//#define AL_AUXILIARY_SEND_FILTER_GAINHF_AUTO 0x2000C +// +// +///* Effect properties. */ +// +///* Reverb effect parameters */ + static final int AL_REVERB_DENSITY = 0x0001; + static final int AL_REVERB_DIFFUSION = 0x0002; + static final int AL_REVERB_GAIN = 0x0003; + static final int AL_REVERB_GAINHF = 0x0004; + static final int AL_REVERB_DECAY_TIME = 0x0005; + static final int AL_REVERB_DECAY_HFRATIO = 0x0006; + static final int AL_REVERB_REFLECTIONS_GAIN = 0x0007; + static final int AL_REVERB_REFLECTIONS_DELAY = 0x0008; + static final int AL_REVERB_LATE_REVERB_GAIN = 0x0009; + static final int AL_REVERB_LATE_REVERB_DELAY = 0x000A; + static final int AL_REVERB_AIR_ABSORPTION_GAINHF = 0x000B; + static final int AL_REVERB_ROOM_ROLLOFF_FACTOR = 0x000C; + static final int AL_REVERB_DECAY_HFLIMIT = 0x000D; + +///* EAX Reverb effect parameters */ +//#define AL_EAXREVERB_DENSITY 0x0001 +//#define AL_EAXREVERB_DIFFUSION 0x0002 +//#define AL_EAXREVERB_GAIN 0x0003 +//#define AL_EAXREVERB_GAINHF 0x0004 +//#define AL_EAXREVERB_GAINLF 0x0005 +//#define AL_EAXREVERB_DECAY_TIME 0x0006 +//#define AL_EAXREVERB_DECAY_HFRATIO 0x0007 +//#define AL_EAXREVERB_DECAY_LFRATIO 0x0008 +//#define AL_EAXREVERB_REFLECTIONS_GAIN 0x0009 +//#define AL_EAXREVERB_REFLECTIONS_DELAY 0x000A +//#define AL_EAXREVERB_REFLECTIONS_PAN 0x000B +//#define AL_EAXREVERB_LATE_REVERB_GAIN 0x000C +//#define AL_EAXREVERB_LATE_REVERB_DELAY 0x000D +//#define AL_EAXREVERB_LATE_REVERB_PAN 0x000E +//#define AL_EAXREVERB_ECHO_TIME 0x000F +//#define AL_EAXREVERB_ECHO_DEPTH 0x0010 +//#define AL_EAXREVERB_MODULATION_TIME 0x0011 +//#define AL_EAXREVERB_MODULATION_DEPTH 0x0012 +//#define AL_EAXREVERB_AIR_ABSORPTION_GAINHF 0x0013 +//#define AL_EAXREVERB_HFREFERENCE 0x0014 +//#define AL_EAXREVERB_LFREFERENCE 0x0015 +//#define AL_EAXREVERB_ROOM_ROLLOFF_FACTOR 0x0016 +//#define AL_EAXREVERB_DECAY_HFLIMIT 0x0017 +// +///* Chorus effect parameters */ +//#define AL_CHORUS_WAVEFORM 0x0001 +//#define AL_CHORUS_PHASE 0x0002 +//#define AL_CHORUS_RATE 0x0003 +//#define AL_CHORUS_DEPTH 0x0004 +//#define AL_CHORUS_FEEDBACK 0x0005 +//#define AL_CHORUS_DELAY 0x0006 +// +///* Distortion effect parameters */ +//#define AL_DISTORTION_EDGE 0x0001 +//#define AL_DISTORTION_GAIN 0x0002 +//#define AL_DISTORTION_LOWPASS_CUTOFF 0x0003 +//#define AL_DISTORTION_EQCENTER 0x0004 +//#define AL_DISTORTION_EQBANDWIDTH 0x0005 +// +///* Echo effect parameters */ +//#define AL_ECHO_DELAY 0x0001 +//#define AL_ECHO_LRDELAY 0x0002 +//#define AL_ECHO_DAMPING 0x0003 +//#define AL_ECHO_FEEDBACK 0x0004 +//#define AL_ECHO_SPREAD 0x0005 +// +///* Flanger effect parameters */ +//#define AL_FLANGER_WAVEFORM 0x0001 +//#define AL_FLANGER_PHASE 0x0002 +//#define AL_FLANGER_RATE 0x0003 +//#define AL_FLANGER_DEPTH 0x0004 +//#define AL_FLANGER_FEEDBACK 0x0005 +//#define AL_FLANGER_DELAY 0x0006 +// +///* Frequency shifter effect parameters */ +//#define AL_FREQUENCY_SHIFTER_FREQUENCY 0x0001 +//#define AL_FREQUENCY_SHIFTER_LEFT_DIRECTION 0x0002 +//#define AL_FREQUENCY_SHIFTER_RIGHT_DIRECTION 0x0003 +// +///* Vocal morpher effect parameters */ +//#define AL_VOCAL_MORPHER_PHONEMEA 0x0001 +//#define AL_VOCAL_MORPHER_PHONEMEA_COARSE_TUNING 0x0002 +//#define AL_VOCAL_MORPHER_PHONEMEB 0x0003 +//#define AL_VOCAL_MORPHER_PHONEMEB_COARSE_TUNING 0x0004 +//#define AL_VOCAL_MORPHER_WAVEFORM 0x0005 +//#define AL_VOCAL_MORPHER_RATE 0x0006 +// +///* Pitchshifter effect parameters */ +//#define AL_PITCH_SHIFTER_COARSE_TUNE 0x0001 +//#define AL_PITCH_SHIFTER_FINE_TUNE 0x0002 +// +///* Ringmodulator effect parameters */ +//#define AL_RING_MODULATOR_FREQUENCY 0x0001 +//#define AL_RING_MODULATOR_HIGHPASS_CUTOFF 0x0002 +//#define AL_RING_MODULATOR_WAVEFORM 0x0003 +// +///* Autowah effect parameters */ +//#define AL_AUTOWAH_ATTACK_TIME 0x0001 +//#define AL_AUTOWAH_RELEASE_TIME 0x0002 +//#define AL_AUTOWAH_RESONANCE 0x0003 +//#define AL_AUTOWAH_PEAK_GAIN 0x0004 +// +///* Compressor effect parameters */ +//#define AL_COMPRESSOR_ONOFF 0x0001 +// +///* Equalizer effect parameters */ +//#define AL_EQUALIZER_LOW_GAIN 0x0001 +//#define AL_EQUALIZER_LOW_CUTOFF 0x0002 +//#define AL_EQUALIZER_MID1_GAIN 0x0003 +//#define AL_EQUALIZER_MID1_CENTER 0x0004 +//#define AL_EQUALIZER_MID1_WIDTH 0x0005 +//#define AL_EQUALIZER_MID2_GAIN 0x0006 +//#define AL_EQUALIZER_MID2_CENTER 0x0007 +//#define AL_EQUALIZER_MID2_WIDTH 0x0008 +//#define AL_EQUALIZER_HIGH_GAIN 0x0009 +//#define AL_EQUALIZER_HIGH_CUTOFF 0x000A +// +///* Effect type */ +//#define AL_EFFECT_FIRST_PARAMETER 0x0000 +//#define AL_EFFECT_LAST_PARAMETER 0x8000 + static final int AL_EFFECT_TYPE = 0x8001; +// +///* Effect types, used with the AL_EFFECT_TYPE property */ +//#define AL_EFFECT_NULL 0x0000 + static final int AL_EFFECT_REVERB = 0x0001; +//#define AL_EFFECT_CHORUS 0x0002 +//#define AL_EFFECT_DISTORTION 0x0003 +//#define AL_EFFECT_ECHO 0x0004 +//#define AL_EFFECT_FLANGER 0x0005 +//#define AL_EFFECT_FREQUENCY_SHIFTER 0x0006 +//#define AL_EFFECT_VOCAL_MORPHER 0x0007 +//#define AL_EFFECT_PITCH_SHIFTER 0x0008 +//#define AL_EFFECT_RING_MODULATOR 0x0009 +//#define AL_EFFECT_AUTOWAH 0x000A +//#define AL_EFFECT_COMPRESSOR 0x000B +//#define AL_EFFECT_EQUALIZER 0x000C +//#define AL_EFFECT_EAXREVERB 0x8000 +// +///* Auxiliary Effect Slot properties. */ + static final int AL_EFFECTSLOT_EFFECT = 0x0001; +//#define AL_EFFECTSLOT_GAIN 0x0002 +//#define AL_EFFECTSLOT_AUXILIARY_SEND_AUTO 0x0003 +// +///* NULL Auxiliary Slot ID to disable a source send. */ +//#define AL_EFFECTSLOT_NULL 0x0000 +// +// +///* Filter properties. */ +// +///* Lowpass filter parameters */ + static final int AL_LOWPASS_GAIN = 0x0001; + static final int AL_LOWPASS_GAINHF = 0x0002; +// +///* Highpass filter parameters */ +//#define AL_HIGHPASS_GAIN 0x0001 +//#define AL_HIGHPASS_GAINLF 0x0002 +// +///* Bandpass filter parameters */ +//#define AL_BANDPASS_GAIN 0x0001 +//#define AL_BANDPASS_GAINLF 0x0002 +//#define AL_BANDPASS_GAINHF 0x0003 +// +///* Filter type */ +//#define AL_FILTER_FIRST_PARAMETER 0x0000 +//#define AL_FILTER_LAST_PARAMETER 0x8000 + static final int AL_FILTER_TYPE = 0x8001; +// +///* Filter types, used with the AL_FILTER_TYPE property */ + static final int AL_FILTER_NULL = 0x0000; + static final int AL_FILTER_LOWPASS = 0x0001; + static final int AL_FILTER_HIGHPASS = 0x0002; +//#define AL_FILTER_BANDPASS 0x0003 +// +///* Filter ranges and defaults. */ +// +///* Lowpass filter */ +//#define AL_LOWPASS_MIN_GAIN (0.0f) +//#define AL_LOWPASS_MAX_GAIN (1.0f) +//#define AL_LOWPASS_DEFAULT_GAIN (1.0f) +// +//#define AL_LOWPASS_MIN_GAINHF (0.0f) +//#define AL_LOWPASS_MAX_GAINHF (1.0f) +//#define AL_LOWPASS_DEFAULT_GAINHF (1.0f) +// +///* Highpass filter */ +//#define AL_HIGHPASS_MIN_GAIN (0.0f) +//#define AL_HIGHPASS_MAX_GAIN (1.0f) +//#define AL_HIGHPASS_DEFAULT_GAIN (1.0f) +// +//#define AL_HIGHPASS_MIN_GAINLF (0.0f) +//#define AL_HIGHPASS_MAX_GAINLF (1.0f) +//#define AL_HIGHPASS_DEFAULT_GAINLF (1.0f) +// +///* Bandpass filter */ +//#define AL_BANDPASS_MIN_GAIN (0.0f) +//#define AL_BANDPASS_MAX_GAIN (1.0f) +//#define AL_BANDPASS_DEFAULT_GAIN (1.0f) +// +//#define AL_BANDPASS_MIN_GAINHF (0.0f) +//#define AL_BANDPASS_MAX_GAINHF (1.0f) +//#define AL_BANDPASS_DEFAULT_GAINHF (1.0f) +// +//#define AL_BANDPASS_MIN_GAINLF (0.0f) +//#define AL_BANDPASS_MAX_GAINLF (1.0f) +//#define AL_BANDPASS_DEFAULT_GAINLF (1.0f) +// +// +///* Effect parameter ranges and defaults. */ +// +///* Standard reverb effect */ +//#define AL_REVERB_MIN_DENSITY (0.0f) +//#define AL_REVERB_MAX_DENSITY (1.0f) +//#define AL_REVERB_DEFAULT_DENSITY (1.0f) +// +//#define AL_REVERB_MIN_DIFFUSION (0.0f) +//#define AL_REVERB_MAX_DIFFUSION (1.0f) +//#define AL_REVERB_DEFAULT_DIFFUSION (1.0f) +// +//#define AL_REVERB_MIN_GAIN (0.0f) +//#define AL_REVERB_MAX_GAIN (1.0f) +//#define AL_REVERB_DEFAULT_GAIN (0.32f) +// +//#define AL_REVERB_MIN_GAINHF (0.0f) +//#define AL_REVERB_MAX_GAINHF (1.0f) +//#define AL_REVERB_DEFAULT_GAINHF (0.89f) +// +//#define AL_REVERB_MIN_DECAY_TIME (0.1f) +//#define AL_REVERB_MAX_DECAY_TIME (20.0f) +//#define AL_REVERB_DEFAULT_DECAY_TIME (1.49f) +// +//#define AL_REVERB_MIN_DECAY_HFRATIO (0.1f) +//#define AL_REVERB_MAX_DECAY_HFRATIO (2.0f) +//#define AL_REVERB_DEFAULT_DECAY_HFRATIO (0.83f) +// +//#define AL_REVERB_MIN_REFLECTIONS_GAIN (0.0f) +//#define AL_REVERB_MAX_REFLECTIONS_GAIN (3.16f) +//#define AL_REVERB_DEFAULT_REFLECTIONS_GAIN (0.05f) +// +//#define AL_REVERB_MIN_REFLECTIONS_DELAY (0.0f) +//#define AL_REVERB_MAX_REFLECTIONS_DELAY (0.3f) +//#define AL_REVERB_DEFAULT_REFLECTIONS_DELAY (0.007f) +// +//#define AL_REVERB_MIN_LATE_REVERB_GAIN (0.0f) +//#define AL_REVERB_MAX_LATE_REVERB_GAIN (10.0f) +//#define AL_REVERB_DEFAULT_LATE_REVERB_GAIN (1.26f) +// +//#define AL_REVERB_MIN_LATE_REVERB_DELAY (0.0f) +//#define AL_REVERB_MAX_LATE_REVERB_DELAY (0.1f) +//#define AL_REVERB_DEFAULT_LATE_REVERB_DELAY (0.011f) +// +//#define AL_REVERB_MIN_AIR_ABSORPTION_GAINHF (0.892f) +//#define AL_REVERB_MAX_AIR_ABSORPTION_GAINHF (1.0f) +//#define AL_REVERB_DEFAULT_AIR_ABSORPTION_GAINHF (0.994f) +// +//#define AL_REVERB_MIN_ROOM_ROLLOFF_FACTOR (0.0f) +//#define AL_REVERB_MAX_ROOM_ROLLOFF_FACTOR (10.0f) +//#define AL_REVERB_DEFAULT_ROOM_ROLLOFF_FACTOR (0.0f) +// +//#define AL_REVERB_MIN_DECAY_HFLIMIT AL_FALSE +//#define AL_REVERB_MAX_DECAY_HFLIMIT AL_TRUE +//#define AL_REVERB_DEFAULT_DECAY_HFLIMIT AL_TRUE +// +///* EAX reverb effect */ +//#define AL_EAXREVERB_MIN_DENSITY (0.0f) +//#define AL_EAXREVERB_MAX_DENSITY (1.0f) +//#define AL_EAXREVERB_DEFAULT_DENSITY (1.0f) +// +//#define AL_EAXREVERB_MIN_DIFFUSION (0.0f) +//#define AL_EAXREVERB_MAX_DIFFUSION (1.0f) +//#define AL_EAXREVERB_DEFAULT_DIFFUSION (1.0f) +// +//#define AL_EAXREVERB_MIN_GAIN (0.0f) +//#define AL_EAXREVERB_MAX_GAIN (1.0f) +//#define AL_EAXREVERB_DEFAULT_GAIN (0.32f) +// +//#define AL_EAXREVERB_MIN_GAINHF (0.0f) +//#define AL_EAXREVERB_MAX_GAINHF (1.0f) +//#define AL_EAXREVERB_DEFAULT_GAINHF (0.89f) +// +//#define AL_EAXREVERB_MIN_GAINLF (0.0f) +//#define AL_EAXREVERB_MAX_GAINLF (1.0f) +//#define AL_EAXREVERB_DEFAULT_GAINLF (1.0f) +// +//#define AL_EAXREVERB_MIN_DECAY_TIME (0.1f) +//#define AL_EAXREVERB_MAX_DECAY_TIME (20.0f) +//#define AL_EAXREVERB_DEFAULT_DECAY_TIME (1.49f) +// +//#define AL_EAXREVERB_MIN_DECAY_HFRATIO (0.1f) +//#define AL_EAXREVERB_MAX_DECAY_HFRATIO (2.0f) +//#define AL_EAXREVERB_DEFAULT_DECAY_HFRATIO (0.83f) +// +//#define AL_EAXREVERB_MIN_DECAY_LFRATIO (0.1f) +//#define AL_EAXREVERB_MAX_DECAY_LFRATIO (2.0f) +//#define AL_EAXREVERB_DEFAULT_DECAY_LFRATIO (1.0f) +// +//#define AL_EAXREVERB_MIN_REFLECTIONS_GAIN (0.0f) +//#define AL_EAXREVERB_MAX_REFLECTIONS_GAIN (3.16f) +//#define AL_EAXREVERB_DEFAULT_REFLECTIONS_GAIN (0.05f) +// +//#define AL_EAXREVERB_MIN_REFLECTIONS_DELAY (0.0f) +//#define AL_EAXREVERB_MAX_REFLECTIONS_DELAY (0.3f) +//#define AL_EAXREVERB_DEFAULT_REFLECTIONS_DELAY (0.007f) +// +//#define AL_EAXREVERB_DEFAULT_REFLECTIONS_PAN_XYZ (0.0f) +// +//#define AL_EAXREVERB_MIN_LATE_REVERB_GAIN (0.0f) +//#define AL_EAXREVERB_MAX_LATE_REVERB_GAIN (10.0f) +//#define AL_EAXREVERB_DEFAULT_LATE_REVERB_GAIN (1.26f) +// +//#define AL_EAXREVERB_MIN_LATE_REVERB_DELAY (0.0f) +//#define AL_EAXREVERB_MAX_LATE_REVERB_DELAY (0.1f) +//#define AL_EAXREVERB_DEFAULT_LATE_REVERB_DELAY (0.011f) +// +//#define AL_EAXREVERB_DEFAULT_LATE_REVERB_PAN_XYZ (0.0f) +// +//#define AL_EAXREVERB_MIN_ECHO_TIME (0.075f) +//#define AL_EAXREVERB_MAX_ECHO_TIME (0.25f) +//#define AL_EAXREVERB_DEFAULT_ECHO_TIME (0.25f) +// +//#define AL_EAXREVERB_MIN_ECHO_DEPTH (0.0f) +//#define AL_EAXREVERB_MAX_ECHO_DEPTH (1.0f) +//#define AL_EAXREVERB_DEFAULT_ECHO_DEPTH (0.0f) +// +//#define AL_EAXREVERB_MIN_MODULATION_TIME (0.04f) +//#define AL_EAXREVERB_MAX_MODULATION_TIME (4.0f) +//#define AL_EAXREVERB_DEFAULT_MODULATION_TIME (0.25f) +// +//#define AL_EAXREVERB_MIN_MODULATION_DEPTH (0.0f) +//#define AL_EAXREVERB_MAX_MODULATION_DEPTH (1.0f) +//#define AL_EAXREVERB_DEFAULT_MODULATION_DEPTH (0.0f) +// +//#define AL_EAXREVERB_MIN_AIR_ABSORPTION_GAINHF (0.892f) +//#define AL_EAXREVERB_MAX_AIR_ABSORPTION_GAINHF (1.0f) +//#define AL_EAXREVERB_DEFAULT_AIR_ABSORPTION_GAINHF (0.994f) +// +//#define AL_EAXREVERB_MIN_HFREFERENCE (1000.0f) +//#define AL_EAXREVERB_MAX_HFREFERENCE (20000.0f) +//#define AL_EAXREVERB_DEFAULT_HFREFERENCE (5000.0f) +// +//#define AL_EAXREVERB_MIN_LFREFERENCE (20.0f) +//#define AL_EAXREVERB_MAX_LFREFERENCE (1000.0f) +//#define AL_EAXREVERB_DEFAULT_LFREFERENCE (250.0f) +// +//#define AL_EAXREVERB_MIN_ROOM_ROLLOFF_FACTOR (0.0f) +//#define AL_EAXREVERB_MAX_ROOM_ROLLOFF_FACTOR (10.0f) +//#define AL_EAXREVERB_DEFAULT_ROOM_ROLLOFF_FACTOR (0.0f) +// +//#define AL_EAXREVERB_MIN_DECAY_HFLIMIT AL_FALSE +//#define AL_EAXREVERB_MAX_DECAY_HFLIMIT AL_TRUE +//#define AL_EAXREVERB_DEFAULT_DECAY_HFLIMIT AL_TRUE +// +///* Chorus effect */ +//#define AL_CHORUS_WAVEFORM_SINUSOID (0) +//#define AL_CHORUS_WAVEFORM_TRIANGLE (1) +// +//#define AL_CHORUS_MIN_WAVEFORM (0) +//#define AL_CHORUS_MAX_WAVEFORM (1) +//#define AL_CHORUS_DEFAULT_WAVEFORM (1) +// +//#define AL_CHORUS_MIN_PHASE (-180) +//#define AL_CHORUS_MAX_PHASE (180) +//#define AL_CHORUS_DEFAULT_PHASE (90) +// +//#define AL_CHORUS_MIN_RATE (0.0f) +//#define AL_CHORUS_MAX_RATE (10.0f) +//#define AL_CHORUS_DEFAULT_RATE (1.1f) +// +//#define AL_CHORUS_MIN_DEPTH (0.0f) +//#define AL_CHORUS_MAX_DEPTH (1.0f) +//#define AL_CHORUS_DEFAULT_DEPTH (0.1f) +// +//#define AL_CHORUS_MIN_FEEDBACK (-1.0f) +//#define AL_CHORUS_MAX_FEEDBACK (1.0f) +//#define AL_CHORUS_DEFAULT_FEEDBACK (0.25f) +// +//#define AL_CHORUS_MIN_DELAY (0.0f) +//#define AL_CHORUS_MAX_DELAY (0.016f) +//#define AL_CHORUS_DEFAULT_DELAY (0.016f) +// +///* Distortion effect */ +//#define AL_DISTORTION_MIN_EDGE (0.0f) +//#define AL_DISTORTION_MAX_EDGE (1.0f) +//#define AL_DISTORTION_DEFAULT_EDGE (0.2f) +// +//#define AL_DISTORTION_MIN_GAIN (0.01f) +//#define AL_DISTORTION_MAX_GAIN (1.0f) +//#define AL_DISTORTION_DEFAULT_GAIN (0.05f) +// +//#define AL_DISTORTION_MIN_LOWPASS_CUTOFF (80.0f) +//#define AL_DISTORTION_MAX_LOWPASS_CUTOFF (24000.0f) +//#define AL_DISTORTION_DEFAULT_LOWPASS_CUTOFF (8000.0f) +// +//#define AL_DISTORTION_MIN_EQCENTER (80.0f) +//#define AL_DISTORTION_MAX_EQCENTER (24000.0f) +//#define AL_DISTORTION_DEFAULT_EQCENTER (3600.0f) +// +//#define AL_DISTORTION_MIN_EQBANDWIDTH (80.0f) +//#define AL_DISTORTION_MAX_EQBANDWIDTH (24000.0f) +//#define AL_DISTORTION_DEFAULT_EQBANDWIDTH (3600.0f) +// +///* Echo effect */ +//#define AL_ECHO_MIN_DELAY (0.0f) +//#define AL_ECHO_MAX_DELAY (0.207f) +//#define AL_ECHO_DEFAULT_DELAY (0.1f) +// +//#define AL_ECHO_MIN_LRDELAY (0.0f) +//#define AL_ECHO_MAX_LRDELAY (0.404f) +//#define AL_ECHO_DEFAULT_LRDELAY (0.1f) +// +//#define AL_ECHO_MIN_DAMPING (0.0f) +//#define AL_ECHO_MAX_DAMPING (0.99f) +//#define AL_ECHO_DEFAULT_DAMPING (0.5f) +// +//#define AL_ECHO_MIN_FEEDBACK (0.0f) +//#define AL_ECHO_MAX_FEEDBACK (1.0f) +//#define AL_ECHO_DEFAULT_FEEDBACK (0.5f) +// +//#define AL_ECHO_MIN_SPREAD (-1.0f) +//#define AL_ECHO_MAX_SPREAD (1.0f) +//#define AL_ECHO_DEFAULT_SPREAD (-1.0f) +// +///* Flanger effect */ +//#define AL_FLANGER_WAVEFORM_SINUSOID (0) +//#define AL_FLANGER_WAVEFORM_TRIANGLE (1) +// +//#define AL_FLANGER_MIN_WAVEFORM (0) +//#define AL_FLANGER_MAX_WAVEFORM (1) +//#define AL_FLANGER_DEFAULT_WAVEFORM (1) +// +//#define AL_FLANGER_MIN_PHASE (-180) +//#define AL_FLANGER_MAX_PHASE (180) +//#define AL_FLANGER_DEFAULT_PHASE (0) +// +//#define AL_FLANGER_MIN_RATE (0.0f) +//#define AL_FLANGER_MAX_RATE (10.0f) +//#define AL_FLANGER_DEFAULT_RATE (0.27f) +// +//#define AL_FLANGER_MIN_DEPTH (0.0f) +//#define AL_FLANGER_MAX_DEPTH (1.0f) +//#define AL_FLANGER_DEFAULT_DEPTH (1.0f) +// +//#define AL_FLANGER_MIN_FEEDBACK (-1.0f) +//#define AL_FLANGER_MAX_FEEDBACK (1.0f) +//#define AL_FLANGER_DEFAULT_FEEDBACK (-0.5f) +// +//#define AL_FLANGER_MIN_DELAY (0.0f) +//#define AL_FLANGER_MAX_DELAY (0.004f) +//#define AL_FLANGER_DEFAULT_DELAY (0.002f) +// +///* Frequency shifter effect */ +//#define AL_FREQUENCY_SHIFTER_MIN_FREQUENCY (0.0f) +//#define AL_FREQUENCY_SHIFTER_MAX_FREQUENCY (24000.0f) +//#define AL_FREQUENCY_SHIFTER_DEFAULT_FREQUENCY (0.0f) +// +//#define AL_FREQUENCY_SHIFTER_MIN_LEFT_DIRECTION (0) +//#define AL_FREQUENCY_SHIFTER_MAX_LEFT_DIRECTION (2) +//#define AL_FREQUENCY_SHIFTER_DEFAULT_LEFT_DIRECTION (0) +// +//#define AL_FREQUENCY_SHIFTER_DIRECTION_DOWN (0) +//#define AL_FREQUENCY_SHIFTER_DIRECTION_UP (1) +//#define AL_FREQUENCY_SHIFTER_DIRECTION_OFF (2) +// +//#define AL_FREQUENCY_SHIFTER_MIN_RIGHT_DIRECTION (0) +//#define AL_FREQUENCY_SHIFTER_MAX_RIGHT_DIRECTION (2) +//#define AL_FREQUENCY_SHIFTER_DEFAULT_RIGHT_DIRECTION (0) +// +///* Vocal morpher effect */ +//#define AL_VOCAL_MORPHER_MIN_PHONEMEA (0) +//#define AL_VOCAL_MORPHER_MAX_PHONEMEA (29) +//#define AL_VOCAL_MORPHER_DEFAULT_PHONEMEA (0) +// +//#define AL_VOCAL_MORPHER_MIN_PHONEMEA_COARSE_TUNING (-24) +//#define AL_VOCAL_MORPHER_MAX_PHONEMEA_COARSE_TUNING (24) +//#define AL_VOCAL_MORPHER_DEFAULT_PHONEMEA_COARSE_TUNING (0) +// +//#define AL_VOCAL_MORPHER_MIN_PHONEMEB (0) +//#define AL_VOCAL_MORPHER_MAX_PHONEMEB (29) +//#define AL_VOCAL_MORPHER_DEFAULT_PHONEMEB (10) +// +//#define AL_VOCAL_MORPHER_MIN_PHONEMEB_COARSE_TUNING (-24) +//#define AL_VOCAL_MORPHER_MAX_PHONEMEB_COARSE_TUNING (24) +//#define AL_VOCAL_MORPHER_DEFAULT_PHONEMEB_COARSE_TUNING (0) +// +//#define AL_VOCAL_MORPHER_PHONEME_A (0) +//#define AL_VOCAL_MORPHER_PHONEME_E (1) +//#define AL_VOCAL_MORPHER_PHONEME_I (2) +//#define AL_VOCAL_MORPHER_PHONEME_O (3) +//#define AL_VOCAL_MORPHER_PHONEME_U (4) +//#define AL_VOCAL_MORPHER_PHONEME_AA (5) +//#define AL_VOCAL_MORPHER_PHONEME_AE (6) +//#define AL_VOCAL_MORPHER_PHONEME_AH (7) +//#define AL_VOCAL_MORPHER_PHONEME_AO (8) +//#define AL_VOCAL_MORPHER_PHONEME_EH (9) +//#define AL_VOCAL_MORPHER_PHONEME_ER (10) +//#define AL_VOCAL_MORPHER_PHONEME_IH (11) +//#define AL_VOCAL_MORPHER_PHONEME_IY (12) +//#define AL_VOCAL_MORPHER_PHONEME_UH (13) +//#define AL_VOCAL_MORPHER_PHONEME_UW (14) +//#define AL_VOCAL_MORPHER_PHONEME_B (15) +//#define AL_VOCAL_MORPHER_PHONEME_D (16) +//#define AL_VOCAL_MORPHER_PHONEME_F (17) +//#define AL_VOCAL_MORPHER_PHONEME_G (18) +//#define AL_VOCAL_MORPHER_PHONEME_J (19) +//#define AL_VOCAL_MORPHER_PHONEME_K (20) +//#define AL_VOCAL_MORPHER_PHONEME_L (21) +//#define AL_VOCAL_MORPHER_PHONEME_M (22) +//#define AL_VOCAL_MORPHER_PHONEME_N (23) +//#define AL_VOCAL_MORPHER_PHONEME_P (24) +//#define AL_VOCAL_MORPHER_PHONEME_R (25) +//#define AL_VOCAL_MORPHER_PHONEME_S (26) +//#define AL_VOCAL_MORPHER_PHONEME_T (27) +//#define AL_VOCAL_MORPHER_PHONEME_V (28) +//#define AL_VOCAL_MORPHER_PHONEME_Z (29) +// +//#define AL_VOCAL_MORPHER_WAVEFORM_SINUSOID (0) +//#define AL_VOCAL_MORPHER_WAVEFORM_TRIANGLE (1) +//#define AL_VOCAL_MORPHER_WAVEFORM_SAWTOOTH (2) +// +//#define AL_VOCAL_MORPHER_MIN_WAVEFORM (0) +//#define AL_VOCAL_MORPHER_MAX_WAVEFORM (2) +//#define AL_VOCAL_MORPHER_DEFAULT_WAVEFORM (0) +// +//#define AL_VOCAL_MORPHER_MIN_RATE (0.0f) +//#define AL_VOCAL_MORPHER_MAX_RATE (10.0f) +//#define AL_VOCAL_MORPHER_DEFAULT_RATE (1.41f) +// +///* Pitch shifter effect */ +//#define AL_PITCH_SHIFTER_MIN_COARSE_TUNE (-12) +//#define AL_PITCH_SHIFTER_MAX_COARSE_TUNE (12) +//#define AL_PITCH_SHIFTER_DEFAULT_COARSE_TUNE (12) +// +//#define AL_PITCH_SHIFTER_MIN_FINE_TUNE (-50) +//#define AL_PITCH_SHIFTER_MAX_FINE_TUNE (50) +//#define AL_PITCH_SHIFTER_DEFAULT_FINE_TUNE (0) +// +///* Ring modulator effect */ +//#define AL_RING_MODULATOR_MIN_FREQUENCY (0.0f) +//#define AL_RING_MODULATOR_MAX_FREQUENCY (8000.0f) +//#define AL_RING_MODULATOR_DEFAULT_FREQUENCY (440.0f) +// +//#define AL_RING_MODULATOR_MIN_HIGHPASS_CUTOFF (0.0f) +//#define AL_RING_MODULATOR_MAX_HIGHPASS_CUTOFF (24000.0f) +//#define AL_RING_MODULATOR_DEFAULT_HIGHPASS_CUTOFF (800.0f) +// +//#define AL_RING_MODULATOR_SINUSOID (0) +//#define AL_RING_MODULATOR_SAWTOOTH (1) +//#define AL_RING_MODULATOR_SQUARE (2) +// +//#define AL_RING_MODULATOR_MIN_WAVEFORM (0) +//#define AL_RING_MODULATOR_MAX_WAVEFORM (2) +//#define AL_RING_MODULATOR_DEFAULT_WAVEFORM (0) +// +///* Autowah effect */ +//#define AL_AUTOWAH_MIN_ATTACK_TIME (0.0001f) +//#define AL_AUTOWAH_MAX_ATTACK_TIME (1.0f) +//#define AL_AUTOWAH_DEFAULT_ATTACK_TIME (0.06f) +// +//#define AL_AUTOWAH_MIN_RELEASE_TIME (0.0001f) +//#define AL_AUTOWAH_MAX_RELEASE_TIME (1.0f) +//#define AL_AUTOWAH_DEFAULT_RELEASE_TIME (0.06f) +// +//#define AL_AUTOWAH_MIN_RESONANCE (2.0f) +//#define AL_AUTOWAH_MAX_RESONANCE (1000.0f) +//#define AL_AUTOWAH_DEFAULT_RESONANCE (1000.0f) +// +//#define AL_AUTOWAH_MIN_PEAK_GAIN (0.00003f) +//#define AL_AUTOWAH_MAX_PEAK_GAIN (31621.0f) +//#define AL_AUTOWAH_DEFAULT_PEAK_GAIN (11.22f) +// +///* Compressor effect */ +//#define AL_COMPRESSOR_MIN_ONOFF (0) +//#define AL_COMPRESSOR_MAX_ONOFF (1) +//#define AL_COMPRESSOR_DEFAULT_ONOFF (1) +// +///* Equalizer effect */ +//#define AL_EQUALIZER_MIN_LOW_GAIN (0.126f) +//#define AL_EQUALIZER_MAX_LOW_GAIN (7.943f) +//#define AL_EQUALIZER_DEFAULT_LOW_GAIN (1.0f) +// +//#define AL_EQUALIZER_MIN_LOW_CUTOFF (50.0f) +//#define AL_EQUALIZER_MAX_LOW_CUTOFF (800.0f) +//#define AL_EQUALIZER_DEFAULT_LOW_CUTOFF (200.0f) +// +//#define AL_EQUALIZER_MIN_MID1_GAIN (0.126f) +//#define AL_EQUALIZER_MAX_MID1_GAIN (7.943f) +//#define AL_EQUALIZER_DEFAULT_MID1_GAIN (1.0f) +// +//#define AL_EQUALIZER_MIN_MID1_CENTER (200.0f) +//#define AL_EQUALIZER_MAX_MID1_CENTER (3000.0f) +//#define AL_EQUALIZER_DEFAULT_MID1_CENTER (500.0f) +// +//#define AL_EQUALIZER_MIN_MID1_WIDTH (0.01f) +//#define AL_EQUALIZER_MAX_MID1_WIDTH (1.0f) +//#define AL_EQUALIZER_DEFAULT_MID1_WIDTH (1.0f) +// +//#define AL_EQUALIZER_MIN_MID2_GAIN (0.126f) +//#define AL_EQUALIZER_MAX_MID2_GAIN (7.943f) +//#define AL_EQUALIZER_DEFAULT_MID2_GAIN (1.0f) +// +//#define AL_EQUALIZER_MIN_MID2_CENTER (1000.0f) +//#define AL_EQUALIZER_MAX_MID2_CENTER (8000.0f) +//#define AL_EQUALIZER_DEFAULT_MID2_CENTER (3000.0f) +// +//#define AL_EQUALIZER_MIN_MID2_WIDTH (0.01f) +//#define AL_EQUALIZER_MAX_MID2_WIDTH (1.0f) +//#define AL_EQUALIZER_DEFAULT_MID2_WIDTH (1.0f) +// +//#define AL_EQUALIZER_MIN_HIGH_GAIN (0.126f) +//#define AL_EQUALIZER_MAX_HIGH_GAIN (7.943f) +//#define AL_EQUALIZER_DEFAULT_HIGH_GAIN (1.0f) +// +//#define AL_EQUALIZER_MIN_HIGH_CUTOFF (4000.0f) +//#define AL_EQUALIZER_MAX_HIGH_CUTOFF (16000.0f) +//#define AL_EQUALIZER_DEFAULT_HIGH_CUTOFF (6000.0f) +// +// +///* Source parameter value ranges and defaults. */ +//#define AL_MIN_AIR_ABSORPTION_FACTOR (0.0f) +//#define AL_MAX_AIR_ABSORPTION_FACTOR (10.0f) +//#define AL_DEFAULT_AIR_ABSORPTION_FACTOR (0.0f) +// +//#define AL_MIN_ROOM_ROLLOFF_FACTOR (0.0f) +//#define AL_MAX_ROOM_ROLLOFF_FACTOR (10.0f) +//#define AL_DEFAULT_ROOM_ROLLOFF_FACTOR (0.0f) +// +//#define AL_MIN_CONE_OUTER_GAINHF (0.0f) +//#define AL_MAX_CONE_OUTER_GAINHF (1.0f) +//#define AL_DEFAULT_CONE_OUTER_GAINHF (1.0f) +// +//#define AL_MIN_DIRECT_FILTER_GAINHF_AUTO AL_FALSE +//#define AL_MAX_DIRECT_FILTER_GAINHF_AUTO AL_TRUE +//#define AL_DEFAULT_DIRECT_FILTER_GAINHF_AUTO AL_TRUE +// +//#define AL_MIN_AUXILIARY_SEND_FILTER_GAIN_AUTO AL_FALSE +//#define AL_MAX_AUXILIARY_SEND_FILTER_GAIN_AUTO AL_TRUE +//#define AL_DEFAULT_AUXILIARY_SEND_FILTER_GAIN_AUTO AL_TRUE +// +//#define AL_MIN_AUXILIARY_SEND_FILTER_GAINHF_AUTO AL_FALSE +//#define AL_MAX_AUXILIARY_SEND_FILTER_GAINHF_AUTO AL_TRUE +//#define AL_DEFAULT_AUXILIARY_SEND_FILTER_GAINHF_AUTO AL_TRUE +// + + public void alGenAuxiliaryEffectSlots(int numSlots, IntBuffer buffers); + public void alGenEffects(int numEffects, IntBuffer buffers); + public void alEffecti(int effect, int param, int value); + public void alAuxiliaryEffectSloti(int effectSlot, int param, int value); + public void alDeleteEffects(int numEffects, IntBuffer buffers); + public void alDeleteAuxiliaryEffectSlots(int numEffectSlots, IntBuffer buffers); + public void alGenFilters(int numFilters, IntBuffer buffers); + public void alFilteri(int filter, int param, int value); + public void alFilterf(int filter, int param, float value); + public void alDeleteFilters(int numFilters, IntBuffer buffers); + public void alEffectf(int effect, int param, float value); + +} diff --git a/jme3-desktop/src/main/java/com/jme3/system/JmeDesktopSystem.java b/jme3-desktop/src/main/java/com/jme3/system/JmeDesktopSystem.java index f5de0c2ea..ffd56e841 100644 --- a/jme3-desktop/src/main/java/com/jme3/system/JmeDesktopSystem.java +++ b/jme3-desktop/src/main/java/com/jme3/system/JmeDesktopSystem.java @@ -37,6 +37,10 @@ import com.jme3.asset.AssetManager; import com.jme3.asset.AssetNotFoundException; import com.jme3.asset.DesktopAssetManager; import com.jme3.audio.AudioRenderer; +import com.jme3.audio.openal.AL; +import com.jme3.audio.openal.ALAudioRenderer; +import com.jme3.audio.openal.ALC; +import com.jme3.audio.openal.EFX; import com.jme3.system.JmeContext.Type; import com.jme3.texture.Image; import com.jme3.texture.image.DefaultImageRaster; @@ -253,13 +257,36 @@ public class JmeDesktopSystem extends JmeSystemDelegate { return ctx; } + private T newObject(String className) { + try { + Class clazz = (Class) Class.forName(className); + return clazz.newInstance(); + } catch (ClassNotFoundException ex) { + logger.log(Level.SEVERE, "CRITICAL ERROR: Audio implementation class is missing!\n" + + "Make sure jme3_lwjgl-oal or jm3_joal is on the classpath.", ex); + } catch (IllegalAccessException ex) { + logger.log(Level.SEVERE, "Failed to create context", ex); + } catch (InstantiationException ex) { + logger.log(Level.SEVERE, "Failed to create context", ex); + } + + return null; + } + + private AudioRenderer newAudioRendererLwjgl() { + AL al = newObject("com.jme3.audio.lwjgl.LwjglAL"); + ALC alc = newObject("com.jme3.audio.lwjgl.LwjglALC"); + EFX efx = newObject("com.jme3.audio.lwjgl.LwjglEFX"); + return new ALAudioRenderer(al, alc, efx); + } + @Override public AudioRenderer newAudioRenderer(AppSettings settings) { initialize(settings); Class clazz = null; try { if (settings.getAudioRenderer().startsWith("LWJGL")) { - clazz = (Class) Class.forName("com.jme3.audio.lwjgl.LwjglAudioRenderer"); + return newAudioRendererLwjgl(); } else if (settings.getAudioRenderer().startsWith("JOAL")) { clazz = (Class) Class.forName("com.jme3.audio.joal.JoalAudioRenderer"); } else { diff --git a/jme3-jogl/src/main/java/com/jme3/audio/joal/JoalAudioRenderer.java b/jme3-jogl/src/main/java/com/jme3/audio/joal/JoalAudioRenderer.java index 9f99ba458..4af6fd68c 100644 --- a/jme3-jogl/src/main/java/com/jme3/audio/joal/JoalAudioRenderer.java +++ b/jme3-jogl/src/main/java/com/jme3/audio/joal/JoalAudioRenderer.java @@ -37,8 +37,18 @@ import com.jme3.math.Vector3f; import com.jme3.util.BufferUtils; import com.jme3.util.NativeObjectManager; import com.jogamp.common.nio.Buffers; -import com.jogamp.openal.*; +import com.jogamp.openal.AL; +import com.jogamp.openal.ALC; +import com.jogamp.openal.ALCcontext; +import com.jogamp.openal.ALCdevice; +import com.jogamp.openal.ALConstants; +import com.jogamp.openal.ALException; +import com.jogamp.openal.ALExt; +import com.jogamp.openal.ALExtConstants; +import com.jogamp.openal.ALFactory; import com.jogamp.openal.util.ALut; +//import com.jogamp.openal.*; +//import com.jogamp.openal.util.ALut; import java.nio.ByteBuffer; import java.nio.FloatBuffer; import java.nio.IntBuffer; @@ -860,6 +870,14 @@ public class JoalAudioRenderer implements AudioRenderer, Runnable { setListenerParams(listener); } } + + public void pauseAll() { + throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates. + } + + public void resumeAll() { + throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates. + } public void playSourceInstance(AudioSource src) { checkDead(); diff --git a/jme3-lwjgl/src/main/java/com/jme3/audio/lwjgl/LwjglAL.java b/jme3-lwjgl/src/main/java/com/jme3/audio/lwjgl/LwjglAL.java new file mode 100644 index 000000000..9cb52c688 --- /dev/null +++ b/jme3-lwjgl/src/main/java/com/jme3/audio/lwjgl/LwjglAL.java @@ -0,0 +1,107 @@ +package com.jme3.audio.lwjgl; + +import com.jme3.audio.openal.AL; +import java.nio.ByteBuffer; +import java.nio.FloatBuffer; +import java.nio.IntBuffer; +import org.lwjgl.openal.AL10; +import org.lwjgl.openal.AL11; + +public final class LwjglAL implements AL { + + public LwjglAL() { + } + + public String alGetString(int parameter) { + return AL10.alGetString(parameter); + } + + public int alGenSources() { + return AL10.alGenSources(); + } + + public int alGetError() { + return AL10.alGetError(); + } + + public void alDeleteSources(int numSources, IntBuffer sources) { + if (sources.position() != 0) throw new AssertionError(); + if (sources.limit() != numSources) throw new AssertionError(); + AL10.alDeleteSources(sources); + } + + public void alGenBuffers(int numBuffers, IntBuffer buffers) { + if (buffers.position() != 0) throw new AssertionError(); + if (buffers.limit() != numBuffers) throw new AssertionError(); + AL10.alGenBuffers(buffers); + } + + public void alDeleteBuffers(int numBuffers, IntBuffer buffers) { + if (buffers.position() != 0) throw new AssertionError(); + if (buffers.limit() != numBuffers) throw new AssertionError(); + AL10.alDeleteBuffers(buffers); + } + + public void alSourceStop(int source) { + AL10.alSourceStop(source); + } + + public void alSourcei(int source, int param, int value) { + AL10.alSourcei(source, param, value); + } + + public void alBufferData(int buffer, int format, ByteBuffer data, int size, int frequency) { + if (data.position() != 0) throw new AssertionError(); + if (data.limit() != size) throw new AssertionError(); + AL10.alBufferData(buffer, format, data, frequency); + } + + public void alSourcePlay(int source) { + AL10.alSourcePlay(source); + } + + public void alSourcePause(int source) { + AL10.alSourcePause(source); + } + + public void alSourcef(int source, int param, float value) { + AL10.alSourcef(source, param, value); + } + + public void alSource3f(int source, int param, float value1, float value2, float value3) { + AL10.alSource3f(source, param, value1, value2, value3); + } + + public int alGetSourcei(int source, int param) { + return AL10.alGetSourcei(source, param); + } + + public void alSourceUnqueueBuffers(int source, int numBuffers, IntBuffer buffers) { + if (buffers.position() != 0) throw new AssertionError(); + if (buffers.limit() != numBuffers) throw new AssertionError(); + AL10.alSourceUnqueueBuffers(source, buffers); + } + + public void alSourceQueueBuffers(int source, int numBuffers, IntBuffer buffers) { + if (buffers.position() != 0) throw new AssertionError(); + if (buffers.limit() != numBuffers) throw new AssertionError(); + AL10.alSourceQueueBuffers(source, buffers); + } + + public void alListener(int param, FloatBuffer data) { + AL10.alListener(param, data); + } + + public void alListenerf(int param, float value) { + AL10.alListenerf(param, value); + } + + public void alListener3f(int param, float value1, float value2, float value3) { + AL10.alListener3f(param, value1, value2, value3); + } + + public void alSource3i(int source, int param, int value1, int value2, int value3) { + AL11.alSource3i(source, param, value1, value2, value3); + } + +} diff --git a/jme3-lwjgl/src/main/java/com/jme3/audio/lwjgl/LwjglALC.java b/jme3-lwjgl/src/main/java/com/jme3/audio/lwjgl/LwjglALC.java new file mode 100644 index 000000000..3aaf62847 --- /dev/null +++ b/jme3-lwjgl/src/main/java/com/jme3/audio/lwjgl/LwjglALC.java @@ -0,0 +1,50 @@ +package com.jme3.audio.lwjgl; + +import com.jme3.audio.openal.ALC; +import java.nio.IntBuffer; +import org.lwjgl.LWJGLException; +import org.lwjgl.openal.AL; +import org.lwjgl.openal.ALC10; +import org.lwjgl.openal.ALCcontext; +import org.lwjgl.openal.ALCdevice; + +public class LwjglALC implements ALC { + + public void createALC() { + try { + AL.create(); + } catch (LWJGLException ex) { + throw new RuntimeException(ex); + } + } + + public void destroyALC() { + AL.destroy(); + } + + public boolean isCreated() { + return AL.isCreated(); + } + + public String alcGetString(int parameter) { + ALCcontext context = ALC10.alcGetCurrentContext(); + ALCdevice device = ALC10.alcGetContextsDevice(context); + return ALC10.alcGetString(device, parameter); + } + + public boolean alcIsExtensionPresent(String extension) { + ALCcontext context = ALC10.alcGetCurrentContext(); + ALCdevice device = ALC10.alcGetContextsDevice(context); + return ALC10.alcIsExtensionPresent(device, extension); + } + + public void alcGetInteger(int param, IntBuffer buffer, int size) { + if (buffer.position() != 0) throw new AssertionError(); + if (buffer.limit() != size) throw new AssertionError(); + + ALCcontext context = ALC10.alcGetCurrentContext(); + ALCdevice device = ALC10.alcGetContextsDevice(context); + ALC10.alcGetInteger(device, param, buffer); + } + +} diff --git a/jme3-lwjgl/src/main/java/com/jme3/audio/lwjgl/LwjglEFX.java b/jme3-lwjgl/src/main/java/com/jme3/audio/lwjgl/LwjglEFX.java new file mode 100644 index 000000000..639758c4e --- /dev/null +++ b/jme3-lwjgl/src/main/java/com/jme3/audio/lwjgl/LwjglEFX.java @@ -0,0 +1,65 @@ +package com.jme3.audio.lwjgl; + +import com.jme3.audio.openal.EFX; +import java.nio.IntBuffer; +import org.lwjgl.openal.EFX10; + +public class LwjglEFX implements EFX { + + public void alGenAuxiliaryEffectSlots(int numSlots, IntBuffer buffers) { + if (buffers.position() != 0) throw new AssertionError(); + if (buffers.limit() != numSlots) throw new AssertionError(); + EFX10.alGenAuxiliaryEffectSlots(buffers); + } + + public void alGenEffects(int numEffects, IntBuffer buffers) { + if (buffers.position() != 0) throw new AssertionError(); + if (buffers.limit() != numEffects) throw new AssertionError(); + EFX10.alGenEffects(buffers); + } + + public void alEffecti(int effect, int param, int value) { + EFX10.alEffecti(effect, param, value); + } + + public void alAuxiliaryEffectSloti(int effectSlot, int param, int value) { + EFX10.alAuxiliaryEffectSloti(effectSlot, param, value); + } + + public void alDeleteEffects(int numEffects, IntBuffer buffers) { + if (buffers.position() != 0) throw new AssertionError(); + if (buffers.limit() != numEffects) throw new AssertionError(); + EFX10.alDeleteEffects(buffers); + } + + public void alDeleteAuxiliaryEffectSlots(int numEffectSlots, IntBuffer buffers) { + if (buffers.position() != 0) throw new AssertionError(); + if (buffers.limit() != numEffectSlots) throw new AssertionError(); + EFX10.alDeleteAuxiliaryEffectSlots(buffers); + } + + public void alGenFilters(int numFilters, IntBuffer buffers) { + if (buffers.position() != 0) throw new AssertionError(); + if (buffers.limit() != numFilters) throw new AssertionError(); + EFX10.alGenFilters(buffers); + } + + public void alFilteri(int filter, int param, int value) { + EFX10.alFilteri(filter, param, value); + } + + public void alFilterf(int filter, int param, float value) { + EFX10.alFilterf(filter, param, value); + } + + public void alDeleteFilters(int numFilters, IntBuffer buffers) { + if (buffers.position() != 0) throw new AssertionError(); + if (buffers.limit() != numFilters) throw new AssertionError(); + EFX10.alDeleteFilters(buffers); + } + + public void alEffectf(int effect, int param, float value) { + EFX10.alEffectf(effect, param, value); + } + +}