Giter Site home page Giter Site logo

usb-midi-driver's Introduction

Android USB MIDI Driver

Build Status Android Arsenal

USB MIDI Driver using Android USB Host API

  • No root privilege needed.
  • Supports the standard USB MIDI devices; like sequencers, or instruments.
  • Supports some non-standard USB MIDI (but protocol is compatible with USB MIDI) devices.
    • YAMAHA, Roland, MOTU, or other makers' devices listed on device_filter.xml can be connected.
  • Supports multiple device connections.
  • Has javax.sound.midi compatible classes.

Requirement

  • Android : OS version 3.1(API Level 12) or higher, and have an USB host port.
    • The android Linux kernel must support USB MIDI devices. Some Android device recognizes only USB-HID and USB-MSD by kernel configurations.
  • USB MIDI (compatible) device

the optional thing:

  • The self powered USB hub (if want to connect multiple USB MIDI devices).
  • USB OTG cable (if the Android device has no standard USB-A port).
  • USB MIDI <--> Lagacy MIDI(MIDI 1.0) converter cable (if want to connect with legacy MIDI instruments).

Repository Overview

  • Library Project : MIDIDriver

    • The driver for connecting an USB MIDI device.
  • Sample Project : MIDIDriverSample

    • The sample implementation of the synthesizer / MIDI event logger.
    • Pre-compiled sample project is available on Google Play Market.

Library Project Usages

See the project wiki for the library usages.

FAQ

  • What is the 'cable' argument of "onMidi..." or "sendMidi..." method?
    • A single USB MIDI endpoint has multiple "virtual MIDI cables". It's used for increasing the midi channels. The cable number's range is 0 to 15.
  • The application doesn't detect the device even if the USB MIDI device connected.

License

Apache License, Version 2.0

usb-midi-driver's People

Contributors

akapelrud avatar amitayd avatar chenzhang22 avatar kshoji avatar mmichler avatar motiz88 avatar regalstreak avatar rikner avatar victordiaz avatar willardvandelft avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

usb-midi-driver's Issues

high CPU usage problem

Hello,

I found high CPU usage problem in 'MIDIDriverSample' app with USB MIDI keyboard device.
Once go to home using home button, CPU usage become higher around 25~30%.
Hmm... Is this common issue?

Thanks

Send Midi Out through 5 channels

Hi i'm starting with your midi library, my issues are if i can load a midi file from assets and send thorugh usb/otg 5 midi channels ?

Can not receive onMidiNoteOn() event

Pre-compiled sample project (https://play.google.com/store/apps/details?id=jp.kshoji.driver.midi.sample) can receive all onMidiNoteOn() events.
But I clone sample project source files from Github, and compile it, this sample app seems to not able to receive all onMidiNoteOn() events.

おそらく、自分でコンパイルしたアプリは、onMidiNoteOff()イベントは全て取れているように見えます。 onMidiNoteOn()は鍵盤を複数同時に押した時のみ取れるようです。
鍵盤を押して、そのまま離した時はonMidiNoteOn()は取れずに、onMidiNoteOff()のみ取れます。

コンパイルに使ったソースは、今日cloneしたものです。

繋いでいるシンセは同じで、アプリだけダウンロードしたものとコンパイルしたもので比較して、onMidiNoteOn()の挙動が違うので、どこかでバグが入ったのではないかと思います。

Change APIs to without handling UsbDevice directly

  • Encapsulate UsbDevice into the inside of MidiInputDevice / MidiOutputDevice.
  • MidiDeviceConnectionWatcher treats all setups around UsbDevice connections and disconnections.
  • On attach / detach listeners, replace the argument from UsbDevice to MidiInputDevice / MidiOutputDevice.

Using raw source code -> Error

Hello,
I downloaded the project and copied the driver into a new Android-Project (Eclipse Luna),
like it is described in the wiki.

When i try to build the MIDIDriver I get a long list of errors.

Description Resource Path Location Type
The method onDeviceAttached(UsbDevice) from the type OnMidiDeviceAttachedListener is deprecated MidiDeviceConnectionWatcher.java /MIDIDriver/src/jp/kshoji/driver/midi/device line 181 Java Problem
The method onDeviceDetached(UsbDevice) from the type OnMidiDeviceDetachedListener is deprecated MidiDeviceConnectionWatcher.java /MIDIDriver/src/jp/kshoji/driver/midi/device line 70 Java Problem
LOLLIPOP cannot be resolved or is not a field UsbMidiDeviceUtils.java /MIDIDriver/src/jp/kshoji/driver/midi/util line 190 Java Problem
LOLLIPOP cannot be resolved or is not a field UsbMidiDeviceUtils.java /MIDIDriver/src/jp/kshoji/driver/midi/util line 219 Java Problem
The method getManufacturerName() is undefined for the type UsbDevice UsbMidiDeviceUtils.java /MIDIDriver/src/jp/kshoji/driver/midi/util line 220 Java Problem
The method getProductName() is undefined for the type UsbDevice UsbMidiDeviceUtils.java /MIDIDriver/src/jp/kshoji/driver/midi/util line 191 Java Problem
InvalidMidiDataException cannot be resolved to a type MidiMessage.java /MIDIDriver/src/jp/kshoji/javax/sound/midi line 16 Java Problem
InvalidMidiDataException cannot be resolved to a type SysexMessage.java /MIDIDriver/src/jp/kshoji/javax/sound/midi line 30 Java Problem
InvalidMidiDataException cannot be resolved to a type SysexMessage.java /MIDIDriver/src/jp/kshoji/javax/sound/midi line 40 Java Problem
InvalidMidiDataException cannot be resolved to a type SysexMessage.java /MIDIDriver/src/jp/kshoji/javax/sound/midi line 43 Java Problem
InvalidMidiDataException cannot be resolved to a type SysexMessage.java /MIDIDriver/src/jp/kshoji/javax/sound/midi line 56 Java Problem
InvalidMidiDataException cannot be resolved to a type SysexMessage.java /MIDIDriver/src/jp/kshoji/javax/sound/midi line 58 Java Problem
MidiSystem cannot be resolved UsbMidiSystem.java /MIDIDriver/src/jp/kshoji/javax/sound/midi line 81 Java Problem
MidiSystem cannot be resolved UsbMidiSystem.java /MIDIDriver/src/jp/kshoji/javax/sound/midi line 85 Java Problem
MidiSystem cannot be resolved UsbMidiSystem.java /MIDIDriver/src/jp/kshoji/javax/sound/midi line 96 Java Problem
MidiSystem cannot be resolved UsbMidiSystem.java /MIDIDriver/src/jp/kshoji/javax/sound/midi line 100 Java Problem
MidiSystem cannot be resolved UsbMidiSystem.java /MIDIDriver/src/jp/kshoji/javax/sound/midi line 123 Java Problem
MidiSystem cannot be resolved UsbMidiSystem.java /MIDIDriver/src/jp/kshoji/javax/sound/midi line 141 Java Problem
ShortMessage cannot be resolved to a variable SysexMessage.java /MIDIDriver/src/jp/kshoji/javax/sound/midi line 13 Java Problem
ShortMessage cannot be resolved to a variable SysexMessage.java /MIDIDriver/src/jp/kshoji/javax/sound/midi line 13 Java Problem
ShortMessage cannot be resolved to a variable SysexMessage.java /MIDIDriver/src/jp/kshoji/javax/sound/midi line 42 Java Problem
ShortMessage cannot be resolved to a variable SysexMessage.java /MIDIDriver/src/jp/kshoji/javax/sound/midi line 42 Java Problem
ShortMessage cannot be resolved to a variable SysexMessage.java /MIDIDriver/src/jp/kshoji/javax/sound/midi line 57 Java Problem
ShortMessage cannot be resolved to a variable SysexMessage.java /MIDIDriver/src/jp/kshoji/javax/sound/midi line 57 Java Problem
The method setMessage(byte[], int) from the type MidiMessage refers to the missing type InvalidMidiDataException SysexMessage.java /MIDIDriver/src/jp/kshoji/javax/sound/midi line 45 Java Problem
The method setMessage(byte[], int) from the type SysexMessage refers to the missing type InvalidMidiDataException SysexMessage.java /MIDIDriver/src/jp/kshoji/javax/sound/midi line 32 Java Problem
Info cannot be resolved to a type UsbMidiDevice.java /MIDIDriver/src/jp/kshoji/javax/sound/midi/usb line 65 Java Problem
Info cannot be resolved to a type UsbMidiDevice.java /MIDIDriver/src/jp/kshoji/javax/sound/midi/usb line 79 Java Problem
InvalidMidiDataException cannot be resolved to a type UsbMidiTransmitter.java /MIDIDriver/src/jp/kshoji/javax/sound/midi/usb line 81 Java Problem
InvalidMidiDataException cannot be resolved to a type UsbMidiTransmitter.java /MIDIDriver/src/jp/kshoji/javax/sound/midi/usb line 94 Java Problem
InvalidMidiDataException cannot be resolved to a type UsbMidiTransmitter.java /MIDIDriver/src/jp/kshoji/javax/sound/midi/usb line 107 Java Problem
InvalidMidiDataException cannot be resolved to a type UsbMidiTransmitter.java /MIDIDriver/src/jp/kshoji/javax/sound/midi/usb line 120 Java Problem
InvalidMidiDataException cannot be resolved to a type UsbMidiTransmitter.java /MIDIDriver/src/jp/kshoji/javax/sound/midi/usb line 133 Java Problem
InvalidMidiDataException cannot be resolved to a type UsbMidiTransmitter.java /MIDIDriver/src/jp/kshoji/javax/sound/midi/usb line 146 Java Problem
InvalidMidiDataException cannot be resolved to a type UsbMidiTransmitter.java /MIDIDriver/src/jp/kshoji/javax/sound/midi/usb line 159 Java Problem
InvalidMidiDataException cannot be resolved to a type UsbMidiTransmitter.java /MIDIDriver/src/jp/kshoji/javax/sound/midi/usb line 172 Java Problem
InvalidMidiDataException cannot be resolved to a type UsbMidiTransmitter.java /MIDIDriver/src/jp/kshoji/javax/sound/midi/usb line 185 Java Problem
InvalidMidiDataException cannot be resolved to a type UsbMidiTransmitter.java /MIDIDriver/src/jp/kshoji/javax/sound/midi/usb line 198 Java Problem
InvalidMidiDataException cannot be resolved to a type UsbMidiTransmitter.java /MIDIDriver/src/jp/kshoji/javax/sound/midi/usb line 211 Java Problem
InvalidMidiDataException cannot be resolved to a type UsbMidiTransmitter.java /MIDIDriver/src/jp/kshoji/javax/sound/midi/usb line 224 Java Problem
MetaMessage cannot be resolved to a type UsbMidiReceiver.java /MIDIDriver/src/jp/kshoji/javax/sound/midi/usb line 46 Java Problem
MetaMessage cannot be resolved to a type UsbMidiReceiver.java /MIDIDriver/src/jp/kshoji/javax/sound/midi/usb line 47 Java Problem
MetaMessage cannot be resolved to a type UsbMidiReceiver.java /MIDIDriver/src/jp/kshoji/javax/sound/midi/usb line 47 Java Problem
MidiDevice cannot be resolved to a type UsbMidiDevice.java /MIDIDriver/src/jp/kshoji/javax/sound/midi/usb line 28 Java Problem
MidiDevice cannot be resolved to a type UsbMidiReceiver.java /MIDIDriver/src/jp/kshoji/javax/sound/midi/usb line 112 Java Problem
MidiDevice cannot be resolved to a type UsbMidiTransmitter.java /MIDIDriver/src/jp/kshoji/javax/sound/midi/usb line 69 Java Problem
MidiDeviceReceiver cannot be resolved to a type UsbMidiReceiver.java /MIDIDriver/src/jp/kshoji/javax/sound/midi/usb line 20 Java Problem
MidiDeviceTransmitter cannot be resolved to a type UsbMidiTransmitter.java /MIDIDriver/src/jp/kshoji/javax/sound/midi/usb line 23 Java Problem
MidiUnavailableException cannot be resolved to a type UsbMidiDevice.java /MIDIDriver/src/jp/kshoji/javax/sound/midi/usb line 58 Java Problem
MidiUnavailableException cannot be resolved to a type UsbMidiDevice.java /MIDIDriver/src/jp/kshoji/javax/sound/midi/usb line 86 Java Problem
MidiUnavailableException cannot be resolved to a type UsbMidiDevice.java /MIDIDriver/src/jp/kshoji/javax/sound/midi/usb line 149 Java Problem
MidiUnavailableException cannot be resolved to a type UsbMidiDevice.java /MIDIDriver/src/jp/kshoji/javax/sound/midi/usb line 169 Java Problem
Receiver cannot be resolved to a type UsbMidiDevice.java /MIDIDriver/src/jp/kshoji/javax/sound/midi/usb line 30 Java Problem
Receiver cannot be resolved to a type UsbMidiDevice.java /MIDIDriver/src/jp/kshoji/javax/sound/midi/usb line 30 Java Problem
Receiver cannot be resolved to a type UsbMidiDevice.java /MIDIDriver/src/jp/kshoji/javax/sound/midi/usb line 47 Java Problem
Receiver cannot be resolved to a type UsbMidiDevice.java /MIDIDriver/src/jp/kshoji/javax/sound/midi/usb line 73 Java Problem
Receiver cannot be resolved to a type UsbMidiDevice.java /MIDIDriver/src/jp/kshoji/javax/sound/midi/usb line 91 Java Problem
Receiver cannot be resolved to a type UsbMidiDevice.java /MIDIDriver/src/jp/kshoji/javax/sound/midi/usb line 91 Java Problem
Receiver cannot be resolved to a type UsbMidiDevice.java /MIDIDriver/src/jp/kshoji/javax/sound/midi/usb line 118 Java Problem
Receiver cannot be resolved to a type UsbMidiDevice.java /MIDIDriver/src/jp/kshoji/javax/sound/midi/usb line 118 Java Problem
Receiver cannot be resolved to a type UsbMidiDevice.java /MIDIDriver/src/jp/kshoji/javax/sound/midi/usb line 121 Java Problem
Receiver cannot be resolved to a type UsbMidiDevice.java /MIDIDriver/src/jp/kshoji/javax/sound/midi/usb line 139 Java Problem
Receiver cannot be resolved to a type UsbMidiDevice.java /MIDIDriver/src/jp/kshoji/javax/sound/midi/usb line 149 Java Problem
Receiver cannot be resolved to a type UsbMidiDevice.java /MIDIDriver/src/jp/kshoji/javax/sound/midi/usb line 150 Java Problem
Receiver cannot be resolved to a type UsbMidiDevice.java /MIDIDriver/src/jp/kshoji/javax/sound/midi/usb line 150 Java Problem
Receiver cannot be resolved to a type UsbMidiDevice.java /MIDIDriver/src/jp/kshoji/javax/sound/midi/usb line 160 Java Problem
Receiver cannot be resolved to a type UsbMidiDevice.java /MIDIDriver/src/jp/kshoji/javax/sound/midi/usb line 161 Java Problem
Receiver cannot be resolved to a type UsbMidiDevice.java /MIDIDriver/src/jp/kshoji/javax/sound/midi/usb line 161 Java Problem
Receiver cannot be resolved to a type UsbMidiDevice.java /MIDIDriver/src/jp/kshoji/javax/sound/midi/usb line 162 Java Problem
Receiver cannot be resolved to a type UsbMidiDevice.java /MIDIDriver/src/jp/kshoji/javax/sound/midi/usb line 228 Java Problem
Receiver cannot be resolved to a type UsbMidiDevice.java /MIDIDriver/src/jp/kshoji/javax/sound/midi/usb line 230 Java Problem
Receiver cannot be resolved to a type UsbMidiDevice.java /MIDIDriver/src/jp/kshoji/javax/sound/midi/usb line 241 Java Problem
Receiver cannot be resolved to a type UsbMidiDevice.java /MIDIDriver/src/jp/kshoji/javax/sound/midi/usb line 242 Java Problem
Receiver cannot be resolved to a type UsbMidiDevice.java /MIDIDriver/src/jp/kshoji/javax/sound/midi/usb line 242 Java Problem
Receiver cannot be resolved to a type UsbMidiDevice.java /MIDIDriver/src/jp/kshoji/javax/sound/midi/usb line 254 Java Problem
Receiver cannot be resolved to a type UsbMidiTransmitter.java /MIDIDriver/src/jp/kshoji/javax/sound/midi/usb line 27 Java Problem
Receiver cannot be resolved to a type UsbMidiTransmitter.java /MIDIDriver/src/jp/kshoji/javax/sound/midi/usb line 43 Java Problem
Receiver cannot be resolved to a type UsbMidiTransmitter.java /MIDIDriver/src/jp/kshoji/javax/sound/midi/usb line 44 Java Problem
Receiver cannot be resolved to a type UsbMidiTransmitter.java /MIDIDriver/src/jp/kshoji/javax/sound/midi/usb line 49 Java Problem
Receiver cannot be resolved to a type UsbMidiTransmitter.java /MIDIDriver/src/jp/kshoji/javax/sound/midi/usb line 50 Java Problem
Receiver cannot be resolved to a type UsbMidiTransmitter.java /MIDIDriver/src/jp/kshoji/javax/sound/midi/usb line 76 Java Problem
Receiver cannot be resolved to a type UsbMidiTransmitter.java /MIDIDriver/src/jp/kshoji/javax/sound/midi/usb line 80 Java Problem
Receiver cannot be resolved to a type UsbMidiTransmitter.java /MIDIDriver/src/jp/kshoji/javax/sound/midi/usb line 89 Java Problem
Receiver cannot be resolved to a type UsbMidiTransmitter.java /MIDIDriver/src/jp/kshoji/javax/sound/midi/usb line 93 Java Problem
Receiver cannot be resolved to a type UsbMidiTransmitter.java /MIDIDriver/src/jp/kshoji/javax/sound/midi/usb line 102 Java Problem
Receiver cannot be resolved to a type UsbMidiTransmitter.java /MIDIDriver/src/jp/kshoji/javax/sound/midi/usb line 106 Java Problem
Receiver cannot be resolved to a type UsbMidiTransmitter.java /MIDIDriver/src/jp/kshoji/javax/sound/midi/usb line 115 Java Problem
Receiver cannot be resolved to a type UsbMidiTransmitter.java /MIDIDriver/src/jp/kshoji/javax/sound/midi/usb line 119 Java Problem
Receiver cannot be resolved to a type UsbMidiTransmitter.java /MIDIDriver/src/jp/kshoji/javax/sound/midi/usb line 128 Java Problem
Receiver cannot be resolved to a type UsbMidiTransmitter.java /MIDIDriver/src/jp/kshoji/javax/sound/midi/usb line 132 Java Problem
Receiver cannot be resolved to a type UsbMidiTransmitter.java /MIDIDriver/src/jp/kshoji/javax/sound/midi/usb line 141 Java Problem
Receiver cannot be resolved to a type UsbMidiTransmitter.java /MIDIDriver/src/jp/kshoji/javax/sound/midi/usb line 145 Java Problem
Receiver cannot be resolved to a type UsbMidiTransmitter.java /MIDIDriver/src/jp/kshoji/javax/sound/midi/usb line 154 Java Problem
Receiver cannot be resolved to a type UsbMidiTransmitter.java /MIDIDriver/src/jp/kshoji/javax/sound/midi/usb line 158 Java Problem
Receiver cannot be resolved to a type UsbMidiTransmitter.java /MIDIDriver/src/jp/kshoji/javax/sound/midi/usb line 167 Java Problem
Receiver cannot be resolved to a type UsbMidiTransmitter.java /MIDIDriver/src/jp/kshoji/javax/sound/midi/usb line 171 Java Problem
Receiver cannot be resolved to a type UsbMidiTransmitter.java /MIDIDriver/src/jp/kshoji/javax/sound/midi/usb line 180 Java Problem
Receiver cannot be resolved to a type UsbMidiTransmitter.java /MIDIDriver/src/jp/kshoji/javax/sound/midi/usb line 184 Java Problem
Receiver cannot be resolved to a type UsbMidiTransmitter.java /MIDIDriver/src/jp/kshoji/javax/sound/midi/usb line 193 Java Problem
Receiver cannot be resolved to a type UsbMidiTransmitter.java /MIDIDriver/src/jp/kshoji/javax/sound/midi/usb line 197 Java Problem

Can't find a onMidiInEvent

Hi,

There are a lot of specific midi in events, but I would like a generic one such as onMidiIn(int status, int data1, int data2). I have central midi manager on my apps, and they are all cross platform. In desktop and windows, the midi in callback gives me status, data1 and data2.

Is there any general midiIn callback that I'm not seeing?

Thanks,

Regards,

Nuno

How to get usb midi device product name?

Hi,

I cannot find a way of getting product device name without consulting the usb descriptors. Am I missing something? In case you don't have support for this I have a fix suggestion.

Looking forward to hear something from you.

Regards,

Nuno

Suppress mis-detection as USB Audio.

Some Android devices treat USB MIDI devices as USB Audio devices.
When such Android device attaches USB MIDI device, USB Audio will be selected as the audio output source.
As the result, sound playing will be stopped.

sequencer.start() method not generating any sound in Android application.

i made a sequencer object as follows
sequencer = MidiSystem.getSequencer();
than open it using open method
sequencer.open();
than i tried to set a sequence and start the sequencer,
InputStream inputStream = getResources().openRawResource(R.raw.airtel_new);
sequence = MidiSystem.getSequence(inputStream);

        sequencer.setSequence(sequence);
        sequencer.start();

But it does not produce any sound in my android application.

Build on Nexus 10 - Android 5.0.2 - Crash when run.

Hi

I forked, cloned, compiled the project (I pulled in the 'missing' javax midi source files from your other repository).

When running the compiled app I see the header on screen (midi driver single...), but it then crashes.

LogCat says...
singlesampleactivity... resoruce not found... res/drawable-xhdpi-v4/ic_launcher.png from xml type xml...

it also says corrupt xml binary file
and
xml block header size.... larger than data size 11449

From the playstore the app works fine...

I copied the xhdpi diretory to xhpdi-v4, this made no difference, the png looks fine opened in a graphics prog.

Any Ideas? Cheers!

It doesn't compile in Android Studio 0.8.1

I first updated gradle to 0.12+ but still I get

Error:FAILURE: Build failed with an exception.

  • What went wrong:
    Task 'assemble' not found in root project 'USB-MIDI-Driver'.
  • Try:
    Run gradle tasks to get a list of available tasks. Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.

Audio stops when USB midi device is connected

I'm building a synthesiser app and I'm having an issue while integratin USB-MIDI-Driver. As soon as I plug the midi device, the audio stops.

The midi devices are detected and the midi signal comes in, but no audio comes out after that moment.

Is this a know issue? Am I missing something?

Add some utility methods on Input/Output device class

MidiInputDevice

Add some methods to listener, to receive ActiveSensing, Start, SongSelect etc. messages.
(Existing method onMidiSingleByte or onMidiSystemCommonMessage are also called for the compatibility)

MidiOutputDevice

Add methods to send some kinds of message directly; like sendMidiActiveSensing, sendMidiStart, sendMidiSongSelect etc.
They call sendMidiSingleByte or sendMidiSystemCommonMessage methods.

adding and using the library as jar devicefilter issue

Hi,
I've made a jar file as described in
https://github.com/kshoji/USB-MIDI-Driver/wiki/Extracting-a-jar-package-from-the-library-archive

But Done the first step beneath. But that last one i don't quite get.
There is a classes.jar file. It will be put on the project's lib directory.
I recommend to rename from classes.jar to midi-driver.jar.
There is a res/xml/device_filter.xml file. It will be put on the project's same path.

So when testing it out, i get a no class found def error for jp.kshoji.driver.midi.R$xml
in the device filter
I think it has troble finding the device_filter_xml as you do import jp.kshoji.driver.midi.R where it's part of.

04-24 17:34:26.411: E/AndroidRuntime(2484): FATAL EXCEPTION: main 04-24 17:34:26.411: E/AndroidRuntime(2484): Process: com.example.miditest, PID: 2484 04-24 17:34:26.411: E/AndroidRuntime(2484): java.lang.NoClassDefFoundError: jp.kshoji.driver.midi.R$xml 04-24 17:34:26.411: E/AndroidRuntime(2484): at jp.kshoji.driver.usb.util.DeviceFilter.getDeviceFilters(DeviceFilter.java:65) 04-24 17:34:26.411: E/AndroidRuntime(2484): at jp.kshoji.driver.midi.device.MidiDeviceConnectionWatcher$MidiDeviceConnectionWatchThread.(MidiDeviceConnectionWatcher.java:261) 04-24 17:34:26.411: E/AndroidRuntime(2484): at jp.kshoji.driver.midi.device.MidiDeviceConnectionWatcher.(MidiDeviceConnectionWatcher.java:125) 04-24 17:34:26.411: E/AndroidRuntime(2484): at jp.kshoji.driver.midi.activity.AbstractSingleMidiActivity.onCreate(AbstractSingleMidiActivity.java:129) 04-24 17:34:26.411: E/AndroidRuntime(2484): at com.example.miditest.MainActivity.onCreate(MainActivity.java:40) 04-24 17:34:26.411: E/AndroidRuntime(2484): at android.app.Activity.performCreate(Activity.java:5231) 04-24 17:34:26.411: E/AndroidRuntime(2484): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1087) 04-24 17:34:26.411: E/AndroidRuntime(2484): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2169) 04-24 17:34:26.411: E/AndroidRuntime(2484): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2271) 04-24 17:34:26.411: E/AndroidRuntime(2484): at android.app.ActivityThread.access$800(ActivityThread.java:144) 04-24 17:34:26.411: E/AndroidRuntime(2484): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1205) 04-24 17:34:26.411: E/AndroidRuntime(2484): at android.os.Handler.dispatchMessage(Handler.java:102) 04-24 17:34:26.411: E/AndroidRuntime(2484): at android.os.Looper.loop(Looper.java:136) 04-24 17:34:26.411: E/AndroidRuntime(2484): at android.app.ActivityThread.main(ActivityThread.java:5146) 04-24 17:34:26.411: E/AndroidRuntime(2484): at java.lang.reflect.Method.invokeNative(Native Method) 04-24 17:34:26.411: E/AndroidRuntime(2484): at java.lang.reflect.Method.invoke(Method.java:515) 04-24 17:34:26.411: E/AndroidRuntime(2484): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:732) 04-24 17:34:26.411: E/AndroidRuntime(2484): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:566) 04-24 17:34:26.411: E/AndroidRuntime(2484): at dalvik.system.NativeStart.main(Native Method)

Can you help me out? WFR

Detect number of available cables?

Hi Kaoru
Is there any way to detect the number of available cables a midi interface provides?
The ESI Midimate II (USB to DIN MIDI interface) provides 2 cables, and the MidiInputDevice properly reports from which cable the input is coming.

But how do I know inside the application, how many cables are available to send MIDI messages out?

Thanks in advance
Andreas

javax.sound.midi issues

  • MidiSystem.getReceiver method returns unopened Receiver.
  • Sequencer won't play correctly with solo/mute setting.

Refine RPN/NRPN codes

  • The function number don't process correctly
  • The value should be cached with key, function number.
  • Move the method MidiInputDevice.processRpnMessages to inline.

sending sysex messages hangs the whole midi interconnection

Thanks a lot for the usb-midi-driver - it's the amazing lib!

Here's the issue - I'm trying to get patches info from line 6 pocket pod.
If invoke "getMidiOutputDevice().sendMidiSystemExclusive(0, data);" (where data is " {0x00, 0x01, 0x0C, 0x01, 0x00, 0x01, (byte) 0xF7}") the simple app hangs until the usb cable (connecting a midi device) is unplugged.

The complete sysex message is "F0 00 01 0C 01 00 00 preset# F7"; sending it as sendMidiSystemCommonMessage doesn't hangs anything but seems to fail in getting any response from the device though.

What do you think about that? Are there any trick/hints for sysex usage?

Note-off is not sent by keyboard

On my keyboard (Yamaha YPR-9), note-off events are not sent. Instead, it sends a note-on event with a velocity of 0. Receiving note-off events does note seem to be a problem for it. A fix for this seems to be making the following change to jp.kshoji.driver.midi.handler.MidiMessageCallback.java:

From:

case 9:
    midiEventListener.onMidiNoteOn(sender, cable, byte1 & 0xf, byte2, byte3);
    break;

to

case 9:
    if (byte3 == 0x00) {
        midiEventListener.onMidiNoteOff(sender, cable, byte1 & 0xf, byte2, byte3);
    } else {
        midiEventListener.onMidiNoteOn(sender, cable, byte1 & 0xf, byte2, byte3);
    }
    break;

sometimes midi note skipped.

Hello,

I found sometimes midi notes are skipped & applications coudn't catch it, you can refer logs as below.
In my test result, not happens when I sync USB-MIDI-Driver until Jan 22, 2013.
It was tested with sample apk and "KORG nanoKEY2" as usb midi keyboard.

Thranks.

logs:
D/MIDIDriver(4482): Input:[9, -112, 96, 110, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]
//<-- missed

D/MIDIDriver(4482): Input:[9, -112, 95, 110, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]
D/MIDIDriver(4482): Input:[8, -128, 95, 64, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]

