I’m developing a MIDI sequencer for Android devices, to create the graphic interface I obtained excellent results using the Processing framework inside Android Studio.
Currently the sequencer is set up to control 16 steps for 16 channels and is designed to generate polyrhythm by reducing the number of steps for each channel.
In the future I want to implement it with different generative algorithms to generate variations of the patterns.
There are 8 patterns that can be interchanged every 4 beats. At the beginning I was trying to complete the project exclusively with Processing, but the lack of a compatible MIDI library (midibus) inside of Processing forced me to rewrite the project within Android Studio.
Unfortunately, my skills do not allow me to implement the MIDI output port in Android Studio as described by Android.media.midi. I also hear about a c ++ framework: superpowered that would probably make the application even more professional with less latency.
If there is the possibility of continuing the project on processing please say me.
I am looking for a partner who is interested in the project and who can enter the project to help me complete it and from which I can learn what it takes to interface with a MIDI device via android.
I can propose and expect code highly commented to arrive at the result, probably the best place for this project is github but it is not essential, I can share my entire work of which I show this screen shot of the current responsive interface.
@chanof
I have also written a sequencer using Processing but as yet don’t have midi … I hope to do it soon so I could be interested in collaborating …
I am thinking though of writing my own code to make use of the Android sdk … no libraries as they seem to get out of date too quickly when Processing gets updated
Hi shedMusic! do you mean midi processing library? I never found anyone who is compatible inside android, by moving to android studio i think android.media.midi is the right way, i hope that is possible to crate a condition like if the button is on and is blinking (the play point is on it) send a midi noteOn, however I’m unable to cross from native processing code to this API.
my e-mail is chanof@hotmail.com
Just a very brief start to show you how I’m getting started … just a quick test to see how to go about importing android.media.midi, and a simple test that the phone/tablet supports MIDI.
More tomorrow … need to get an OTG cable to plug something in!
import android.app.Activity;
import android.content.Context;
import android.media.midi.* ;
import android.content.pm.PackageManager ;
Activity act;
Context context;
MidiManager m ;
void setup() {
act = this.getActivity();
context = act.getApplicationContext();
m = (MidiManager)context.getSystemService(Context.MIDI_SERVICE);
//check device supports MIDI
if (context.getPackageManager().hasSystemFeature(PackageManager.FEATURE_MIDI)) {
// Phone.tablet supports MIDI
println("great .... can do midi things");
} else {
println("boo .... no midi possible");
}
}
Yes it’s in Processing IDE … it’s a matter of reading the android sdk docs and trying things out a bit at a time. I’m expecting this to take a while yet! Might be a bit soon to start looking at your code, but still post it if you want to
I added ‘m.getDevices()’ to shedMusics code. Now it prints available Midi devices.
That was easy. But I can’t figure out how to open a device. Hopefully shedMusic can do it.
import android.app.Activity;
import android.content.Context;
import android.media.midi.* ;
import android.content.pm.PackageManager ;
Activity act;
Context context;
MidiManager m ;
MidiDeviceInfo[] infos;
String s = "MIDI supported";
String z = "MIDI not supported ";
void setup() {
act = this.getActivity();
context = act.getApplicationContext();
m = (MidiManager)context.getSystemService(Context.MIDI_SERVICE);
//check device supports MIDI
if (context.getPackageManager().hasSystemFeature(PackageManager.FEATURE_MIDI)) {
// Phone.tablet supports MIDI
println (s);
infos = m.getDevices();
println (infos); // list of all the available MIDI devices
} else {
print (z);
}
}
Thanks @sensn seems to be hope! This feature could allow hundreds of professional musical applications developed directly in processing. Thanks for yours works!
Hi,
I just kept on trying to open a device, but we really have to hope for @shedMusic to share his work on this. My knowledge is way to little to do it. So please Mr. shedMusic if you make your work available this would be really great for artists with little coding know-how.
Ok… i think i need too to order a usb to midi cable!
Great work Mark @shedMusic !
Are you going to add the parameters input, like noteOn noteOff (or note length), note, velocity, channel and CC ? Please!
Thanks
Nice. @chanof if you read through https://developer.android.com/reference/android/media/midi/package-summary
you can see that the next step will be to open a device, which might be a bit tricky. Then we need to open a input port. Once @shedMusic gets this ready, I think it will be possible for us to get the note-on thing done from what is written in the docs.
I do have an OTG-cable and a USB-MIDI interface that works, so i can help testing, once we are there.
Thanks guys, I’m even happier if I can learn instead of copying. You need some patience with me :).
For example:
I think the next step after the posted code is to open the MIDI devices to which I want to send notes:
m.openDevice(info, new MidiManager.OnDeviceOpenedListener() {
@Override
public void onDeviceOpened(MidiDevice device) {
if (device == null) {
Log.e(TAG, "could not open device " + info);
} else {
...
}
}, new Handler(Looper.getMainLooper())
);
By copying this method i got an error: unexpected token
Yeah, that’s what I tried yesterday. It’s not that easy. That code has to be rewritten to work inside the processing IDE. I guess shedMusic is working on it. So we’ll have to wait and see.
//Try to open a device!
//To get this bit to work, make sure you have imported android.os.Handler and android.os.Looper at the top of your sketch;
//Still experimental at this stage but is working
//I have used deviceInfo[0] here which for me (at least for now) is FluidSynth
m.openDevice(deviceInfo[0], new MidiManager.OnDeviceOpenedListener() {
@Override
public void onDeviceOpened(MidiDevice device) {
if (device == null) {
println("could not open device");
} else {
println("device opened and ready for use");
}
}
}
, new Handler(Looper.getMainLooper())
);
//and that ends opening a device ... phew...!
//next ... playing some notes ... I hope