memelab
YaBB Newbies
Offline
Posts: 1
Re: RWMidi MIDI Library
Reply #14 - Aug 26th , 2009, 2:27pm
hey everyone... n00b question here... I've followed so far and installed all the correct libraries within P5 and OSX... I have some code that is seeing my controller, i.e. void noteOnReceived(Note note) { println("note on " + note.getPitch()); } ... is displaying values in my console. What I cannot seem to get to work is equating the Integer returned from getPitch to another conditional within my code. I have a feeling that this is a very basic syntax error on my part, but it's partly that I don't understand the inner workings of midi more than using it to map triggers in an a/v program, so I am not sure if using the getPitch statement is the best thing to go ahead with, or if there is something else I have overlooked. Here is the sample code:import rwmidi.*; MidiInput midiInput; MidiOutput midiOutput; int r1; int r2; int r3; int r4; void setup() { size(800, 800); background(0); noStroke(); fill(255); rect(0, 0, 200, 200); fill(239); rect(200, 0, 200, 200); fill(223); rect(400, 0, 200, 200); fill(207); rect(600, 0, 200, 200); fill(191); rect(0, 200, 200, 200); fill(175); rect(200, 200, 200, 200); fill(159); rect(400, 200, 200, 200); fill(143); rect(600, 200, 200, 200); fill(127); rect(0, 400, 200, 200); fill(111); rect(200, 400, 200, 200); fill(95); rect(400, 400, 200, 200); fill(79); rect(600, 400, 200, 200); fill(63); rect(0, 600, 200, 200); fill(47); rect(200, 600, 200, 200); fill(31); rect(400, 600, 200, 200); fill(15); rect(600, 600, 200, 200); MidiInputDevice inDevices[] = RWMidi.getInputDevices(); for (int i = 0; i < inDevices.length; i++) { println("In " + i + ": " + inDevices[i].getName()); } MidiOutputDevice outDevices[] = RWMidi.getOutputDevices(); for (int i = 0; i < outDevices.length; i++) { println("Out " + i + ": " + outDevices[i].getName()); } midiInput = inDevices[2].createInput(this); midiOutput = outDevices[2].createOutput(); } void draw() { } void noteOnReceived(Note note) { println("note on " + note.getPitch()); } int i = 43; if (i = note.getPitch()) { noStroke(); fill(255); rect(0, 0, 200, 200); } else { noStroke(); fill(0); rect(0, 0, 200, 200); } Obviously, what I am trying to do is affect the fill (as a substitute for alpha) of the rectangle based on whether a note is received. I am using a Trigger Finger, which has a 4x4 button array, matching the rectangles drawn (and I know I should rewrite the rect()'s in a class, but I'm a bit slow in OOP, with the end idea of using this as a live input / layer mask to a video mixer, overtop of another channel with live visuals. Feel free to point out stupid mistakes... ~ J