Go Down

Topic: Separate Max signal (MIDI) (Read 361 times) previous topic - next topic

Krisztian Hofstadter

Hello

I am wondering whether someone could give me a hint, how to continue.

I would like make sound with a midi device by sending values from Max/MSP to the Arduino. Now, my following code should work, but it only changes the notes, I can not control the velocity.
Code: [Select]
/*
MIDI
Language: Wiring/Arduino

Plays MIDI notes from 30 to 90 (F#-0 to F#-5)

*/

char note = 0;    // The MIDI note to be played

void setup()  {
   // Set MIDI baud rate
   Serial.begin(31250);
}

void loop()  {
 
 byte note;
 
 // check if data has been sent from the computer
 if (Serial.available()) {
   // read the most recent byte (which will be from 0 to 255)
   note = Serial.read();
   
 noteOn(0x90, note, 0X70);
   delay(10);
   // Note on channel 1 (0x90), some note value (note), silent velocity (0x00):
   noteOn(0x90, note, 0x00);
   delay(100);                        

 }
 

}

// Plays a MIDI note.  Doesn't check to see that
// cmd is greater than 127, or that data values are less than 127:

void noteOn(char cmd, char data1, char data2)  {
 Serial.print(cmd, BYTE);
 Serial.print(data1, BYTE);
 Serial.print(data2, BYTE);
}

//doto : check serial baudrate, how to receive more than 1 data


If I want to send a message from Max with the note and the velocity (60 88) in it how could I do that? I think there should be a way to separate the messages components in the Arduino code. Could anyone point me to a direction to go?

thank you
K


Go Up