Skip to content

How to setup the library to the application

Mathieu Bosi edited this page Jul 18, 2017 · 4 revisions

Instructions for using the library.

Setup the project

Using raw source code:

  • Clone the library. Execute git clone https://github.com/kshoji/USB-MIDI-Driver on the terminal.
  • Import the library project into Eclipse workspace or Android Studio, and build it.
  • Create new Android Project.
  • Add the library project to the project.

Using maven:

  • Edit the project's pom.xml file
    • Add a repository setting.
    • Add a dependency.
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>

    <distributionManagement>
        <repository>
            <id>repo</id>
            <url>https://github.com/kshoji/USB-MIDI-Driver/raw/master/MIDIDriver/snapshots</url>
        </repository>
    </distributionManagement>
    <dependencies>
        <dependency>
            <groupId>jp.kshoji</groupId>
            <artifactId>midi-driver</artifactId>
            <version>0.1.4</version><!-- check the latest release version with https://github.com/kshoji/USB-MIDI-Driver/releases/latest -->
            <type>aar</type>
        </dependency>
        :
        :
    </dependencies>
    :
    :
</project>

Using Gradle(Android Studio):

  • Edit the project's build.gradle file
    • Add a repository setting.
    • Add a dependency.
repositories {
    maven {
        url 'https://github.com/kshoji/USB-MIDI-Driver/raw/master/MIDIDriver/snapshots'
    }
    mavenCentral()
}

dependencies {
    // check the latest release version with https://github.com/kshoji/USB-MIDI-Driver/releases/latest
    compile 'jp.kshoji:midi-driver:0.1.4:@aar'
}

Create an Activity class

  • Override AbstractSingleMidiActivity or AbstractMultipleMidiActivity.
    • AbstractSingleMidiActivity can connect only one MIDI device.
    • AbstractMultipleMidiActivity can connect multiple MIDI devices.
      • NOTE: The performance problem (slow latency or high CPU/memory usage) may occur if many devices have been connected.
    • If the Activity already extended another Activity class, UsbMidiDriver class will be used. See the document.

Modify the AndroidManifest.xml

  • Add "uses-feature" tag to use USB Host feature.
  • Activity's launchMode must be "singleTask".
<uses-feature android:name="android.hardware.usb.host" /> 

<application>
    <activity
        android:name=".MyMidiMainActivity"
        android:label="@string/app_name"
        android:launchMode="singleTask" >
        <intent-filter>
            <category android:name="android.intent.category.LAUNCHER" />
            <action android:name="android.intent.action.MAIN" />
        </intent-filter>
    </activity>
    :