Midi un basic by kuk un

Hi!

I was writing the sketch by kuk, step by step, to verify that every line works well, without errors.
Till i found one: playNote(note,0);
As playNote was not declared un the scope. Besides, i don't know where to place it.

Any comment is wellcome.

Dl8k.

/* Any code is welcome */

Dl8k:
Any comment is wellcome.

That's going to be a bit difficult as you have not posted the program you are talking about.

And when posting code please use the code button </>

so your code looks like this

and is easy to copy to a text editor See How to use the Forum

...R

void playNote(byte note, byte velocity){

Please edit your previous post and add the code tags you were asked to use.

//variables setup

byte incomingByte;
byte note;
byte velocity;


int statusLed = 13;   // select the pin for the LED

int action=2; //0 =note off ; 1=note on ; 2= nada


//setup: declaring iputs and outputs and begin serial 
void setup() {
 pinMode(statusLed,OUTPUT);   // declare the LED's pin as output
 pinMode(2,OUTPUT); 
 pinMode(3,OUTPUT);
 pinMode(4,OUTPUT);
 pinMode(5,OUTPUT);
 pinMode(6,OUTPUT);
 pinMode(7,OUTPUT);
 pinMode(8,OUTPUT);
 pinMode(9,OUTPUT);
 
 //start serial with midi baudrate 31250 or 38400 for debugging
 Serial.begin(31250);        
 digitalWrite(statusLed,HIGH);  
}

//loop: wait for serial data, and interpret the message 
void loop () {
 if (Serial.available() > 0) {
   // read the incoming byte:
   incomingByte = Serial.read();

   // wait for as status-byte, channel 1, note on or off
   if (incomingByte== 144){ // note on message starting starting
     action=1;
   }else if (incomingByte== 128){ // note off message starting
     action=0;
   }else if (incomingByte== 208){ // aftertouch message starting
      //not implemented yet
   }else if (incomingByte== 160){ // polypressure message starting
      //not implemented yet
   }else if ( (action==0)&&(note==0) ){ // if we received a "note off", we wait for which note (databyte)
      note=incomingByte;
     playNote(note, 0);
     note=0;
     velocity=0;
     action=2;
   }

Hi!

Well, you can see that in the last ElseIf statement, playNote appears, but it was not declared anywhere in the program. I try to place it in the variables setup, but did not work. Nor as an int function.

Dl8k

Dl8k:
Well, you can see that in the last ElseIf statement, playNote appears, but it was not declared anywhere in the program.

You have not said where you got the program from but quite obviously some part(s) of it are missing.

...R

Hi!,

Here is the original thread:

http://forum.arduino.cc/index.php?topic=22447.msg169310#msg169310

In any case, if you erase the last elseif statement the program should work ok, with of course more limited functions.

Dl8k

Dl8k:
Here is the original thread:

So why are you not using the complete program from that Thread?

It seems to have a playNote() function.

...R

If you read the thread you just quoted you should find the code you seem to have taken out where playNote() is defined. Putting that back in might help.

Steve

Hi!

Well , i was writing the program step by step. Checking every paragraph, before adding a new one. So to not make mistakes...Till i added the playnote function... and the program said this function was not declared in the scope... :o

You haven't shown us that code.

Dl8k:
Well , i was writing the program step by step.

That is a good way to develop your own program but it does not make sense to do it for an existing program because you need all the components of the existing program.

...R

Hi!

Well, finally it works!. I thougt i could write the sketch step by step to avoid errors, but not always is a good idea. ::slight_smile: Besides, i commited some syntax mistakes... So please accept my excuses.

Anyway, the sketch is correct. Another matter will be the test: i have an old Roland synthesizer...the first to feature midi ports, that only transmits/responds to fixed velocity (64). The optocouplers i will use are 6n137/139. I will try if it works...

Dl8k