Hi everybody!
We have developed a little project which understand midi message using midi library and arduino UNO and lights some power leds related with some keys. Our variables are pitch and velocity. The hardware and software work fine when we connect midi wire directly from the computer and send the midi standard. (Cubase 6.5) The problems begin using MPC (AKAI MPC1000). We realized that it uses note on == 0 instead of note off and we have fixed the code, but there are still problems.
At the beginning it works perfectly, but more midi messages are coming more differences occur. At the end leds remain switched on when they must switch off and things like that.
We discard our hardware because works ok connected through the Computer. Is it possible that messages from MPC have any difference else from the midi standard?
This is the example connected through the computer.
I hope someone could help us.
We are maintaining the note off in order to use both, Computer and MPC
#include <MIDI.h>
int Led2 = 2;
int Led3 = 3;
int Led4 = 4;
int Led5 = 5;
int Led6 = 6;
int Led7 = 7;
int Led8 = 8;
int Led9 = 9;
int Led10 = 10;
int Led11 = 11;
// This function will be automatically called when a NoteOn is received.
// It must be a void-returning function with the correct parameters,
// see documentation here:
// http://arduinomidilib.sourceforge.net/class_m_i_d_i___class.html
void HandleNoteOn(byte channel, byte pitch, byte velocity)
{
// Do whatever you want when you receive a Note On.
//--------------------**tecla DO central**----------------DIGITAL--------------------------
if (pitch == 60 && velocity != 0)
{
digitalWrite(Led2, HIGH);
}
if (pitch == 60 && velocity == 0)
{
digitalWrite(Led2, LOW);
}
//-----------------------------------------------------------------------------------------
//--------------------**tecla RE central**---------------PWM-------------------------------
if (pitch == 61)
{
analogWrite(Led3, 2*velocity);
//delay(45);
}
//-----------------------------------------------------------------------------------------
THE REST OF PITCHES....
}
void HandleNoteOff(byte channel, byte pitch, byte velocity)
{
//--------------------**tecla DO central**----------------DIGITAL--------------------------
if (pitch == 60)
{
digitalWrite(Led2, LOW);
}
//-----------------------------------------------------------------------------------------
//--------------------**tecla RE central**---------------PWM-------------------------------
if (pitch == 61)
{
analogWrite(Led3, LOW);
//delay(45);
}
//-----------------------------------------------------------------------------------------
THE REST OF PITCHES
}
void setup() {
pinMode(Led2,OUTPUT);
pinMode(Led3,OUTPUT);
pinMode(Led4,OUTPUT);
pinMode(Led5,OUTPUT);
pinMode(Led6,OUTPUT);
pinMode(Led7,OUTPUT);
pinMode(Led8,OUTPUT);
pinMode(Led9,OUTPUT);
pinMode(Led10,OUTPUT);
pinMode(Led11,OUTPUT);
//pinMode(13, OUTPUT);
// Initiate MIDI communications, listen to channel 15
MIDI.begin(14);
// Connect the HandleNoteOn function to the library, so it is called upon reception of a NoteOn.
MIDI.setHandleNoteOn(HandleNoteOn); // Put only the name of the function
MIDI.setHandleNoteOff(HandleNoteOff); // Put only the name of the function
}
void loop() {
// Call MIDI.read the fastest you can for real-time performance.
MIDI.read();
/*digitalWrite(13, HIGH); // set the LED on
delay(400); // wait for a second
digitalWrite(13, LOW); // set the LED off
delay(400); // wait for a second*/
// There is no need to check if there are messages incoming if they are bound to a Callback function.
}