D/MIDIDriver(4482): Input:[9, -112, 93, 110, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]
D/MIDIDriver(4482): Input:[8, -128, 93, 64, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]

D/MIDIDriver(4482): Input:[9, -112, 91, 110, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]
//<-- missed

D/MIDIDriver(4482): Input:[9, -112, 89, 118, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]
//<-- missed

D/MIDIDriver(4482): Input:[9, -112, 88, 118, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]
//<-- missed

D/MIDIDriver(4482): Input:[9, -112, 86, 118, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]
D/MIDIDriver(4482): Input:[8, -128, 86, 64, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]

D/MIDIDriver(4482): Input:[9, -112, 84, 127, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]
D/MIDIDriver(4482): Input:[8, -128, 84, 64, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]

Class which implements UsbMidiDriver outside the activity returns getconnectedusbdevices 0

To not have all the necessary methods of the UsbMidiDriver inside my MainActivity,
I decided to make a class outside the mainActivity which implements the UsbMidiDriver.

In the MainActivity, i still do the open() in the oncreate() and close() in the ondestroy().
In the UsbMidiDriver implementation I keep a set of usbdevices, which the device should be added to when onattached... is called.
But anyway the superclass allready provides a method to get these.

Either way, if i call the methods to retrieve the usbdevices, it's empty. Although during startup of my application, the logging implemented by you still states that my device has been attached.

