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
Promidi help (Read 425 times)
Promidi help
Apr 16th, 2008, 12:56pm
 
I have a sketch which generates 8 separate values according to mouse position relative to 8 elipses. I want to output these values as midi control data. I have found promidi but don't know what to do with it. Can anybody help get me started?

This is what I have so far:

void setup(){
 size(640, 640);
 smooth();
 background(255);
 noStroke();
}

void draw() {
 float a = dist(mouseX, mouseY, 320, 120);
 fill(a);
 ellipse(320,120, 64, 64);
 float b = dist(mouseX, mouseY, 461, 179);
 fill(b);
 ellipse(461,179, 64, 64);
 float c = dist(mouseX, mouseY, 520, 320);
 fill(c);
 ellipse(520,320, 64, 64);
 float d = dist(mouseX, mouseY, 461, 461);
 fill(d);
 ellipse(461,461, 64, 64);
 float e = dist(mouseX, mouseY, 320, 520);
 fill(e);
 ellipse(320,520, 64, 64);
 float f = dist(mouseX, mouseY, 179, 461);
 fill(f);
 ellipse(179,461, 64, 64);
 float g = dist(mouseX, mouseY, 120, 320);
 fill(g);
 ellipse(120,320, 64, 64);  
 float h = dist(mouseX, mouseY, 179, 179);
 fill(h);
 ellipse(179,179, 64, 64);  
}

Re: Promidi help
Reply #1 - Apr 17th, 2008, 11:23pm
 
hi!
i'm a beginner too(i started in december Smiley
but i have work a little bit , and tonight there is nothing to do except to help you on this sketch Smiley
i work with sound too and that's why i have ever use the promidi library.
So, i have try to do something (i think it's working )

i don't have write nothing for the comment (excuse for my bad english) but i have use some Object and Array of objects.it's more easy to use.

////this is the first page

import promidi.*;

MidiOut midiOut;
MidiIO midiIO;
int numEllipse=8;
int cc,giveInc;
int [] c = new int[numEllipse];
int [] x ={
 320,461,520,461,320,179,120,179};
int [] y={
 120,179,320,461,520,461,320,179};
int [] diam={
 64,64,64,64,64,64,64,64};  
int [] noteNum={
 60,61,62,63,64,65,66,67};
int [] contNum={
 70,71,72,73,74,75,75,76};
int [] value = new int[numEllipse];
Note [] sound = new Note[numEllipse];
Controller [] increment=new Controller[numEllipse];
SoundCircle[] circle=new SoundCircle[numEllipse];

void setup(){
 size(640, 640);
 smooth();  
 background(255);
 noStroke();
 //le MIDI
 midiIO = MidiIO.getInstance(this);
 println("<<<<<<<<<< Ports Midi >>>>>>>>>>");
 midiIO.printDevices();
 midiOut = midiIO.getMidiOut(0,3);
 for(int i=0;i<numEllipse;i++){
   sound[i]=new Note(noteNum[i],127,50);
   increment[i]=new Controller(contNum[i],value[i]);
   circle[i]=new SoundCircle(x[i],y[i],diam[i],increment[i],c[i]);

 }


}

void draw() {
 background(255);

 for(int i=0;i<numEllipse;i++){
   //circle[i].update();
   circle[i].display();
   value[i]=circle[i].giveInc;
   if(mouseX!=pmouseX){
   midiOut.sendController(circle[i].increment);
   }
   print(circle[0].giveInc+"     "+circle[4].giveInc+"    ");
 }
}
////this is the second page

class SoundCircle{
 int x,y,diam,c,giveInc;
 Controller increment;





 SoundCircle(int ix,int iy,int idiam,Controller iincrement,int ic){
   x=ix;
   y=iy;
   diam=idiam;
   increment=iincrement;
   c=ic;

 }
 
 void display(){
   c=int(dist(mouseX,mouseY,x,y));
   cc=constrain(c,0,600);
   fill(c);
   giveInc = int(map(cc,0,600,0,127));
   ellipse(x,y,diam,diam);

 }
}

voilà !!

have a nice trip
say me if it's working
ciao
Page Index Toggle Pages: 1