Rest of changes for native sound engine integration.

bklimt
Raph Levien 13 years ago
parent c3509e50c1
commit 94a01600b0
  1. 5
      android/.classpath
  2. 10
      android/.project
  3. 8
      android/AndroidManifest.xml
  4. 2
      android/default.properties
  5. 10
      android/jni/Android.mk
  6. 2
      android/jni/Application.mk
  7. 32
      android/src/com/google/synthesizer/android/widgets/piano/PianoView.java
  8. 7
      cpp/src/android_glue.cc

@ -6,6 +6,7 @@
<classpathentry excluding="**/.svn/*" kind="src" path="test"/>
<classpathentry kind="src" path="gen"/>
<classpathentry kind="con" path="com.android.ide.eclipse.adt.ANDROID_FRAMEWORK"/>
<classpathentry kind="lib" path="core-lib/libprotobuf.jar"/>
<classpathentry kind="output" path="bin"/>
<classpathentry exported="true" kind="lib" path="core-lib/libprotobuf.jar"/>
<classpathentry exported="true" kind="con" path="com.android.ide.eclipse.adt.LIBRARIES"/>
<classpathentry kind="output" path="bin/classes"/>
</classpath>

@ -15,6 +15,16 @@
</dictionary>
</arguments>
</buildCommand>
<buildCommand>
<name>org.eclipse.ui.externaltools.ExternalToolBuilder</name>
<triggers>auto,full,incremental,</triggers>
<arguments>
<dictionary>
<key>LaunchConfigHandle</key>
<value>&lt;project&gt;/.externalToolBuilders/NDK Builder.launch</value>
</dictionary>
</arguments>
</buildCommand>
<buildCommand>
<name>com.android.ide.eclipse.adt.ResourceManagerBuilder</name>
<arguments>

@ -4,11 +4,11 @@
package="com.google.synthesizer"
android:versionCode="2"
android:versionName="0.9">
<uses-sdk android:minSdkVersion="8" /> <!-- 8 = Froyo 2.2 -->
<uses-sdk android:minSdkVersion="9" /> <!-- 8 = Froyo 2.2 -->
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<application android:icon="@drawable/icon" android:label="@string/app_name">
<activity
android:name=".android.ui.PianoActivity"
android:name=".android.ui.PianoActivity2"
android:label="@string/app_name"
android:screenOrientation="landscape">
<intent-filter>
@ -64,10 +64,12 @@
android:name=".android.ui.KarplusStrongActivity"
android:label="@string/karplus_strong"
android:screenOrientation="landscape" />
<!-- Don't need the service if we're running native sound engine
<service android:name=".android.service.SynthesizerService">
<intent-filter>
<action android:name=".android.service.ISynthesizerService" />
</intent-filter>
</service>
-->
</application>
</manifest>
</manifest>

@ -8,4 +8,4 @@
# project structure.
# Project target.
target=android-8
target=android-9

@ -3,7 +3,8 @@ LOCAL_PATH := $(call my-dir)/../../cpp/src
include $(CLEAR_VARS)
LOCAL_MODULE := synth
LOCAL_CPP_EXTENSION := .cc
LOCAL_SRC_FILES := dx7note.cc \
LOCAL_SRC_FILES := android_glue.cc \
dx7note.cc \
env.cc \
fm_core.cc \
fm_op_kernel.cc \
@ -14,5 +15,12 @@ LOCAL_SRC_FILES := dx7note.cc \
sin.cc \
synth_unit.cc
# for native audio
LOCAL_LDLIBS += -lOpenSLES
# for logging
LOCAL_LDLIBS += -llog
LOCAL_CFLAGS := -O3
include $(BUILD_SHARED_LIBRARY)

@ -1 +1,3 @@
APP_STL := stlport_static
APP_ABI := armeabi-v7a

@ -16,6 +16,9 @@
package com.google.synthesizer.android.widgets.piano;
import java.util.HashMap;
import java.util.Map;
import android.content.Context;
import android.content.res.TypedArray;
import android.graphics.Canvas;
@ -23,8 +26,11 @@ import android.graphics.Rect;
import android.util.AttributeSet;
import android.view.MotionEvent;
import android.view.View;
import com.google.synthesizer.R;
import com.google.synthesizer.android.AndroidGlue;
import com.google.synthesizer.core.model.composite.MultiChannelSynthesizer;
import com.google.synthesizer.core.music.Note;
/**
* PianoView is a UI widget that simulates a music keyboard.
@ -350,6 +356,32 @@ public class PianoView extends View {
});
}
/**
* Connects the PianoView to an AndroidGlue. This should probably be a MidiListener instead,
* though...
*/
public void bindTo(final AndroidGlue midiSink) {
this.setPianoViewListener(new PianoViewListener() {
{
fingerMap_ = new HashMap<Integer, Integer>();
}
public void noteDown(double logFrequency, int finger, boolean retriggerIfOn) {
noteUp(finger);
int midiNote = Note.getKeyforLog12TET(logFrequency);
fingerMap_.put(finger, midiNote);
midiSink.sendMidi(new byte[] {(byte) 0x90, (byte) midiNote, 64});
}
public void noteUp(int finger) {
if (fingerMap_.containsKey(finger)) {
int midiNote = fingerMap_.get(finger);
fingerMap_.remove(finger);
midiSink.sendMidi(new byte[] {(byte) 0x80, (byte) midiNote, 64});
}
}
private Map<Integer, Integer> fingerMap_;
});
}
// The most recent screen rect that this keyboard was drawn into.
//
// This is basically a stack variable for onDraw. It's a member variable only so that we can

@ -47,13 +47,6 @@ extern "C" void BqPlayerCallback(SLAndroidSimpleBufferQueueItf queueItf,
cur_buffer = (cur_buffer + 1) % N_BUFFERS;
}
extern "C" JNIEXPORT jint JNICALL
Java_com_google_synthesizer_android_AndroidGlue_hello(JNIEnv *env,
jobject thiz) {
LOGI("here %d!", 42);
return 42;
}
void CreateEngine() {
SLresult result;
result = slCreateEngine(&engineObject, 0, NULL, 0, NULL, NULL);

Loading…
Cancel
Save