I did allready had a proper positive communication test by using the AbstractSingleMidiActivity

This is the code of the Main Activity:

import java.util.ArrayList;
import java.util.HashSet;
import java.util.Iterator;
import java.util.List;
import java.util.Set;

import jp.kshoji.driver.midi.device.MidiDeviceConnectionWatcher;
import jp.kshoji.driver.midi.device.MidiOutputDevice;
import android.app.Activity;
import android.hardware.usb.UsbDevice;
import android.os.Bundle;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;

public class MainActivity extends Activity {
    private AndroidMidiCommunicator usbMidiDriver;
    private Set<UsbDevice> usbDevices = new HashSet<UsbDevice>();

    public void test(View v) {
//      System.out.println("productname :" + getMidiOutputDevice().getDeviceAddress());

        byte[] identityReqByte = new byte[] { (byte) 0xf0, 0x7e, 0x7f,
                0x06, 0x01, (byte) 0xf7 };
        usbDevices = usbMidiDriver.getConnectedUsbDevices();
        //or usbMidiDriver.getUsbDevices();  (own set in the AndroidMidiCommunicator)

        Iterator<UsbDevice> usbDeviceIterator = usbDevices.iterator();
        if (usbDeviceIterator.hasNext()) {
            Set<MidiOutputDevice> midiOutputDevices = usbMidiDriver.getMidiOutputDevices(usbDeviceIterator.next());
            List<MidiOutputDevice> midiOutputDeviceList = new ArrayList<MidiOutputDevice>();
            midiOutputDeviceList.addAll(midiOutputDevices);
            if (midiOutputDeviceList.size() > 0) {
                midiOutputDeviceList.get(0).sendMidiSystemExclusive(0, identityReqByte);
            }else{
                System.out.println("size is 0");
            }
        }else{
            System.out.println("no usb devices");
        }


    }
//  public void testgetdevicename(){
//      System.out.println("productname :" + midiOutputDevice.getDeviceAddress());
//
//  }

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
         usbMidiDriver = new AndroidMidiCommunicator(this);
         usbMidiDriver.open();
    }

    @Override
    public boolean onCreateOptionsMenu(Menu menu) {
        // Inflate the menu; this adds items to the action bar if it is present.
        getMenuInflater().inflate(R.menu.main, menu);
        return true;
    }

    @Override
    public boolean onOptionsItemSelected(MenuItem item) {
        // Handle action bar item clicks here. The action bar will
        // automatically handle clicks on the Home/Up button, so long
        // as you specify a parent activity in AndroidManifest.xml.
        int id = item.getItemId();
        if (id == R.id.action_settings) {
            return true;
        }
        return super.onOptionsItemSelected(item);
    }
    @Override
    protected void onDestroy() {
        super.onDestroy();
         usbMidiDriver.close();
    }
}

