We closed this forum 18 June 2010. It has served us well since 2005 as the ALPHA forum did before it from 2002 to 2005. New discussions are ongoing at the new URL http://forum.processing.org. You'll need to sign up and get a new user account. We're sorry about that inconvenience, but we think it's better in the long run. The content on this forum will remain online.
Page Index Toggle Pages: 1
Help (Read 617 times)
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;}
 //}
Re: Help – on WHAT?
Reply #1 - Dec 16th, 2006, 2:10pm
 
*If* you provided a more descriptive subject, specified what you actually wanted your code to do and provided hints where you have trouble, you *might* be able to get some help here. If not, well… help yourself.
Re: Help
Reply #2 - Dec 16th, 2006, 2:39pm
 
I second brsma.

People on this forum have always been VERY helpful, but you should at least show some initiative like telling us what error the code produces/ where there's a slowdown/ or whatever problem there is. Believe me, if you describe your problem a bit further, someone will likely take some time to look at it.

And most importantly, don't just write "Help" in to the subject. Undescriptive posts like that tend to get ignored.

Page Index Toggle Pages: 1