more example code posted

194 views
Skip to first unread message

Phil Burk

unread,
Oct 13, 2015, 7:29:49 PM10/13/15
to android-midi
I have posted a repository on GitHub with more Android MIDI examples.

  • The MidiTools folder contain general purpose MIDI classes that are used by the other Apps.
  • MidiScope displays MIDI Messages on the screen.
  • MidiKeyboard display a simple on-screen music keyboard.
  • MidiSynthExample is a simple sawtooth MIDI synthesizer.
  • MidiBtlePairing pairs with Bluetooth MIDI devices.
The apps are initially intended for OEMs to use for testing. So they use Android.mk files. I plan to split out individual programs into Android Studio programs.

You can use the code now with Android Studio but you will need to copy the files into an existing Android Studio project.


Pedro Lopez-Cabanillas

unread,
Oct 18, 2015, 5:08:29 PM10/18/15
to androi...@googlegroups.com
Hi Phil,

Great examples! Thanks!

Here is my contribution. Using the new Android 6 MIDI API, I've exposed the Sonivox EAS synth as a MIDI Service. https://github.com/pedrolcl/android/tree/master/NativeGMSynth

I've finished it this afternoon, and tested it very briefly with only an emulator, because I dont have yet a real device with Android 6. So sorry for the bugs and glitches. Pull requests are welcome :-)

Regards,
Pedro


--
You received this message because you are subscribed to the Google Groups "android-midi" group.
To unsubscribe from this group and stop receiving emails from it, send an email to android-midi...@googlegroups.com.
To post to this group, send email to androi...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/android-midi/642acf52-0e45-4f48-a8c7-755aff79f610%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Phil Burk

unread,
Oct 26, 2015, 9:35:09 PM10/26/15
to android-midi
Hello Pedro,

Sorry it took so long to respond. I was on vacation.

This NativeGMSynth looks really nice. I was hoping someone would do this. Great job.

I think a useful change would be to have an option to not open the input port on your synth service. Then other apps could open the port and use your synth. I forked a repo and may experiment with that this week if I get a chance.

Phil Burk


Allen Heidorn

unread,
Nov 18, 2015, 3:04:48 PM11/18/15
to android-midi
Hi Phil,

I'm trying to get a Unity app together for Android 6 and am running into some issues where I could use some help.
First, I think I have the MidiManager stuff hooked up, but am at the point where I need to test it with our BLE MIDI jamstik.

Is there a way (or an app) where I can connect the BLE-Midi device without writing that code myself so I can test?

I grabbed the android-midisuite example and did manage to get MidiBtlePairing to build (in Android Studio), but had to correct a few things.
First in MainActivity.java at the onActivityResult override:
          final BluetoothDevice fBluetoothDevice = (BluetoothDevice)data.getExtra("device") doesn't compile as 'getExtra' doesn't exist.
Did you mean to use data.getParcelableExtra("device")?

Once I made that change, it compiled and ran, but hitting the Scan Bluetooth button on a Nexus 9 device yielded a crash:
java.lang.NullPointerException: Attempt to invoke virtual method 'void android.app.ActionBar.setTitle(int)' on a null object reference

Am I overlooking something, perhaps I have issues with my setup, or is there an issue with the sample code before I start debugging it?

I also looked at the MIDI Scope code (yours and developer.android.com sample), but it won't connect a BLE peripheral.

https://developer.android.com/reference/android/media/midi/ states that  "MIDI devices can be connected to Android using Bluetooth LE.
Before using the device, the app must scan for available BTLE devices and then allow the user to connect. An example program will be provided so look for it on the Android developer website."

I've looked on the repository, but haven't seen anything that looks like it would help.

Thanks for any help you can give,
Allen

Phil Burk

unread,
Nov 24, 2015, 2:44:08 PM11/24/15
to android-midi
Hello Allen,


On Wednesday, November 18, 2015 at 12:04:48 PM UTC-8, Allen Heidorn wrote:
Is there a way (or an app) where I can connect the BLE-Midi device without writing that code myself so I can test?

Not yet. I am working on getting a pre-built app posted.
 
I grabbed the android-midisuite example and did manage to get MidiBtlePairing to build (in Android Studio), but had to correct a few things.
First in MainActivity.java at the onActivityResult override:
          final BluetoothDevice fBluetoothDevice = (BluetoothDevice)data.getExtra("device") doesn't compile as 'getExtra' doesn't exist.
Did you mean to use data.getParcelableExtra("device")?

Oops, yes. getExtra() is deprecated and hidden. it does the same as getParcelableExtra(). Thanks for catching that.
 
Once I made that change, it compiled and ran, but hitting the Scan Bluetooth button on a Nexus 9 device yielded a crash:
java.lang.NullPointerException: Attempt to invoke virtual method 'void android.app.ActionBar.setTitle(int)' on a null object reference

I don't think I call setTitle(). Is that in your code? Do you have a full stack trace for that exception?
 
Am I overlooking something, perhaps I have issues with my setup, or is there an issue with the sample code before I start debugging it?
I also looked at the MIDI Scope code (yours and developer.android.com sample), but it won't connect a BLE peripheral.

The BLE-MIDI peripheral has to be connected first.
 
https://developer.android.com/reference/android/media/midi/ states that  "MIDI devices can be connected to Android using Bluetooth LE.
Before using the device, the app must scan for available BTLE devices and then allow the user to connect. An example program will be provided so look for it on the Android developer website."

It is referring to the MidiBtlePairing app. Thanks for helping us get the kinks out.

Phil Burk


 

Phil Burk

unread,
Nov 24, 2015, 7:36:46 PM11/24/15
to android-midi
Oops, yes. getExtra() is deprecated and hidden. it does the same as getParcelableExtra(). Thanks for catching that.

 I posted a fix for this and another internal API reference at:

Reply all
Reply to author
Forward
0 new messages