Pages: [1]   Go Down
Author Topic: Question about the MIDI library  (Read 767 times)
0 Members and 1 Guest are viewing this topic.
China-Shenzhen
Offline Offline
Newbie
*
Karma: 0
Posts: 4
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

I want to make a try for the MIDI library as that: use the Easy MIDI controller in my cell phone to send MIDI message via the bluetooth, and display the message in the LCD, howerver, when I click the key in my phone(piano mode),there is no response in the LCD. I have modified the baud rate of the bluetooth to 115200.  If I use serial port directly, I can see information like this ('1 53 110 1 57 0'), unlike the correct MIDI message, Does anyone give me a hand to see what happened? Thanks!

#include <MIDI.h>

#include <LiquidCrystal.h>

LiquidCrystal lcd(12,11,2,3,4,5,6,7,8,9,10);
void setup(){
  lcd.begin(16,2);
  Serial.begin(115200);
  MIDI.begin();
  MIDI.setHandleNoteOn(functionNoteOn);
  MIDI.setHandleNoteOff(functionNoteOff);
  lcd.clear();
  lcd.print("Hello,Cathy Lee!");
}

void loop(){
    delay(1000);
    MIDI.read();
}
void functionNoteOn(byte channel,byte pitch,byte velocity){
  lcd.print("NoteOn:");
  lcd.print(channel);
  lcd.print(' ');
  lcd.print(pitch);
  lcd.print(' ');
  lcd.print(velocity);
  lcd.print(' '); 
}
void functionNoteOff(byte channel,byte pitch,byte velocity){
  lcd.print("NoteOff:");
  lcd.print(channel);
  lcd.print(' ');
  lcd.print(pitch);
  lcd.print(' ');
  lcd.print(velocity);
  lcd.print(' ');   
}
Logged

Relux Wong

0
Offline Offline
Newbie
*
Karma: 0
Posts: 26
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Hi,

Are you connecting you bluetooth receiver directly to RX/TX (serial) of the Arduino ?
I don't know that much about theses bluetooth module but they should be initialized no ?
Midi serial baud rate is 31250, don't know it you can use the midi library at 115200 baud (maybe, never tested).

What do you mean by using the serail port directly ? is this information written on the lcd ?

regards,
xray303

Logged

China-Shenzhen
Offline Offline
Newbie
*
Karma: 0
Posts: 4
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Hi Xray,

my connection as below:
Cellphone -> Bluetooth Module -> Arduino UNO Serial port.

So, I want to know how to set the baud rate when use the MIDI library or it is default to 31250?

Regard to use serial port directly means that I don't use MIDI library but Serial library.

Hi,

Are you connecting you bluetooth receiver directly to RX/TX (serial) of the Arduino ?
I don't know that much about theses bluetooth module but they should be initialized no ?
Midi serial baud rate is 31250, don't know it you can use the midi library at 115200 baud (maybe, never tested).

What do you mean by using the serail port directly ? is this information written on the lcd ?

regards,
xray303


Logged

Relux Wong

0
Offline Offline
Newbie
*
Karma: 0
Posts: 26
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Hi,

Normally midi.begin() set the baud rate to 31250 automatically.
Maybe the serial.begin interfer to the midi.begin as they are using the same serial port .. (not sure for the UNO).

You can try to display on the lcd screen directly the received serial bytes (at 31250 baud) without using the midi lib. to check if the midi data received are correct.
when a note is pressed on your midi program you should receive for example : 0x90 (in hex note on channel 1) then the note value  and then the velocity.
when you stop pressing the note you will also receive a message for example  : 0x80 (in hex note off channel 1) then the note value  and then the velocity (should be 0).

to check the midi message you can look at this page : http://www.midi.org/techspecs/midimessages.php

The message you have received earlier are quite strange but not totally wrong :

   1  = ??     53 = can be note number       110 =can be velocity       /     1 = ???      57= can be note number         0= can be velocity (0 is note off in some program) )


Logged

Pages: [1]   Go Up
Jump to: