import themidibus.*; //Import the library MidiBus myBus; // The MidiBus int instrument = 118; //Synth Drum int lastBeat; float beatLength; void setup() { size(400,200); background(0); myBus = new MidiBus(this, -1, "Microsoft MIDI Mapper"); setInstrument(instrument); frameRate(60); lastBeat = millis(); beatLength = 500; } void draw() { background(0); int channel = 0; int pitch = 48; //drum int velocity = 127; if(millis() - lastBeat > beatLength){ lastBeat = millis(); myBus.sendNoteOn(0, pitch, 80); } } void setInstrument(int value) { byte data[] = new byte[2]; data[0] = (byte)0xC0; data[1] = (byte)value; myBus.sendMessage(data); }