import rwmidi.*; MidiOutput output; int scale[] = new int[] {0, 2, 3, 5, 7, 8, 10, 12 }; //int scale2[] = new int[] {12, 10, 8, 7, 5, 3, 2, 0 }; int prevPitch = 0; int MAX = 70; //set up some global variables as arrays now int[] xspeed = new int[MAX]; int[] yspeed = new int[MAX]; int[] x = new int[MAX]; int[] y = new int[MAX]; float[] r = new float[MAX]; color []elColor = new color [MAX]; //our setup function void setup() { size(800,600); //define size //initialize all arrays for (int i = 0; i < MAX; i++) { random(i); xspeed[i] = int(random(-10,2)); yspeed[i] = int(random(-5,2)); x[i] = width/2; y[i] = height/2; r[i] = 10; elColor[i]= color(0,0,0); } MidiOutputDevice devices[] = RWMidi.getOutputDevices(); output = RWMidi.getOutputDevices()[0].createOutput(); //ESTE FOR ES PARA QUE APAGUE AL PRINCIPIO CUALQUIER NOTA QUE QUEDE SONANDO for(int i=0; i<=127; i++){ notoutput(i); } } //METODOS int pitchValue(int x, int y) { return (x + y) % 3 * 12 + 40; } void output(int y) { output.sendNoteOn(0, y+20, 100); } void notoutput(int y) { output.sendNoteOff(0, y+20, 100); } ////////////////////// void draw() { background(0); ellipseMode(CENTER); noStroke(); for (int i = 0; i < MAX; i++) { notoutput(prevPitch); if(i%2 == 0){ int posPitch = floor(map(i, 0, MAX, 0, 7)); int pitch = scale[posPitch]; output(pitch); prevPitch=pitch; } //colorMode(HSB,100,100,100); fill(elColor[i],50); ellipse(x[i],y[i],r[i],r[i]); if (r[i] > random(10,100)) { r[i]--; elColor[i]= color(random(0,256),0,0); } //adjust x,y based on speed x[i] = x[i] + xspeed[i]; y[i] = y[i] + yspeed[i]; //acount for bouncing off edges if ((x[i] > width) || (x[i] < 0)) { xspeed[i] = xspeed[i] * -1; r[i] = random(10,100); //adjust radius when bouncing elColor[i]= color(0,random(0,256),0); } if ((y[i] > height) || (y[i] < 0)) { yspeed[i] = yspeed[i] * -1; r[i] = random(10,100); elColor[i]= color(0,0,random(100,256)); } } }