Skip to content

Android midi driver using Sonivox EAS library

Notifications You must be signed in to change notification settings

ChinaWallace/mididriver

 
 

Repository files navigation

Midi Driver Build Status

Android midi driver using Sonivox EAS library. The app and library are available here.

Licensed under GPL or Apache license - your choice.

Do not use or build 64 bit versions of this native library as Google have included broken 64 bit versions of libsonivox.so in devices and at least one emulator. Do not include other 64 bit native libraries in your app as this appears not to work. See #15, #14, #11.

smarek has made a fork of the latest master, merging some of the features from the jhindin branch, and laid out for Gradle. I have merged this into the smarek branch.

The OpenSLES branch contains a purely native version of the driver using OpenSLES. This is an attempt to resolve the choppy sound issue reported by smarek. Now merged to master.

I have added a jhindin branch to this repository which is a merge of jhindin/mididriver. Do not use this branch as it is not up to date. He has made these changes:

  1. The source file tree has been rearranged to fit Android Studio/Gradle integration structure
  2. Linking with SoniVox library deferred to the launch time - in this way, there is no need to pull sonivox libraries from all potential platforms just to build the system

I have removed the event queue as per the comment by akdmia because it is no longer necessary. Contention is handled by using a mutex in the native code. I have only tested this with this app, not with an extended event stream. The app just has a couple of buttons that play a couple of piano notes when touched. I've added two more buttons that play and stop a midi file using the MediaPlayer to check that there is no interaction problem. Added a listener for sending initial midi messages when the midi driver has started. Removed the handler for the listener as the callback is not on a driver thread. This project may be compiled as a library by changing the setting in project.properties to android.library=true. The MainActivity.java source file will be moved to a temporary folder so it is not compiled into in the library jar file. I have made the changes in jhindin/mididriver without changing the project structure. Copies of the libsonivox.so library are no longer required.

To use this driver you need to:

  • Get and install the Android NDK toolkit.
  • Get the documentation and include files from android/platform_external_sonivox.
  • Adjust the ~jni/Application.mk to build the architecture(s) you want.
  • Don't build 64 bit versions as Google have included broken 64 bit versions of libsonivox.so in devices and at least one emulator.

Or you can just copy the libmidi.so file from here, but it has

Java_org_billthefarmer_mididriver_MidiDriver

embedded in the native method names.

The windows NDK toolkit doesn't appear to use anything other than standard windows shell commands and it's own tools, so you don't need Cygwin, despite what the docs say.

Methods

void start()  Start the driver. Call from onResume().

void stop()  Stop the driver. Call from onPause();

void addOnMidiStartListener(OnMidiStartListener l);

void queueEvent(byte[]) Send a midi message. This method now just
calls write()

Listener

void onMidiStart() This is called when the driver has started so
that program change messages, etc may be sent. This is now
somewhat redundant but has been left in.

Native Methods

boolean init()  Return true on success, or false on failure.

int[] config()  Return a four element array of ints with part of
the EAS onfig:

  config[0] = pLibConfig->maxVoices;
  config[1] = pLibConfig->numChannels;
  config[2] = pLibConfig->sampleRate;
  config[3] = pLibConfig->mixBufferSize;

boolean write(byte buffer[])  Writes midi data to the Sonivox
synthesizer. The length of the array should be the exact length of
the message or messages. Returns true on success, false on
failure.

boolean shutdown()  Shut down the synthesizer. Returns true on
success, false on failure.

About

Android midi driver using Sonivox EAS library

Resources

Stars

Watchers

Forks

Packages

No packages published

Languages

  • C 54.6%
  • Java 25.0%
  • C++ 19.4%
  • Makefile 1.0%