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.
IndexProgramming Questions & HelpSound,  Music Libraries › ProMidi => Array of Note
Page Index Toggle Pages: 1
ProMidi => Array of Note (Read 411 times)
ProMidi => Array of Note
Mar 14th, 2008, 12:34pm
 
hello,

I want to know , how it's possible to create some Array of Note Object to use in another object.
I have created an game like a chess board, and when you move over the square of the chess board with your mouse, you send midinote.
So i have created 16 objects for 16 squares, and i want to send 16 notes out, so how can i do to put 16 different notes into my square Class?
i hope i'm clear Smiley

i have writen this:

Carre[] carre = new Carre[numCarre];
Note [] noteLevelOne = new Note[numCarre];
Note [] noteLevelTwo = new Note[numCarre];

to declare, and this to construct:

for(int i=0;i<carre.length;i++){
   noteLevelOne[i]=new Note(numeros1[i],velocity1,length1);
   noteLevelTwo[i]=new Note(numeros2[i],velocity2,length2);
   carre[i]=new Carre(x[i],y[i],diameter,colorc[i],colord[i],noteLevelOne[i],noteLevelTwo[i]);
   
 }

and in my class:

class Carre{
 
 int colorc,colord,x,y,diameter;
 Note note1;
 Note note2;



 Carre(int xpos,int ypos,int dia,int icolorc,int icolord,Note inote1,Note inote2){
   x=xpos;
   y=ypos;
   diameter=dia;
   icolorc=colorc;
   icolord=colord;
   inote1=note1;
   inote2=note2;
   
 }

and finally the method to send the note:
void update(){
   if(level==false){
     if(over(x,y,diameter,mick1.x1,mick1.y1,mick2.x1,mick2.y1)){
       if (colorc > 0) {
         colorc=colorc-5;
       }
       if(colorc>=250){
         //note1=new Note(60,126,400);
         midiOut.sendNote(note1);
         println("   "+note1);
         println(note1);
       }
     }
     else {
       colorc=255;
       colord=255;
     }
   }
 }

but when i run the sketch processing send me an error message said that :
NullPointerException

He doesn't find any Note midi!
i don't understand why..
please help me Smiley
thanks

Re: ProMidi => Array of Note
Reply #1 - Mar 14th, 2008, 1:17pm
 
ok...
i have find a solution.
Smiley
Page Index Toggle Pages: 1