aboutsummaryrefslogtreecommitdiff
path: root/media
diff options
context:
space:
mode:
authorYuichi Araki <yaraki@google.com>2015-08-17 15:22:28 +0900
committerYuichi Araki <yaraki@google.com>2015-08-17 15:22:28 +0900
commit6ab42c36e877ca920212b0a1586268a2e855c2e3 (patch)
tree378b3b83e6502169d99e8e0aa67e22fbb3300bf1 /media
parent80b550a664dce8f9577d064efa44d814b81fe0d8 (diff)
downloadandroid-6ab42c36e877ca920212b0a1586268a2e855c2e3.tar.gz
MidiScope: Add a sample
This brings back MidiScope that was deleted in order to resolve a merge conflict. Change-Id: I027d53ad57eea89827d486918c0000af5521d463
Diffstat (limited to 'media')
-rw-r--r--media/MidiScope/Application/.gitignore16
-rw-r--r--media/MidiScope/Application/proguard-project.txt20
-rw-r--r--media/MidiScope/Application/src/androidTest/java/com/example/android/midiscope/test/SampleTests.java54
-rw-r--r--media/MidiScope/Application/src/main/AndroidManifest.xml55
-rw-r--r--media/MidiScope/Application/src/main/java/com/example/android/midiscope/LoggingReceiver.java62
-rw-r--r--media/MidiScope/Application/src/main/java/com/example/android/midiscope/MainActivity.java162
-rw-r--r--media/MidiScope/Application/src/main/java/com/example/android/midiscope/MidiPrinter.java108
-rw-r--r--media/MidiScope/Application/src/main/java/com/example/android/midiscope/MidiScope.java83
-rw-r--r--media/MidiScope/Application/src/main/java/com/example/android/midiscope/ScopeLogger.java25
-rwxr-xr-xmedia/MidiScope/Application/src/main/res/drawable-hdpi/ic_clear_all.pngbin0 -> 107 bytes
-rwxr-xr-xmedia/MidiScope/Application/src/main/res/drawable-mdpi/ic_clear_all.pngbin0 -> 83 bytes
-rwxr-xr-xmedia/MidiScope/Application/src/main/res/drawable-xhdpi/ic_clear_all.pngbin0 -> 99 bytes
-rwxr-xr-xmedia/MidiScope/Application/src/main/res/drawable-xxhdpi/ic_clear_all.pngbin0 -> 108 bytes
-rwxr-xr-xmedia/MidiScope/Application/src/main/res/drawable-xxxhdpi/ic_clear_all.pngbin0 -> 98 bytes
-rw-r--r--media/MidiScope/Application/src/main/res/layout/main.xml60
-rw-r--r--media/MidiScope/Application/src/main/res/menu/main.xml32
-rwxr-xr-xmedia/MidiScope/Application/src/main/res/mipmap-hdpi/ic_launcher.pngbin0 -> 3022 bytes
-rwxr-xr-xmedia/MidiScope/Application/src/main/res/mipmap-mdpi/ic_launcher.pngbin0 -> 1887 bytes
-rwxr-xr-xmedia/MidiScope/Application/src/main/res/mipmap-xhdpi/ic_launcher.pngbin0 -> 3855 bytes
-rwxr-xr-xmedia/MidiScope/Application/src/main/res/mipmap-xxhdpi/ic_launcher.pngbin0 -> 6224 bytes
-rwxr-xr-xmedia/MidiScope/Application/src/main/res/mipmap-xxxhdpi/ic_launcher.pngbin0 -> 8972 bytes
-rw-r--r--media/MidiScope/Application/src/main/res/values/colors.xml26
-rw-r--r--media/MidiScope/Application/src/main/res/values/strings.xml24
-rw-r--r--media/MidiScope/Application/src/main/res/values/styles.xml25
-rw-r--r--media/MidiScope/Application/src/main/res/xml/scope_device_info.xml24
-rw-r--r--media/MidiScope/build.gradle12
-rw-r--r--media/MidiScope/buildSrc/build.gradle16
-rw-r--r--media/MidiScope/gradle/wrapper/gradle-wrapper.jarbin0 -> 49896 bytes
-rw-r--r--media/MidiScope/gradle/wrapper/gradle-wrapper.properties6
-rwxr-xr-xmedia/MidiScope/gradlew164
-rw-r--r--media/MidiScope/gradlew.bat90
-rw-r--r--media/MidiScope/screenshots/1-main.pngbin0 -> 43259 bytes
-rw-r--r--media/MidiScope/screenshots/2-signals.pngbin0 -> 265359 bytes
-rw-r--r--media/MidiScope/screenshots/icon-web.pngbin0 -> 34730 bytes
-rw-r--r--media/MidiScope/settings.gradle2
-rw-r--r--media/MidiScope/template-params.xml79
36 files changed, 1145 insertions, 0 deletions
diff --git a/media/MidiScope/Application/.gitignore b/media/MidiScope/Application/.gitignore
new file mode 100644
index 00000000..6eb878d4
--- /dev/null
+++ b/media/MidiScope/Application/.gitignore
@@ -0,0 +1,16 @@
+# Copyright 2013 The Android Open Source Project
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+src/template/
+src/common/
+build.gradle
diff --git a/media/MidiScope/Application/proguard-project.txt b/media/MidiScope/Application/proguard-project.txt
new file mode 100644
index 00000000..f2fe1559
--- /dev/null
+++ b/media/MidiScope/Application/proguard-project.txt
@@ -0,0 +1,20 @@
+# To enable ProGuard in your project, edit project.properties
+# to define the proguard.config property as described in that file.
+#
+# Add project specific ProGuard rules here.
+# By default, the flags in this file are appended to flags specified
+# in ${sdk.dir}/tools/proguard/proguard-android.txt
+# You can edit the include path and order by changing the ProGuard
+# include property in project.properties.
+#
+# For more details, see
+# http://developer.android.com/guide/developing/tools/proguard.html
+
+# Add any project specific keep options here:
+
+# If your project uses WebView with JS, uncomment the following
+# and specify the fully qualified class name to the JavaScript interface
+# class:
+#-keepclassmembers class fqcn.of.javascript.interface.for.webview {
+# public *;
+#}
diff --git a/media/MidiScope/Application/src/androidTest/java/com/example/android/midiscope/test/SampleTests.java b/media/MidiScope/Application/src/androidTest/java/com/example/android/midiscope/test/SampleTests.java
new file mode 100644
index 00000000..e132dae9
--- /dev/null
+++ b/media/MidiScope/Application/src/androidTest/java/com/example/android/midiscope/test/SampleTests.java
@@ -0,0 +1,54 @@
+/*
+ * Copyright 2015 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.example.android.midiscope.test;
+
+import com.example.android.midiscope.*;
+
+import android.test.ActivityInstrumentationTestCase2;
+
+/**
+ * Tests for MidiScope sample.
+ */
+public class SampleTests extends ActivityInstrumentationTestCase2<MainActivity> {
+
+ private MainActivity mTestActivity;
+
+ public SampleTests() {
+ super(MainActivity.class);
+ }
+
+ @Override
+ protected void setUp() throws Exception {
+ super.setUp();
+
+ // Starts the activity under test using the default Intent with:
+ // action = {@link Intent#ACTION_MAIN}
+ // flags = {@link Intent#FLAG_ACTIVITY_NEW_TASK}
+ // All other fields are null or empty.
+ mTestActivity = getActivity();
+ }
+
+ /**
+ * Test if the test fixture has been set up correctly.
+ */
+ public void testPreconditions() {
+ //Try to add a message to add context to your assertions. These messages will be shown if
+ //a tests fails and make it easy to understand why a test failed
+ assertNotNull("mTestActivity is null", mTestActivity);
+ }
+
+}
diff --git a/media/MidiScope/Application/src/main/AndroidManifest.xml b/media/MidiScope/Application/src/main/AndroidManifest.xml
new file mode 100644
index 00000000..c2b1c43f
--- /dev/null
+++ b/media/MidiScope/Application/src/main/AndroidManifest.xml
@@ -0,0 +1,55 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ Copyright 2015 The Android Open Source Project
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+-->
+<manifest
+ package="com.example.android.midiscope"
+ xmlns:android="http://schemas.android.com/apk/res/android"
+ android:versionCode="1"
+ android:versionName="1.0">
+
+ <uses-feature
+ android:name="android.software.midi"
+ android:required="true"/>
+
+ <application
+ android:allowBackup="true"
+ android:icon="@mipmap/ic_launcher"
+ android:label="@string/app_name"
+ android:theme="@style/MidiScopeTheme">
+
+ <activity
+ android:name=".MainActivity"
+ android:label="@string/app_name">
+ <intent-filter>
+ <action android:name="android.intent.action.MAIN"/>
+ <category android:name="android.intent.category.LAUNCHER"/>
+ </intent-filter>
+ </activity>
+
+ <service
+ android:name="MidiScope"
+ android:permission="android.permission.BIND_MIDI_DEVICE_SERVICE">
+ <intent-filter>
+ <action android:name="android.media.midi.MidiDeviceService"/>
+ </intent-filter>
+ <meta-data
+ android:name="android.media.midi.MidiDeviceService"
+ android:resource="@xml/scope_device_info"/>
+ </service>
+
+ </application>
+
+</manifest>
diff --git a/media/MidiScope/Application/src/main/java/com/example/android/midiscope/LoggingReceiver.java b/media/MidiScope/Application/src/main/java/com/example/android/midiscope/LoggingReceiver.java
new file mode 100644
index 00000000..23ce8f7c
--- /dev/null
+++ b/media/MidiScope/Application/src/main/java/com/example/android/midiscope/LoggingReceiver.java
@@ -0,0 +1,62 @@
+/*
+ * Copyright (C) 2015 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.example.android.midiscope;
+
+import android.media.midi.MidiReceiver;
+import android.util.Log;
+
+import java.io.IOException;
+import java.util.concurrent.TimeUnit;
+
+/**
+ * Convert incoming MIDI messages to a string and write them to a ScopeLogger.
+ * Assume that messages have been aligned using a MidiFramer.
+ */
+public class LoggingReceiver extends MidiReceiver {
+ public static final String TAG = "MidiScope";
+ private static final long NANOS_PER_SECOND = TimeUnit.SECONDS.toNanos(1);
+ private long mStartTime;
+ private ScopeLogger mLogger;
+
+ public LoggingReceiver(ScopeLogger logger) {
+ mStartTime = System.nanoTime();
+ mLogger = logger;
+ }
+
+ /*
+ * @see android.media.midi.MidiReceiver#onReceive(byte[], int, int, long)
+ */
+ @Override
+ public void onSend(byte[] data, int offset, int count, long timestamp)
+ throws IOException {
+ StringBuilder sb = new StringBuilder();
+ if (timestamp == 0) {
+ sb.append(String.format("-----0----: "));
+ } else {
+ long monoTime = timestamp - mStartTime;
+ double seconds = (double) monoTime / NANOS_PER_SECOND;
+ sb.append(String.format("%10.3f: ", seconds));
+ }
+ sb.append(MidiPrinter.formatBytes(data, offset, count));
+ sb.append(": ");
+ sb.append(MidiPrinter.formatMessage(data, offset, count));
+ String text = sb.toString();
+ mLogger.log(text);
+ Log.i(TAG, text);
+ }
+
+} \ No newline at end of file
diff --git a/media/MidiScope/Application/src/main/java/com/example/android/midiscope/MainActivity.java b/media/MidiScope/Application/src/main/java/com/example/android/midiscope/MainActivity.java
new file mode 100644
index 00000000..41d74f03
--- /dev/null
+++ b/media/MidiScope/Application/src/main/java/com/example/android/midiscope/MainActivity.java
@@ -0,0 +1,162 @@
+/*
+ * Copyright (C) 2015 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.example.android.midiscope;
+
+import android.app.ActionBar;
+import android.app.Activity;
+import android.media.midi.MidiDeviceInfo;
+import android.media.midi.MidiManager;
+import android.media.midi.MidiReceiver;
+import android.os.Bundle;
+import android.view.Menu;
+import android.view.MenuItem;
+import android.view.View;
+import android.view.WindowManager;
+import android.widget.ScrollView;
+import android.widget.TextView;
+import android.widget.Toolbar;
+
+import com.example.android.common.midi.MidiFramer;
+import com.example.android.common.midi.MidiOutputPortSelector;
+import com.example.android.common.midi.MidiPortWrapper;
+
+import java.util.LinkedList;
+
+/**
+ * App that provides a MIDI echo service.
+ */
+public class MainActivity extends Activity implements ScopeLogger {
+
+ private static final int MAX_LINES = 100;
+
+ private final LinkedList<String> mLogLines = new LinkedList<>();
+ private TextView mLog;
+ private ScrollView mScroller;
+ private MidiOutputPortSelector mLogSenderSelector;
+
+ @Override
+ public void onCreate(Bundle savedInstanceState) {
+ super.onCreate(savedInstanceState);
+ setContentView(R.layout.main);
+
+ setActionBar((Toolbar) findViewById(R.id.toolbar));
+ ActionBar actionBar = getActionBar();
+ if (actionBar != null) {
+ actionBar.setDisplayShowTitleEnabled(false);
+ }
+
+ mLog = (TextView) findViewById(R.id.log);
+ mScroller = (ScrollView) findViewById(R.id.scroll);
+
+ // Setup MIDI
+ MidiManager midiManager = (MidiManager) getSystemService(MIDI_SERVICE);
+
+ // Receiver that prints the messages.
+ MidiReceiver loggingReceiver = new LoggingReceiver(this);
+
+ // Receiver that parses raw data into complete messages.
+ MidiFramer connectFramer = new MidiFramer(loggingReceiver);
+
+ // Setup a menu to select an input source.
+ mLogSenderSelector = new MidiOutputPortSelector(midiManager, this, R.id.spinner_senders) {
+ @Override
+ public void onPortSelected(final MidiPortWrapper wrapper) {
+ super.onPortSelected(wrapper);
+ if (wrapper != null) {
+ mLogLines.clear();
+ MidiDeviceInfo deviceInfo = wrapper.getDeviceInfo();
+ if (deviceInfo == null) {
+ log(getString(R.string.header_text));
+ } else {
+ log(MidiPrinter.formatDeviceInfo(deviceInfo));
+ }
+ }
+ }
+ };
+ mLogSenderSelector.getSender().connect(connectFramer);
+
+ // Tell the virtual device to log its messages here..
+ MidiScope.setScopeLogger(this);
+ }
+
+ @Override
+ public void onDestroy() {
+ mLogSenderSelector.onClose();
+ // The scope will live on as a service so we need to tell it to stop
+ // writing log messages to this Activity.
+ MidiScope.setScopeLogger(null);
+ super.onDestroy();
+ }
+
+ @Override
+ public boolean onCreateOptionsMenu(Menu menu) {
+ getMenuInflater().inflate(R.menu.main, menu);
+ setKeepScreenOn(menu.findItem(R.id.action_keep_screen_on).isChecked());
+ return true;
+ }
+
+ @Override
+ public boolean onOptionsItemSelected(MenuItem item) {
+ switch (item.getItemId()) {
+ case R.id.action_clear_all:
+ mLogLines.clear();
+ logOnUiThread("");
+ break;
+ case R.id.action_keep_screen_on:
+ boolean checked = !item.isChecked();
+ setKeepScreenOn(checked);
+ item.setChecked(checked);
+ break;
+ }
+ return super.onOptionsItemSelected(item);
+ }
+
+ private void setKeepScreenOn(boolean keepScreenOn) {
+ if (keepScreenOn) {
+ getWindow().addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);
+ } else {
+ getWindow().clearFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);
+ }
+ }
+
+ @Override
+ public void log(final String string) {
+ runOnUiThread(new Runnable() {
+ @Override
+ public void run() {
+ logOnUiThread(string);
+ }
+ });
+ }
+
+ /**
+ * Logs a message to our TextView. This needs to be called from the UI thread.
+ */
+ private void logOnUiThread(String s) {
+ mLogLines.add(s);
+ if (mLogLines.size() > MAX_LINES) {
+ mLogLines.removeFirst();
+ }
+ // Render line buffer to one String.
+ StringBuilder sb = new StringBuilder();
+ for (String line : mLogLines) {
+ sb.append(line).append('\n');
+ }
+ mLog.setText(sb.toString());
+ mScroller.fullScroll(View.FOCUS_DOWN);
+ }
+}
diff --git a/media/MidiScope/Application/src/main/java/com/example/android/midiscope/MidiPrinter.java b/media/MidiScope/Application/src/main/java/com/example/android/midiscope/MidiPrinter.java
new file mode 100644
index 00000000..9e97c04c
--- /dev/null
+++ b/media/MidiScope/Application/src/main/java/com/example/android/midiscope/MidiPrinter.java
@@ -0,0 +1,108 @@
+/*
+ * Copyright (C) 2015 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.example.android.midiscope;
+
+import android.media.midi.MidiDeviceInfo;
+import android.media.midi.MidiDeviceInfo.PortInfo;
+import android.os.Bundle;
+
+import com.example.android.common.midi.MidiConstants;
+
+/**
+ * Format a MIDI message for printing.
+ */
+public class MidiPrinter {
+
+ public static final String[] CHANNEL_COMMAND_NAMES = { "NoteOff", "NoteOn",
+ "PolyTouch", "Control", "Program", "Pressure", "Bend" };
+ public static final String[] SYSTEM_COMMAND_NAMES = { "SysEx", // F0
+ "TimeCode", // F1
+ "SongPos", // F2
+ "SongSel", // F3
+ "F4", // F4
+ "F5", // F5
+ "TuneReq", // F6
+ "EndSysex", // F7
+ "TimingClock", // F8
+ "F9", // F9
+ "Start", // FA
+ "Continue", // FB
+ "Stop", // FC
+ "FD", // FD
+ "ActiveSensing", // FE
+ "Reset" // FF
+ };
+
+ public static String getName(int status) {
+ if (status >= 0xF0) {
+ int index = status & 0x0F;
+ return SYSTEM_COMMAND_NAMES[index];
+ } else if (status >= 0x80) {
+ int index = (status >> 4) & 0x07;
+ return CHANNEL_COMMAND_NAMES[index];
+ } else {
+ return "data";
+ }
+ }
+
+ public static String formatBytes(byte[] data, int offset, int count) {
+ StringBuilder sb = new StringBuilder();
+ for (int i = 0; i < count; i++) {
+ sb.append(String.format(" %02X", data[offset + i]));
+ }
+ return sb.toString();
+ }
+
+ public static String formatMessage(byte[] data, int offset, int count) {
+ StringBuilder sb = new StringBuilder();
+ byte statusByte = data[offset++];
+ int status = statusByte & 0xFF;
+ sb.append(getName(status)).append("(");
+ int numData = MidiConstants.getBytesPerMessage(statusByte) - 1;
+ if ((status >= 0x80) && (status < 0xF0)) { // channel message
+ int channel = status & 0x0F;
+ // Add 1 for humans who think channels are numbered 1-16.
+ sb.append((channel + 1)).append(", ");
+ }
+ for (int i = 0; i < numData; i++) {
+ if (i > 0) {
+ sb.append(", ");
+ }
+ sb.append(data[offset++]);
+ }
+ sb.append(")");
+ return sb.toString();
+ }
+
+ public static String formatDeviceInfo(MidiDeviceInfo info) {
+ StringBuilder sb = new StringBuilder();
+ if (info != null) {
+ Bundle properties = info.getProperties();
+ for (String key : properties.keySet()) {
+ Object value = properties.get(key);
+ sb.append(key).append(" = ").append(value).append('\n');
+ }
+ for (PortInfo port : info.getPorts()) {
+ sb.append((port.getType() == PortInfo.TYPE_INPUT) ? "input"
+ : "output");
+ sb.append("[").append(port.getPortNumber()).append("] = \"").append(port.getName()
+ + "\"\n");
+ }
+ }
+ return sb.toString();
+ }
+}
diff --git a/media/MidiScope/Application/src/main/java/com/example/android/midiscope/MidiScope.java b/media/MidiScope/Application/src/main/java/com/example/android/midiscope/MidiScope.java
new file mode 100644
index 00000000..3965d83c
--- /dev/null
+++ b/media/MidiScope/Application/src/main/java/com/example/android/midiscope/MidiScope.java
@@ -0,0 +1,83 @@
+/*
+ * Copyright (C) 2015 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.example.android.midiscope;
+
+import android.media.midi.MidiDeviceService;
+import android.media.midi.MidiDeviceStatus;
+import android.media.midi.MidiReceiver;
+
+import com.example.android.common.midi.MidiFramer;
+
+import java.io.IOException;
+
+/**
+ * Virtual MIDI Device that logs messages to a ScopeLogger.
+ */
+
+public class MidiScope extends MidiDeviceService {
+
+ private static ScopeLogger mScopeLogger;
+ private MidiReceiver mInputReceiver = new MyReceiver();
+ private static MidiFramer mDeviceFramer;
+
+ @Override
+ public MidiReceiver[] onGetInputPortReceivers() {
+ return new MidiReceiver[] { mInputReceiver };
+ }
+
+ public static ScopeLogger getScopeLogger() {
+ return mScopeLogger;
+ }
+
+ public static void setScopeLogger(ScopeLogger logger) {
+ if (logger != null) {
+ // Receiver that prints the messages.
+ LoggingReceiver loggingReceiver = new LoggingReceiver(logger);
+ mDeviceFramer = new MidiFramer(loggingReceiver);
+ }
+ mScopeLogger = logger;
+ }
+
+ private static class MyReceiver extends MidiReceiver {
+ @Override
+ public void onSend(byte[] data, int offset, int count,
+ long timestamp) throws IOException {
+ if (mScopeLogger != null) {
+ // Send raw data to be parsed into discrete messages.
+ mDeviceFramer.send(data, offset, count, timestamp);
+ }
+ }
+ }
+
+ /**
+ * This will get called when clients connect or disconnect.
+ * Log device information.
+ */
+ @Override
+ public void onDeviceStatusChanged(MidiDeviceStatus status) {
+ if (mScopeLogger != null) {
+ if (status.isInputPortOpen(0)) {
+ mScopeLogger.log("=== connected ===");
+ String text = MidiPrinter.formatDeviceInfo(
+ status.getDeviceInfo());
+ mScopeLogger.log(text);
+ } else {
+ mScopeLogger.log("--- disconnected ---");
+ }
+ }
+ }
+}
diff --git a/media/MidiScope/Application/src/main/java/com/example/android/midiscope/ScopeLogger.java b/media/MidiScope/Application/src/main/java/com/example/android/midiscope/ScopeLogger.java
new file mode 100644
index 00000000..dc52efd6
--- /dev/null
+++ b/media/MidiScope/Application/src/main/java/com/example/android/midiscope/ScopeLogger.java
@@ -0,0 +1,25 @@
+/*
+ * Copyright (C) 2015 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.example.android.midiscope;
+
+public interface ScopeLogger {
+ /**
+ * Write the text string somewhere that the user can see it.
+ * @param text
+ */
+ void log(String text);
+}
diff --git a/media/MidiScope/Application/src/main/res/drawable-hdpi/ic_clear_all.png b/media/MidiScope/Application/src/main/res/drawable-hdpi/ic_clear_all.png
new file mode 100755
index 00000000..e23d886c
--- /dev/null
+++ b/media/MidiScope/Application/src/main/res/drawable-hdpi/ic_clear_all.png
Binary files differ
diff --git a/media/MidiScope/Application/src/main/res/drawable-mdpi/ic_clear_all.png b/media/MidiScope/Application/src/main/res/drawable-mdpi/ic_clear_all.png
new file mode 100755
index 00000000..dca30487
--- /dev/null
+++ b/media/MidiScope/Application/src/main/res/drawable-mdpi/ic_clear_all.png
Binary files differ
diff --git a/media/MidiScope/Application/src/main/res/drawable-xhdpi/ic_clear_all.png b/media/MidiScope/Application/src/main/res/drawable-xhdpi/ic_clear_all.png
new file mode 100755
index 00000000..fef5dcd2
--- /dev/null
+++ b/media/MidiScope/Application/src/main/res/drawable-xhdpi/ic_clear_all.png
Binary files differ
diff --git a/media/MidiScope/Application/src/main/res/drawable-xxhdpi/ic_clear_all.png b/media/MidiScope/Application/src/main/res/drawable-xxhdpi/ic_clear_all.png
new file mode 100755
index 00000000..51d2d3da
--- /dev/null
+++ b/media/MidiScope/Application/src/main/res/drawable-xxhdpi/ic_clear_all.png
Binary files differ
diff --git a/media/MidiScope/Application/src/main/res/drawable-xxxhdpi/ic_clear_all.png b/media/MidiScope/Application/src/main/res/drawable-xxxhdpi/ic_clear_all.png
new file mode 100755
index 00000000..9dbccf36
--- /dev/null
+++ b/media/MidiScope/Application/src/main/res/drawable-xxxhdpi/ic_clear_all.png
Binary files differ
diff --git a/media/MidiScope/Application/src/main/res/layout/main.xml b/media/MidiScope/Application/src/main/res/layout/main.xml
new file mode 100644
index 00000000..71c52aa6
--- /dev/null
+++ b/media/MidiScope/Application/src/main/res/layout/main.xml
@@ -0,0 +1,60 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!--
+ Copyright (C) 2015 The Android Open Source Project
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+-->
+
+<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
+ android:layout_width="match_parent"
+ android:layout_height="match_parent"
+ android:orientation="vertical">
+
+ <Toolbar
+ android:id="@+id/toolbar"
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:background="?android:attr/colorPrimary"
+ android:elevation="4dp"
+ android:minHeight="?android:attr/actionBarSize"
+ android:popupTheme="@android:style/ThemeOverlay.Material.Light"
+ android:theme="@android:style/ThemeOverlay.Material.Dark.ActionBar">
+
+ <Spinner
+ android:id="@+id/spinner_senders"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:entries="@array/senders"
+ android:popupTheme="@android:style/ThemeOverlay.Material.Light"/>
+
+ </Toolbar>
+
+ <ScrollView
+ android:id="@+id/scroll"
+ android:layout_width="match_parent"
+ android:layout_height="0px"
+ android:layout_weight="1">
+
+ <TextView
+ android:id="@+id/log"
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:paddingBottom="8dp"
+ android:paddingEnd="16dp"
+ android:paddingStart="16dp"
+ android:paddingTop="8dp"
+ android:textAppearance="?android:attr/textAppearanceMedium"/>
+
+ </ScrollView>
+
+</LinearLayout>
diff --git a/media/MidiScope/Application/src/main/res/menu/main.xml b/media/MidiScope/Application/src/main/res/menu/main.xml
new file mode 100644
index 00000000..abb1842a
--- /dev/null
+++ b/media/MidiScope/Application/src/main/res/menu/main.xml
@@ -0,0 +1,32 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!--
+ Copyright 2015 The Android Open Source Project
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+-->
+<menu xmlns:android="http://schemas.android.com/apk/res/android">
+
+ <item
+ android:id="@+id/action_clear_all"
+ android:icon="@drawable/ic_clear_all"
+ android:showAsAction="ifRoom"
+ android:title="@string/clear_log"/>
+
+ <item
+ android:id="@+id/action_keep_screen_on"
+ android:checkable="true"
+ android:checked="true"
+ android:showAsAction="never"
+ android:title="@string/keep_screen_on"/>
+
+</menu>
diff --git a/media/MidiScope/Application/src/main/res/mipmap-hdpi/ic_launcher.png b/media/MidiScope/Application/src/main/res/mipmap-hdpi/ic_launcher.png
new file mode 100755
index 00000000..4a755241
--- /dev/null
+++ b/media/MidiScope/Application/src/main/res/mipmap-hdpi/ic_launcher.png
Binary files differ
diff --git a/media/MidiScope/Application/src/main/res/mipmap-mdpi/ic_launcher.png b/media/MidiScope/Application/src/main/res/mipmap-mdpi/ic_launcher.png
new file mode 100755
index 00000000..09a42710
--- /dev/null
+++ b/media/MidiScope/Application/src/main/res/mipmap-mdpi/ic_launcher.png
Binary files differ
diff --git a/media/MidiScope/Application/src/main/res/mipmap-xhdpi/ic_launcher.png b/media/MidiScope/Application/src/main/res/mipmap-xhdpi/ic_launcher.png
new file mode 100755
index 00000000..e9c9a361
--- /dev/null
+++ b/media/MidiScope/Application/src/main/res/mipmap-xhdpi/ic_launcher.png
Binary files differ
diff --git a/media/MidiScope/Application/src/main/res/mipmap-xxhdpi/ic_launcher.png b/media/MidiScope/Application/src/main/res/mipmap-xxhdpi/ic_launcher.png
new file mode 100755
index 00000000..6e79c3bc
--- /dev/null
+++ b/media/MidiScope/Application/src/main/res/mipmap-xxhdpi/ic_launcher.png
Binary files differ
diff --git a/media/MidiScope/Application/src/main/res/mipmap-xxxhdpi/ic_launcher.png b/media/MidiScope/Application/src/main/res/mipmap-xxxhdpi/ic_launcher.png
new file mode 100755
index 00000000..638d4e13
--- /dev/null
+++ b/media/MidiScope/Application/src/main/res/mipmap-xxxhdpi/ic_launcher.png
Binary files differ
diff --git a/media/MidiScope/Application/src/main/res/values/colors.xml b/media/MidiScope/Application/src/main/res/values/colors.xml
new file mode 100644
index 00000000..eef48d88
--- /dev/null
+++ b/media/MidiScope/Application/src/main/res/values/colors.xml
@@ -0,0 +1,26 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!--
+ Copyright 2015 The Android Open Source Project
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+-->
+<resources>
+ <color name="primary">#009688</color>
+ <color name="primary_dark">#00796B</color>
+ <color name="primary_light">#B2DFDB</color>
+ <color name="accent">#FFC107</color>
+ <color name="primary_text">#212121</color>
+ <color name="secondary_text">#727272</color>
+ <color name="icons">#FFFFFF</color>
+ <color name="divider">#B6B6B6</color>
+</resources>
diff --git a/media/MidiScope/Application/src/main/res/values/strings.xml b/media/MidiScope/Application/src/main/res/values/strings.xml
new file mode 100644
index 00000000..52beb4e1
--- /dev/null
+++ b/media/MidiScope/Application/src/main/res/values/strings.xml
@@ -0,0 +1,24 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ Copyright 2015 The Android Open Source Project
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+-->
+<resources>
+ <string name="header_text">Select a MIDI source from the Spinner above or send messages to MidiScope.</string>
+ <string name="clear_log">Clear Log</string>
+ <string name="keep_screen_on">Keep Screen On</string>
+ <string-array name="senders">
+ <item>"none"</item>
+ </string-array>
+</resources>
diff --git a/media/MidiScope/Application/src/main/res/values/styles.xml b/media/MidiScope/Application/src/main/res/values/styles.xml
new file mode 100644
index 00000000..00360096
--- /dev/null
+++ b/media/MidiScope/Application/src/main/res/values/styles.xml
@@ -0,0 +1,25 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ Copyright 2015 The Android Open Source Project
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+-->
+<resources>
+
+ <style name="MidiScopeTheme" parent="android:Theme.Material.Light.NoActionBar">
+ <item name="android:colorPrimary">@color/primary</item>
+ <item name="android:colorPrimaryDark">@color/primary_dark</item>
+ <item name="android:colorAccent">@color/accent</item>
+ </style>
+
+</resources>
diff --git a/media/MidiScope/Application/src/main/res/xml/scope_device_info.xml b/media/MidiScope/Application/src/main/res/xml/scope_device_info.xml
new file mode 100644
index 00000000..f89f1109
--- /dev/null
+++ b/media/MidiScope/Application/src/main/res/xml/scope_device_info.xml
@@ -0,0 +1,24 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!--
+ Copyright 2015 The Android Open Source Project
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+-->
+<devices>
+ <device
+ name="AndroidMidiScope"
+ manufacturer="AndroidTest"
+ product="Scope">
+ <input-port name="input"/>
+ </device>
+</devices>
diff --git a/media/MidiScope/build.gradle b/media/MidiScope/build.gradle
new file mode 100644
index 00000000..9b6a9ce4
--- /dev/null
+++ b/media/MidiScope/build.gradle
@@ -0,0 +1,12 @@
+
+
+// BEGIN_EXCLUDE
+import com.example.android.samples.build.SampleGenPlugin
+apply plugin: SampleGenPlugin
+
+samplegen {
+ pathToBuild "../../../../build"
+ pathToSamplesCommon "../../common"
+}
+apply from: "../../../../build/build.gradle"
+// END_EXCLUDE
diff --git a/media/MidiScope/buildSrc/build.gradle b/media/MidiScope/buildSrc/build.gradle
new file mode 100644
index 00000000..d77115d0
--- /dev/null
+++ b/media/MidiScope/buildSrc/build.gradle
@@ -0,0 +1,16 @@
+
+repositories {
+ jcenter()
+}
+dependencies {
+ compile 'org.freemarker:freemarker:2.3.20'
+}
+
+sourceSets {
+ main {
+ groovy {
+ srcDir new File(rootDir, "../../../../../build/buildSrc/src/main/groovy")
+ }
+ }
+}
+
diff --git a/media/MidiScope/gradle/wrapper/gradle-wrapper.jar b/media/MidiScope/gradle/wrapper/gradle-wrapper.jar
new file mode 100644
index 00000000..8c0fb64a
--- /dev/null
+++ b/media/MidiScope/gradle/wrapper/gradle-wrapper.jar
Binary files differ
diff --git a/media/MidiScope/gradle/wrapper/gradle-wrapper.properties b/media/MidiScope/gradle/wrapper/gradle-wrapper.properties
new file mode 100644
index 00000000..afb32963
--- /dev/null
+++ b/media/MidiScope/gradle/wrapper/gradle-wrapper.properties
@@ -0,0 +1,6 @@
+#Wed Apr 10 15:27:10 PDT 2013
+distributionBase=GRADLE_USER_HOME
+distributionPath=wrapper/dists
+zipStoreBase=GRADLE_USER_HOME
+zipStorePath=wrapper/dists
+distributionUrl=http\://services.gradle.org/distributions/gradle-2.2.1-bin.zip
diff --git a/media/MidiScope/gradlew b/media/MidiScope/gradlew
new file mode 100755
index 00000000..91a7e269
--- /dev/null
+++ b/media/MidiScope/gradlew
@@ -0,0 +1,164 @@
+#!/usr/bin/env bash
+
+##############################################################################
+##
+## Gradle start up script for UN*X
+##
+##############################################################################
+
+# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
+DEFAULT_JVM_OPTS=""
+
+APP_NAME="Gradle"
+APP_BASE_NAME=`basename "$0"`
+
+# Use the maximum available, or set MAX_FD != -1 to use that value.
+MAX_FD="maximum"
+
+warn ( ) {
+ echo "$*"
+}
+
+die ( ) {
+ echo
+ echo "$*"
+ echo
+ exit 1
+}
+
+# OS specific support (must be 'true' or 'false').
+cygwin=false
+msys=false
+darwin=false
+case "`uname`" in
+ CYGWIN* )
+ cygwin=true
+ ;;
+ Darwin* )
+ darwin=true
+ ;;
+ MINGW* )
+ msys=true
+ ;;
+esac
+
+# For Cygwin, ensure paths are in UNIX format before anything is touched.
+if $cygwin ; then
+ [ -n "$JAVA_HOME" ] && JAVA_HOME=`cygpath --unix "$JAVA_HOME"`
+fi
+
+# Attempt to set APP_HOME
+# Resolve links: $0 may be a link
+PRG="$0"
+# Need this for relative symlinks.
+while [ -h "$PRG" ] ; do
+ ls=`ls -ld "$PRG"`
+ link=`expr "$ls" : '.*-> \(.*\)$'`
+ if expr "$link" : '/.*' > /dev/null; then
+ PRG="$link"
+ else
+ PRG=`dirname "$PRG"`"/$link"
+ fi
+done
+SAVED="`pwd`"
+cd "`dirname \"$PRG\"`/" >&-
+APP_HOME="`pwd -P`"
+cd "$SAVED" >&-
+
+CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
+
+# Determine the Java command to use to start the JVM.
+if [ -n "$JAVA_HOME" ] ; then
+ if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
+ # IBM's JDK on AIX uses strange locations for the executables
+ JAVACMD="$JAVA_HOME/jre/sh/java"
+ else
+ JAVACMD="$JAVA_HOME/bin/java"
+ fi
+ if [ ! -x "$JAVACMD" ] ; then
+ die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME
+
+Please set the JAVA_HOME variable in your environment to match the
+location of your Java installation."
+ fi
+else
+ JAVACMD="java"
+ which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
+
+Please set the JAVA_HOME variable in your environment to match the
+location of your Java installation."
+fi
+
+# Increase the maximum file descriptors if we can.
+if [ "$cygwin" = "false" -a "$darwin" = "false" ] ; then
+ MAX_FD_LIMIT=`ulimit -H -n`
+ if [ $? -eq 0 ] ; then
+ if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then
+ MAX_FD="$MAX_FD_LIMIT"
+ fi
+ ulimit -n $MAX_FD
+ if [ $? -ne 0 ] ; then
+ warn "Could not set maximum file descriptor limit: $MAX_FD"
+ fi
+ else
+ warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT"
+ fi
+fi
+
+# For Darwin, add options to specify how the application appears in the dock
+if $darwin; then
+ GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\""
+fi
+
+# For Cygwin, switch paths to Windows format before running java
+if $cygwin ; then
+ APP_HOME=`cygpath --path --mixed "$APP_HOME"`
+ CLASSPATH=`cygpath --path --mixed "$CLASSPATH"`
+
+ # We build the pattern for arguments to be converted via cygpath
+ ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null`
+ SEP=""
+ for dir in $ROOTDIRSRAW ; do
+ ROOTDIRS="$ROOTDIRS$SEP$dir"
+ SEP="|"
+ done
+ OURCYGPATTERN="(^($ROOTDIRS))"
+ # Add a user-defined pattern to the cygpath arguments
+ if [ "$GRADLE_CYGPATTERN" != "" ] ; then
+ OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)"
+ fi
+ # Now convert the arguments - kludge to limit ourselves to /bin/sh
+ i=0
+ for arg in "$@" ; do
+ CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -`
+ CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option
+
+ if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition
+ eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"`
+ else
+ eval `echo args$i`="\"$arg\""
+ fi
+ i=$((i+1))
+ done
+ case $i in
+ (0) set -- ;;
+ (1) set -- "$args0" ;;
+ (2) set -- "$args0" "$args1" ;;
+ (3) set -- "$args0" "$args1" "$args2" ;;
+ (4) set -- "$args0" "$args1" "$args2" "$args3" ;;
+ (5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;;
+ (6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;;
+ (7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;;
+ (8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;;
+ (9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;;
+ esac
+fi
+
+# Split up the JVM_OPTS And GRADLE_OPTS values into an array, following the shell quoting and substitution rules
+function splitJvmOpts() {
+ JVM_OPTS=("$@")
+}
+eval splitJvmOpts $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS
+JVM_OPTS[${#JVM_OPTS[*]}]="-Dorg.gradle.appname=$APP_BASE_NAME"
+
+exec "$JAVACMD" "${JVM_OPTS[@]}" -classpath "$CLASSPATH" org.gradle.wrapper.GradleWrapperMain "$@"
diff --git a/media/MidiScope/gradlew.bat b/media/MidiScope/gradlew.bat
new file mode 100644
index 00000000..aec99730
--- /dev/null
+++ b/media/MidiScope/gradlew.bat
@@ -0,0 +1,90 @@
+@if "%DEBUG%" == "" @echo off
+@rem ##########################################################################
+@rem
+@rem Gradle startup script for Windows
+@rem
+@rem ##########################################################################
+
+@rem Set local scope for the variables with windows NT shell
+if "%OS%"=="Windows_NT" setlocal
+
+@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
+set DEFAULT_JVM_OPTS=
+
+set DIRNAME=%~dp0
+if "%DIRNAME%" == "" set DIRNAME=.
+set APP_BASE_NAME=%~n0
+set APP_HOME=%DIRNAME%
+
+@rem Find java.exe
+if defined JAVA_HOME goto findJavaFromJavaHome
+
+set JAVA_EXE=java.exe
+%JAVA_EXE% -version >NUL 2>&1
+if "%ERRORLEVEL%" == "0" goto init
+
+echo.
+echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
+echo.
+echo Please set the JAVA_HOME variable in your environment to match the
+echo location of your Java installation.
+
+goto fail
+
+:findJavaFromJavaHome
+set JAVA_HOME=%JAVA_HOME:"=%
+set JAVA_EXE=%JAVA_HOME%/bin/java.exe
+
+if exist "%JAVA_EXE%" goto init
+
+echo.
+echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
+echo.
+echo Please set the JAVA_HOME variable in your environment to match the
+echo location of your Java installation.
+
+goto fail
+
+:init
+@rem Get command-line arguments, handling Windowz variants
+
+if not "%OS%" == "Windows_NT" goto win9xME_args
+if "%@eval[2+2]" == "4" goto 4NT_args
+
+:win9xME_args
+@rem Slurp the command line arguments.
+set CMD_LINE_ARGS=
+set _SKIP=2
+
+:win9xME_args_slurp
+if "x%~1" == "x" goto execute
+
+set CMD_LINE_ARGS=%*
+goto execute
+
+:4NT_args
+@rem Get arguments from the 4NT Shell from JP Software
+set CMD_LINE_ARGS=%$
+
+:execute
+@rem Setup the command line
+
+set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
+
+@rem Execute Gradle
+"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS%
+
+:end
+@rem End local scope for the variables with windows NT shell
+if "%ERRORLEVEL%"=="0" goto mainEnd
+
+:fail
+rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
+rem the _cmd.exe /c_ return code!
+if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1
+exit /b 1
+
+:mainEnd
+if "%OS%"=="Windows_NT" endlocal
+
+:omega
diff --git a/media/MidiScope/screenshots/1-main.png b/media/MidiScope/screenshots/1-main.png
new file mode 100644
index 00000000..0b4fb8e8
--- /dev/null
+++ b/media/MidiScope/screenshots/1-main.png
Binary files differ
diff --git a/media/MidiScope/screenshots/2-signals.png b/media/MidiScope/screenshots/2-signals.png
new file mode 100644
index 00000000..7e4b443e
--- /dev/null
+++ b/media/MidiScope/screenshots/2-signals.png
Binary files differ
diff --git a/media/MidiScope/screenshots/icon-web.png b/media/MidiScope/screenshots/icon-web.png
new file mode 100644
index 00000000..6daec5cd
--- /dev/null
+++ b/media/MidiScope/screenshots/icon-web.png
Binary files differ
diff --git a/media/MidiScope/settings.gradle b/media/MidiScope/settings.gradle
new file mode 100644
index 00000000..0a5c310b
--- /dev/null
+++ b/media/MidiScope/settings.gradle
@@ -0,0 +1,2 @@
+
+include 'Application'
diff --git a/media/MidiScope/template-params.xml b/media/MidiScope/template-params.xml
new file mode 100644
index 00000000..8caea80e
--- /dev/null
+++ b/media/MidiScope/template-params.xml
@@ -0,0 +1,79 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ Copyright 2015 The Android Open Source Project
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+-->
+<sample>
+ <name>MidiScope</name>
+ <group>Media</group>
+ <package>com.example.android.midiscope</package>
+ <minSdk>23</minSdk>
+ <compileSdkVersion>23</compileSdkVersion>
+
+ <strings>
+ <intro>
+ <![CDATA[
+This sample demonstrates how to use the MIDI API to receive and process MIDI signals coming from an
+attached input device.
+ ]]>
+ </intro>
+ </strings>
+
+ <common src="midi"/>
+ <template src="base"/>
+
+ <metadata>
+ <status>PUBLISHED</status>
+ <categories>Media</categories>
+ <technologies>Android</technologies>
+ <languages>Java</languages>
+ <solutions>Mobile</solutions>
+ <level>INTERMEDIATE</level>
+ <icon>screenshots/icon-web.png</icon>
+ <screenshots>
+ <img>screenshots/1-main.png</img>
+ <img>screenshots/2-settings.png</img>
+ </screenshots>
+ <api_refs>
+ <android>android.media.midi.MidiManager</android>
+ <android>android.media.midi.MidiReceiver</android>
+ </api_refs>
+
+ <!-- 1-3 line description of the sample here.
+
+ Avoid simply rearranging the sample's title. What does this sample actually
+ accomplish, and how does it do it? -->
+ <description>
+ <![CDATA[
+Sample demonstrating how to use the MIDI API to receive and process MIDI signals coming from an
+attached device.
+ ]]>
+ </description>
+
+ <!-- Multi-paragraph introduction to sample, from an educational point-of-view.
+ Makrdown formatting allowed. This will be used to generate a mini-article for the
+ sample on DAC. -->
+ <intro>
+ <![CDATA[
+The Android MIDI API ([android.media.midi][1]) allows developers to connect a MIDI device to Android
+and process MIDI signals coming from it. This sample demonstrates some basic features of the MIDI
+API, such as enumeration of currently available devices (Information includes name, vendor,
+capabilities, etc), notification when MIDI devices are plugged in or unplugged, and receiving MIDI
+signals. This sample simply shows all the received MIDI signals to the screen log and does not play
+any sound for them.
+[1]: https://developer.android.com/reference/android/media/midi/package-summary.html
+ ]]>
+ </intro>
+ </metadata>
+</sample>