In the AndroidMidiCommunicator, i just do:

@Override
    public void onDeviceAttached(UsbDevice usbDevice) {
         synchronized (usbDevices) {
             usbDevices.add(usbDevice);
         }  
         System.out.println("device has been added");
    }

ANR exception thrown at MidiOutputDevice.sendMidiMessage

Reported stacktrace is like this:

DALVIK THREADS:
(mutexes: tll=0 tsl=0 tscl=0 ghl=0)
"main" prio=5 tid=1 SUSPENDED
  | group="main" sCount=1 dsCount=0 obj=0x409e2460 self=0x12800
  | sysTid=1178 nice=0 sched=0/0 cgrp=[fopen-error:2] handle=1074148488
  | schedstat=( 2880000000 6390000000 4022 ) utm=178 stm=110 core=0
  at android.hardware.usb.UsbRequest.native_queue_array(Native Method)
  at android.hardware.usb.UsbRequest.queue(UsbRequest.java:141)
  at jp.kshoji.driver.midi.device.MidiOutputDevice.sendMidiMessage
(MidiOutputDevice.java:108)
  at jp.kshoji.driver.midi.device.MidiOutputDevice.sendMidiNoteOn
(MidiOutputDevice.java:281)

trying to send this sysex message for example

hi, this is the sysex message i'm trying to send using MidiSystemExclusive,

