diff --git a/bin/classes.jar b/bin/classes.jar index 0eb366f..6cef11b 100644 Binary files a/bin/classes.jar and b/bin/classes.jar differ diff --git a/jni/Android.mk b/jni/Android.mk index 3d895db..1f039b1 100644 --- a/jni/Android.mk +++ b/jni/Android.mk @@ -17,7 +17,7 @@ LOCAL_PATH := $(call my-dir) include $(CLEAR_VARS) LOCAL_MODULE := midi -LOCAL_SRC_FILES := midi.c +LOCAL_SRC_FILES := midi.cpp # for EAS midi LOCAL_LDLIBS += -lsonivox diff --git a/jni/midi.c b/jni/midi.cpp similarity index 85% rename from jni/midi.c rename to jni/midi.cpp index 9043b3d..28f5776 100644 --- a/jni/midi.c +++ b/jni/midi.cpp @@ -23,6 +23,8 @@ #include +#include "org_billthefarmer_mididriver_MidiDriver.h" + // for EAS midi #include "eas.h" #include "eas_reverb.h" @@ -40,7 +42,7 @@ static EAS_HANDLE midiHandle; // init EAS midi jint Java_org_billthefarmer_mididriver_MidiDriver_init(JNIEnv *env, - jobject clazz) + jobject obj) { EAS_RESULT result; @@ -77,23 +79,23 @@ Java_org_billthefarmer_mididriver_MidiDriver_init(JNIEnv *env, // midi config jintArray Java_org_billthefarmer_mididriver_MidiDriver_config(JNIEnv *env, - jobject clazz) + jobject obj) { jboolean isCopy; if (pLibConfig == NULL) return NULL; - jintArray configArray = (*env)->NewIntArray(env, 4); + jintArray configArray = env->NewIntArray(4); - jint *config = (*env)->GetIntArrayElements(env, configArray, &isCopy); + jint *config = env->GetIntArrayElements(configArray, &isCopy); config[0] = pLibConfig->maxVoices; config[1] = pLibConfig->numChannels; config[2] = pLibConfig->sampleRate; config[3] = pLibConfig->mixBufferSize; - (*env)->ReleaseIntArrayElements(env, configArray, config, 0); + env->ReleaseIntArrayElements(configArray, config, 0); return configArray; } @@ -101,7 +103,7 @@ Java_org_billthefarmer_mididriver_MidiDriver_config(JNIEnv *env, // midi render jint Java_org_billthefarmer_mididriver_MidiDriver_render(JNIEnv *env, - jobject clazz, + jobject obj, jshortArray shortArray) { jboolean isCopy; @@ -120,9 +122,9 @@ Java_org_billthefarmer_mididriver_MidiDriver_render(JNIEnv *env, return 0; buffer = - (EAS_PCM *)(*env)->GetShortArrayElements(env, shortArray, &isCopy); + (EAS_PCM *)env->GetShortArrayElements(shortArray, &isCopy); - size = (*env)->GetArrayLength(env, shortArray); + size = env->GetArrayLength(shortArray); count = 0; while (count < size) @@ -135,7 +137,7 @@ Java_org_billthefarmer_mididriver_MidiDriver_render(JNIEnv *env, count += numGenerated * pLibConfig->numChannels; } - (*env)->ReleaseShortArrayElements(env, shortArray, buffer, 0); + env->ReleaseShortArrayElements(shortArray, buffer, 0); return count; } @@ -143,7 +145,7 @@ Java_org_billthefarmer_mididriver_MidiDriver_render(JNIEnv *env, // midi write jboolean Java_org_billthefarmer_mididriver_MidiDriver_write(JNIEnv *env, - jobject clazz, + jobject obj, jbyteArray byteArray) { jboolean isCopy; @@ -154,12 +156,12 @@ Java_org_billthefarmer_mididriver_MidiDriver_write(JNIEnv *env, if (pEASData == NULL || midiHandle == NULL) return JNI_FALSE; - buf = (EAS_U8 *)(*env)->GetByteArrayElements(env, byteArray, &isCopy); - length = (*env)->GetArrayLength(env, byteArray); + buf = (EAS_U8 *)env->GetByteArrayElements(byteArray, &isCopy); + length = env->GetArrayLength(byteArray); result = EAS_WriteMIDIStream(pEASData, midiHandle, buf, length); - (*env)->ReleaseByteArrayElements(env, byteArray, buf, 0); + env->ReleaseByteArrayElements(byteArray, (jbyte *)buf, 0); if (result != EAS_SUCCESS) return JNI_FALSE; @@ -170,7 +172,7 @@ Java_org_billthefarmer_mididriver_MidiDriver_write(JNIEnv *env, // shutdown EAS midi jboolean Java_org_billthefarmer_mididriver_MidiDriver_shutdown(JNIEnv *env, - jobject clazz) + jobject obj) { EAS_RESULT result; diff --git a/jni/org_billthefarmer_mididriver_MidiDriver.h b/jni/org_billthefarmer_mididriver_MidiDriver.h new file mode 100644 index 0000000..d4a80b2 --- /dev/null +++ b/jni/org_billthefarmer_mididriver_MidiDriver.h @@ -0,0 +1,57 @@ +/* DO NOT EDIT THIS FILE - it is machine generated */ +#include +/* Header for class org_billthefarmer_mididriver_MidiDriver */ + +#ifndef _Included_org_billthefarmer_mididriver_MidiDriver +#define _Included_org_billthefarmer_mididriver_MidiDriver +#ifdef __cplusplus +extern "C" { +#endif +#undef org_billthefarmer_mididriver_MidiDriver_SAMPLE_RATE +#define org_billthefarmer_mididriver_MidiDriver_SAMPLE_RATE 22050L +#undef org_billthefarmer_mididriver_MidiDriver_BUFFER_SIZE +#define org_billthefarmer_mididriver_MidiDriver_BUFFER_SIZE 4096L +/* + * Class: org_billthefarmer_mididriver_MidiDriver + * Method: init + * Signature: ()I + */ +JNIEXPORT jint JNICALL Java_org_billthefarmer_mididriver_MidiDriver_init + (JNIEnv *, jobject); + +/* + * Class: org_billthefarmer_mididriver_MidiDriver + * Method: config + * Signature: ()[I + */ +JNIEXPORT jintArray JNICALL Java_org_billthefarmer_mididriver_MidiDriver_config + (JNIEnv *, jobject); + +/* + * Class: org_billthefarmer_mididriver_MidiDriver + * Method: render + * Signature: ([S)I + */ +JNIEXPORT jint JNICALL Java_org_billthefarmer_mididriver_MidiDriver_render + (JNIEnv *, jobject, jshortArray); + +/* + * Class: org_billthefarmer_mididriver_MidiDriver + * Method: write + * Signature: ([B)Z + */ +JNIEXPORT jboolean JNICALL Java_org_billthefarmer_mididriver_MidiDriver_write + (JNIEnv *, jobject, jbyteArray); + +/* + * Class: org_billthefarmer_mididriver_MidiDriver + * Method: shutdown + * Signature: ()Z + */ +JNIEXPORT jboolean JNICALL Java_org_billthefarmer_mididriver_MidiDriver_shutdown + (JNIEnv *, jobject); + +#ifdef __cplusplus +} +#endif +#endif diff --git a/libs/mips/libmidi.so b/libs/mips/libmidi.so index 90d0258..5e41016 100644 Binary files a/libs/mips/libmidi.so and b/libs/mips/libmidi.so differ diff --git a/libs/x86/libmidi.so b/libs/x86/libmidi.so index 144895b..f71bda3 100644 Binary files a/libs/x86/libmidi.so and b/libs/x86/libmidi.so differ