dotcomplot
YaBB Newbies
Offline
Posts: 3
midi input data problem!
Jan 1st , 2009, 3:30pm
hey, i'm quite new to processing, so my problem should be an easy one for you pros! i'm able to get the midi pitch and velocities from midi input, but how can i use the varibles "vel" and "pit" in the draw method? code: import JMyron.*; import promidi.*; import processing.opengl.*; JMyron m;//a camera object MidiIO midiIO; int MyMusic = noteOff(Note note, int deviceNumber, int midiChannel); void setup(){ size(1024,576); m = new JMyron();//make a new instance of the object m.start(width,height);//start a capture at 320x240 //m.findGlobs(20);//disable the intelligence to speed up frame rate println("Myron " + m.version()); rectMode(RIGHT); stroke(0,0,0); midiIO = MidiIO.getInstance(this); println("printPorts of midiIO"); midiIO.printDevices(); //÷ffnen des LoopBe Inputs, Channel 3(== Wert 2) <- MUSS angepasst werden midiIO.openInput(0,0); frameRate(120); } int noteOn( Note note, int deviceNumber, int midiChannel ){ //Aus der ¸bergebenen Note holen wir uns Velocity und Pitch int vel = note.getVelocity(); int pit = note.getPitch(); println("noteOn, Velocity: " + vel + ", Pitch: " + pit); return vel; } //Event Handler f¸r den Midi Befehl Note On. //Wird ausgef¸hrt, sobald ¸ber das geˆffnete Device ein NoteOff kommt. int noteOff( Note note, int deviceNumber, int midiChannel ){ //Aus der ¸bergebenen Note holen wir uns Velocity int pit = note.getPitch(); println("noteOff, Pitch: " + pit); return pit; } void draw(){ background(0); m.update();//update the camera view int[] img = m.image(); //get the normal image of the camera float r,g,b; for(int y=0;y<height;y+=5){ //loop through all the pixels for(int x=0;x<width;x+=100){ //loop through all the pixels float av = (red(img[y*width])+red(img[y*width])+red(img[y*width]))/10; fill(red(123),green(20),blue(20)); fill(255); pushMatrix(); translate(y*10,y+200); for(int j = 10; j<200; j = j+1) { rotate(av/j); } for(int i = 0; i<10; i = i+1) { rect(0,0,av*i,av*i/(i/10)); } popMatrix(); } } //saveFrame("glitch3-####.tiff"); } void mousePressed(){ m.settings();//click the window to get the settings } public void stop(){ m.stop();//stop the object super.stop(); } greetz thomas