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
problem with promidi (Read 662 times)
problem with promidi
Sep 20th, 2008, 12:35am
 
hi,

i have a problem using processing and promidi.

i tried to use this promidi example for testing midi-output:

////////////////////////////////////////////////////////

import processing.opengl.*;
import promidi.*;

MidiIO midiIO;
MidiOut midiOut;
Bowl[] bowl;

void setup(){
 size(128*5,128*5);
 background(0);
 smooth();

 //get an instance of MidiIO
 midiIO = MidiIO.getInstance(this);
 
 //print a list with all available devices
 midiIO.printDevices();
 
 //open an midiout using the first device and the first channel
 midiOut = midiIO.getMidiOut(0,0);

 bowl = new Bowl[30];
 for(int i = 0;i < bowl.length;i++){
   bowl[i] = new Bowl(i);
 }
 noStroke();
}

void draw(){
 background(0);
 for(int i = 0;i < bowl.length;i++){
   bowl[i].move();
   bowl[i].paint();
 }

}

class Bowl{
 float xSpeed;
 float ySpeed;
 float xPos;
 float yPos;
 Note note;
 color col;
 int myNumber;

 Bowl(int number){
   xSpeed = random(2,20);
   ySpeed = random(2,20);
   note = new Note(0,0,0);
   col = color(
     random(0,255),
     random(0,255),
     random(0,255)
   );
   myNumber = number;
 }

 void move(){
   xPos += xSpeed;
   yPos += ySpeed;
   midiOut.sendController(
     new Controller(0,myNumber,int(xPos/6)+2)
   );
   
   if(xPos > width || xPos < 0){
     xSpeed = -xSpeed;
     xPos += xSpeed;

     playNote();
   }
   if(yPos > width || yPos < 0){
     ySpeed = -ySpeed;
     yPos += ySpeed;
     playNote();
     midiOut.sendProgramChange(
       new ProgramChange(0,myNumber)
     );
   }
 }

 void playNote(){
   note = new Note(int(xPos/5f),int(yPos/10f)+60,int(random(1000)));
   midiOut.sendNote(note);
 }

 void paint(){
   fill(col);
   ellipse(xPos,yPos,20,20);
 }
}

////////////////////////////////////////////////////////

when i run this, i get the following message:

"The constructor Controller(int, int, int) is undefined"

can somebody tell me why this happens?

thanks,
stefan
Re: problem with promidi
Reply #1 - Sep 23rd, 2008, 12:09am
 
Hi stefan,  

the problem is you copied a code example from the promidi 1.0 documentation when you are using version 2.0 of the library.
Re: problem with promidi
Reply #2 - Sep 23rd, 2008, 12:19am
 
my bad, looks like the 2.0 documentation is outdated as well for that particular example.

this line:

new Controller(0,myNumber,int(xPos/6)+2)

should read:

new Controller(myNumber,int(xPos/6)+2)

and, this line:

new ProgramChange(0,myNumber)

should read:

new ProgramChange(myNumber)



Re: problem with promidi
Reply #3 - Sep 23rd, 2008, 6:32pm
 
hi corbanbrook,

thanks for your help. i switched to rwmidi in the meantime, so i dont need this any longer.

cheers,
stefan
Re: problem with promidi
Reply #4 - Sep 25th, 2008, 5:23pm
 
I didnt know rwmidi existed until you mentioned it, I replaced promidi with it in my sketch and its working a lot better.
Page Index Toggle Pages: 1