found a bug that sysex over 3 bytes isn't transferred

F0 7F 7F 04 04 00 3F F7

this is a 8 bytes sysex , and i think you don't cover it under your code, am i correct

however, with this one, 3 bytes message ,i can send and see it comes on my computer midi in
F0 7F F7

seems that the api is limited for maximum 3 bytes message, which is not good, need to fix
thanks for helping

Why is sendMidiMessage private?

Hi,

First of all I would like to give you my props for this work.

I would like to ask you something. I understand that you wanted to provide a complete API for the most diverse type of midi messages, but, why keep sendMidiMessage private? If this was public, one could send midi straight ahead with cases, just by filling the parameters.

public void sendMidiMessage(int codeIndexNumber, int cable, int byte1, int byte2, int byte3);

I have been using RtMidi on desktop and PGMidi for iOS and they all make use of send midi with just three parameters. I think this freedom would greatly enhance the usability of the API.

By the way, what is cable? I can't figure it out. Can you explain me?

Thanks,

Regards,

Nuno Santos

sendmidicontrolchange not working

Hi

I'm working with the roland UM One MK3
You know it has the lights for indicating an outgoing or incoming message. So to see it 4 times going off, i set some "timertasks".
I see the lights going off 4 times, but the message is not interpreted by the synth, making me think, that there's something wrong with the sendmidicontrolchange method.
In the mean time i'm going to see if i can send it with sysex in stead.

if (midiOutputDeviceList.size() > 0) {
midiOutputDeviceList.get(0).sendMidiControlChange(0, 1, 80, 0);
handler.postDelayed(new Runnable(){
@OverRide
public void run() {
midiOutputDeviceList.get(0).sendMidiControlChange(0, 1, 80, 127);
};},200);
handler.postDelayed(new Runnable(){
@OverRide
public void run() {
midiOutputDeviceList.get(0).sendMidiControlChange(0, 1, 82, 0);
};},300);
handler.postDelayed(new Runnable(){
@OverRide
public void run() {
midiOutputDeviceList.get(0).sendMidiControlChange(0, 1, 82, 127);
};},400);

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.