// Title: MIDI VALUE SENDER // // Descr: This application allows you to send a short MIDI CC or NOTE signal to // a chosen MIDI output device. It is useful for mapping a MIDI controller // to a MIDI program. For example, you could map a custom MIDI interface // to a program such as Ableton Live. It has only been tested on Mac OS X. // // Author: Richard Caceres, mrshiz111 [at] gmail [com] // URL: http://richard-c.com // Date: 09/29/08 // // Note: Build with Processing (http://processing.org) using the RWMIDI // (http://ruinwesen.com/blog?id=95) and ControlP5 // (http://www.sojamo.de/libraries/controlP5/) libraries. // // Copyright: You are free to modify this program as long as you give me credit. import rwmidi.*; import controlP5.*; ControlP5 controlP5; MidiOutput midiOut; int sliderValue = 127; void setup() { size(300,400); frameRate(30); controlP5 = new ControlP5(this); ScrollList l1 = controlP5.addScrollList("ccList", 10,100,80,290); ScrollList l2 = controlP5.addScrollList("deviceList", 10, 20, 270, 80); ScrollList l3 = controlP5.addScrollList("noteList", 110,100,80,290); l1.setLabel("MIDI CC Sender"); l2.setLabel ("MIDI Device"); l3.setLabel ("MIDI Note Sender"); // Populate CC List. for(int i=0;i < 127;i++) { controlP5.Button b = l1.addItem("CC "+i, i); b.setId(100 + i); } // Populate Note List. for(int i=0;i < 127;i++) { controlP5.Button b = l3.addItem("Note # "+i, i); b.setId(200 + i); } // Create the Midi Output device selector String md[] = RWMidi.getOutputDeviceNames(); for (int i=0; i < md.length; i++) { controlP5.Button b = l2.addItem(md[i], i); b.setId (i); } // Create the Slider Slider s = controlP5.addSlider("sliderValue",0,127,128,220,100,10,100); // Create the midi output midiOut = RWMidi.getOutputDevices()[0].createOutput(); } void ccList(int theValue) { println("ddd"); } void controlEvent(ControlEvent theEvent) { println(theEvent.controller().id()+" / "+ theEvent.controller()+" / "+ theEvent.controller().value() ); println (theEvent.label()); int id = theEvent.controller().id(); if (id < 100) { midiOut = RWMidi.getOutputDevices()[id].createOutput(); } else if (id >= 100 && id < 200) { midiOut.sendController(0, (int)theEvent.controller().value(), sliderValue); } else if (id >= 200 && id < 300) { midiOut.sendNoteOn(0, (int)theEvent.controller().value(), sliderValue); delay(10); midiOut.sendNoteOn(0, (int)theEvent.controller().value(), 0); } } void slider(float value) { sliderValue = floor(value); } void draw() { background(0); }