java - Is there a simple example of the new ANDROID M MIDI -


i trying read midi data in new android mushroom midi. attempting use new midi method.

https://developer.android.com/reference/android/media/midi/package-summary.html

android midi has example. contains spinners, context, wrappers , way complex first understanding from. has many java programs , 800 lines of code. want open device 0 , midi output port 2.

is there simple example out there using classes m.opendevice , public void ondeviceopened(mididevice device)? searching first example runs in main , produces textview output.

this seems simple midi sends 3 bits of data, key down, key number, , impact. after weeks of trying, can't seem work. here oneidi example of code below. contains 30 lines of code. want.

// midi parameters out of midi transmitter       public void midi_info() {          midimanager m = (midimanager) getsystemservice(midi_service);         //get system device information         final midideviceinfo[] deviceinfo = m.getdevices();          //your devices have info in array poiston 0         midideviceinfo info = deviceinfo[0];           // midi device port information         int numinputs = info.getinputportcount();         int numoutputs = info.getoutputportcount();          // test connection         if (numoutputs < 1) {             //out put no prot found             textview textout = null;             textout = (textview) findviewbyid(r.id.log);             textout.settextcolor(color.red);             textout.settext("     midi port disconnected");             //send device info test box         } else {             textview textout = null;             textout = (textview) findviewbyid(r.id.log);             textout.settextcolor(color.blue);             textout.settext(string.format(" midi input port number   =  %d  of %d \n" +                     " midi output port number = %d  of %d\n" +                     " \n" +                     " %s", midideviceinfo.portinfo.type_input, numinputs, midideviceinfo.portinfo.type_output, numoutputs, deviceinfo[0].tostring()));           }      }      //method open_device opens midi device     public void open_device() {           //call midimanager within oncreate method         midimanager m = (midimanager) getsystemservice(midi_service);           midideviceinfo[] info = m.getdevices();         final midideviceinfo info0 = info[0];          //open instance of class opendevice          bundle properties = info0.getproperties();         final string name = properties.getstring(midideviceinfo.property_name);         final string deviceusb = properties.getstring(midideviceinfo.property_usb_device);          m.opendevice(info0, new ondeviceopenedlistener() {               @override               public void ondeviceopened(mididevice device) {                    if (name.equals("androidmidiscope0")) {                     textview textout = null;                     textout = (textview) findviewbyid(r.id.log);                     textout.settextcolor(color.red);                     textout.settext("device failed open");                 } else {                       textview textout = null;                     textout = (textview) findviewbyid(r.id.log);                     textout.settextcolor(color.blue);                     textout.settext(string.format("device opened  = %s", device));                     int portnumber = 2;                     midioutputport outputport = device.openoutputport(portnumber);                     }               }           }, new handler(looper.getmainlooper()));     }      }   public class myreceiver extends midireceiver {       mididevice device =null;     public void onsend(byte[] data, int offset, int count, long timestamp) throws ioexception {         textview textout = null;         textout = (textview) textout.findviewbyid(r.id.log);         textout.settextcolor(color.red);         textout.settext(string.format("midi keydown detected  data =%s", data[0]));      }     } 


Comments

Popular posts from this blog

javascript - Slick Slider width recalculation -

jsf - PrimeFaces Datatable - What is f:facet actually doing? -

angular2 services - Angular 2 RC 4 Http post not firing -