mainattraction
YaBB Newbies
Offline
Posts: 2
Help
Dec 13th , 2006, 8:20pm
New to programing and need help with class project, can any one look at the code and help me out. as far as making it work or tips on how to improve it. Thanks. import promidi.*; ArrayList melody = new ArrayList(); ArrayList tune = new ArrayList(); Sequencer sequencer; int i = 0; void setup(){ DMouseX runX = new DMouseX (50); DMouseY runY = new DMouseY(50); melody.add(runX); tune.add(runY); sequencer = new Sequencer(); MidiIO midiIO = MidiIO.getInstance(); midiIO.printDevices(); midiIO.closeOutput(1); MidiOut test = midiIO.getMidiOut(1,1); Track track = new Track("one", test); track.setQuantization(Q._1_8); track.addEvent(new Note(drawmouseX1.x, 127,40), 0); track.addEvent(new Note(20, 127,40), 1); track.addEvent(new Note(30, 127,40), 2); track.addEvent(new Note(40, 127,40), 3); track.addEvent(new Note(50, 127,40), 4); Song song = new Song("test", 120); song.addTrack(track); sequencer.setSong(song); sequencer.setLoopStartPoint(0); sequencer.setLoopEndPoint(512); sequencer.setLoopCount(-1); } void mousePressed(){ if(mouseButton == LEFT) sequencer.stop(); DMouseX curMouseX = new DMouseX(mouseX); DMouseY curMouseY = new DMouseY(mouseY); //getcomm one = new getcomm (melody.get(0)); melody.add (curMouseX); tune.add (curMouseY); } //i++; //else sequencer.stop(); void keyPressed () { if(key == 'b') sequencer.start(); } void draw(){ if (i ==0){ DMouseX drawmouseX1 = (DMouseX)melody.get(0); DMouseY drawmouseY1 = (DMouseY) tune.get(0); ellipse(drawmouseX1.x, drawmouseY1.y, 5, 5); } if (i==1){ DMouseX drawmouseX2 = (DMouseX)melody.get(1); DMouseY drawmouseY2 = (DMouseY) tune.get(1); ellipse(drawmouseX2.x, drawmouseY2.y, 5, 5); } if (i==2){ DMouseX drawmouseX3 = (DMouseX)melody.get(2); DMouseY drawmouseY3 = (DMouseY) tune.get(2); ellipse(drawmouseX3.x, drawmouseY3.y, 5, 5); } if(i==3){ DMouseX drawmouseX4 = (DMouseX)melody.get(3); DMouseY drawmouseY4 = (DMouseY) tune.get(3); ellipse(drawmouseX4.x, drawmouseY4.y, 5, 5); } if(i==4){ DMouseX drawmouseX5 = (DMouseX)melody.get(4); DMouseY drawmouseY5 = (DMouseY) tune.get(4); ellipse(drawmouseX5.x, drawmouseY5.y, 5, 5); } //println(drawmouseX1.x); //println(drawmouseY2.y); println(melody.size()); println( tune.size()); //String mvalue; //mvalue = melody.get(i); //println(melody.get(0).toString()); //println(mvalue.get(i).toString()); } class DMouseX { int x; DMouseX(int _inX){x = _inX;} } class DMouseY { int y; DMouseY(int _inY){y = _inY;} } //class getcomm { // int dog; //getcomm(int doggy) {dog = doggy;} //}