import promidi.*; MidiIO midiIO; MidiOut midiOut; Note note; int midiNote; int theMidiNote; float readSpeed = 0.30; boolean portSelected = false; PImage a; int[] aPixels; int direction = 1; boolean onetime = true; float signal; void setup() { note = new Note(0,0,0); midiIO = MidiIO.getInstance(this); println("printPorts of midiIO"); midiIO.printPorts(); size(200, 200); aPixels = new int[width*height]; noFill(); stroke(255); framerate(30); a = loadImage("rock.jpg"); for(int i=0; i 127) { theMidiNote = 127; } else { theMidiNote = theMidiNote; } if (theMidiNote > 80 && portSelected==true) { midiOut.sendProgramChange(new ProgramChange(3,randomInst)); midiOut.sendNoteOff(note); note = new Note(3,theMidiNote,126); midiOut.sendNoteOn(note); } else { if ((theMidiNote > 40) && (theMidiNote < 60) && portSelected==true) { midiOut.sendProgramChange(new ProgramChange(2,1)); midiOut.sendNoteOff(note); note = new Note(2,theMidiNote,127); midiOut.sendNoteOn(note); } else { if(portSelected==true) { midiOut.sendProgramChange(new ProgramChange(0,randomInst+1)); midiOut.sendNoteOff(note); note = new Note(0,theMidiNote,127); midiOut.sendNoteOn(note); } } } } void stopBreak() { // IF NEED IT if(keyPressed) { if (key == 's' || key == 'S') { midiOut.sendNoteOff(note); } } } void soundStill() { if(key == CODED) { if (keyCode == UP) { readSpeed = readSpeed + 0.01; } else if (keyCode == DOWN) { readSpeed = readSpeed - 0.01; } } else { readSpeed = readSpeed; } } void pointMania() { float pointillize = 2.0 + (mouseX / (float) width) * 4.0; int x = int(random(a.width)); int y = int(random(a.height)); int loc = x + y*a.width; float r = red(a.pixels[loc]); float g = green(a.pixels[loc]); float b = blue(a.pixels[loc]); fill(r,g,b,126); rect(x,y,pointillize,pointillize); } void mainBody() { portSelected = true ; if (signal > width*height-1 || signal < 0) { direction = direction * -1; } if(mousePressed) { if(mouseY > height-1) { mouseY = height-1; } if(mouseY < 0) { mouseY = 0; } signal = mouseY*width+mouseX; } else { signal += (readSpeed*direction); } if(keyPressed) { soundStill(); loadPixels(); for (int i=0; i