beatkeeper
YaBB Newbies
Offline
Posts: 8
Re: proMIDI, MidiBus, and Accurate Input Detection
Reply #5 - Jan 22nd , 2009, 6:44am
Hello All, As promised, this is the sketch I use to figure out what I'm receiving via the MidiBus library. Any improvements are certainly welcome. ----Start of code---- /* * This sketch is a simple diagnostic tool for monitoring MIDI * input data. It uses the MidiBus library. * * Issues: */ import themidibus.*; MidiBus myBus; void setup(){ // List all available Midi devices on STDOUT. This will show each device's index and name. MidiBus.list(); myBus = new MidiBus(this, 0,1); } void draw(){ } void noteOn(int channel, int pit, int vel){ println(millis() + "\tNoteOn : Pitch=" + pit + "\tVelocity=" + vel + "\tChannel=" + channel); } void noteOff(int channel, int pit, int vel){ println(millis() + "\tNoteOff: Pitch=" + pit + "\tVelocity=" + vel + "\tChannel=" + channel); } void controllerChange(int channel, int num, int val){ println(millis() + "\tController Change: Number=" + num + "\tvalue=" + val + "\tChannel=" + channel); } ----End of code---- Below is the equivalent using the proMIDI library. Note that it exhibits the behavior that I mentioned earlier in the thread. If anyone sees anything obvious that might be the cause, please let me know. ----Start of code---- /* * This sketch is a simple diagnostic tool for monitoring MIDI * input data. It uses the proMIDI library. */ import promidi.*; MidiIO midiIO; int device = 0; // Roland TDW-1 // int channel = 8; // Oxygen 8 int channel = 7; void setup(){ midiIO = MidiIO.getInstance(this); // print a list of all devices midiIO.printDevices(); Receiver recvr = new Receiver(); midiIO.plug(recvr,"noteOn", device, channel); midiIO.plug(recvr,"noteOff", device, channel); midiIO.plug(recvr,"controllerIn", device, channel); midiIO.plug(recvr,"programChange", device, channel); } // Note that without this draw function, nothing seems to happen! void draw(){ } // If this class is not declared public then it will cause the MidiIO.plug() // method to fail with an IllegalAccessException. public class Receiver { Receiver(){ println("Created Receiver object recvr"); } void noteOn(Note note){ int vel = note.getVelocity(); int pit = note.getPitch(); println(millis() + "\tNoteOn : Pitch=" + pit + "\tVelocity=" + vel); } void noteOff(Note note){ int pit = note.getPitch(); int vel = note.getVelocity(); println(millis() + "\tNoteOff: Pitch=" + pit + "\tVelocity=" + vel); } void controllerIn(Controller controller){ int num = controller.getNumber(); int val = controller.getValue(); println(millis() + "\tController In: Number=" + num + "\tvalue=" + val); } void programChange(ProgramChange programChange){ int num = programChange.getNumber(); println(millis() + "\tProg Change: Number=" + num); } }// class Receiver ----End of code----