[vc_row][vc_column width=”1/1″][/vc_column][/vc_row][vc_row][vc_column width=”1/1″][vc_column_text]MIDI Intro
MIDI is the digital music interface,The signal which teansported is note and contral
parameter, The command is made into MIDI messages.it use USRT to communicate with
other devices with 31.25×( 1±0.01) KBaud.
The MIDI cable used is 5 cell cable,We usually use 2,one is input,the other is
output.
Picture 1 MIDI 5pin maleplug
If you donot has maya pro,you can use USB to MIDI cable as showed below.
Picture 2 USB to MIDI cable
The software we used is HappyEO,HappyEO is a software simulating electronic organ.we
can play wonderful music with the software.
Picture 3 HappyEO electronic organ
[/vc_column_text][/vc_column][/vc_row][vc_row][vc_column width=”1/1″][vc_tour][vc_tab title=”Test platform” tab_id=”1392602382-1-98″][vc_column_text]Application software: HappyEO
Hardware platform: arduino+MIDI Breakout
Program software platform: arduino C
Note: we treat the arduino as sound source,arduino send the data and command with
31.25×( 1±0.01) KBaud through the cable MIDI to USB.PC output the voice with the date and
command.[/vc_column_text][/vc_tab][vc_tab title=”Test steps” tab_id=”1392602382-2-79″][vc_column_text]Firstly,we should program the arduino,attach the MIDI breadout to the arduinoboard,connect
the USBtoMIDI cable to PC and MIDI breadout board,the PC can recognize the device,then open
the HappyEO,press the buttom “option”,select the common item and select the USB Audio Device
as the output device.Then select the MIDI input item and select the USB Audio Device item.
If you has select the USB AUDIO DEVICE item,select Wave table software synthesizers as the
output device, you can hear the music with the earphone from the arduino+MIDI Breakout board.
And you can see the LEDs is flash.
If you select the USB AUDIO DEVICE as the output device,HappyEO can send the data and
command to arduino when wo press the keyboard,the led will falsh when it receive data.
Note: USNto MIDI MIDI Breadout
MIDI OUT———- MIDI IN
MIDI IN————- MIDI OUT[/vc_column_text][/vc_tab][vc_tab title=”Test code” tab_id=”1392603281363-2-1″][vc_column_text]The code blew is standard code,you can change the code on the basis of your requirement.
// defines for MIDI Shield components only
#define KNOB1 0
#define KNOB2 1
#define BUTTON1 2
#define BUTTON2 3
#define BUTTON3 4
#define STAT1 7
#define STAT2 6
#define OFF 1
#define ON 2
#define WAIT 3
byte incomingByte;
byte note;
byte velocity;
int pot;
byte byte1;
byte byte2;
byte byte3;
int action=2; //1 =note off ; 2=note on ; 3= wait
void setup() {
pinMode(STAT1,OUTPUT);
pinMode(STAT2,OUTPUT);
pinMode(BUTTON1,INPUT);
pinMode(BUTTON2,INPUT);
pinMode(BUTTON3,INPUT);
digitalWrite(BUTTON1,HIGH);
digitalWrite(BUTTON2,HIGH);
digitalWrite(BUTTON3,HIGH);
for(int i = 0;i < 10;i++) // flash MIDI Sheild LED’s on startup
{
digitalWrite(STAT1,HIGH);
digitalWrite(STAT2,LOW);
delay(30);
digitalWrite(STAT1,LOW);
digitalWrite(STAT2,HIGH);
delay(30);
}
digitalWrite(STAT1,HIGH);
digitalWrite(STAT2,HIGH);
//start serial with midi baudrate 31250
Serial.begin(31250);
}
void loop () {
//*************** MIDI OUT ***************//
pot = analogRead(0);
note = pot/8; // convert value to value 0-127
if(button(BUTTON1) || button(BUTTON2) || button(BUTTON3))
{
Midi_Send(0x90,note,0x45);
while(button(BUTTON1) || button(BUTTON2) || button(BUTTON3));
}
//*************** MIDI LOOPBACK ******************//
if(Serial.available() > 0)
{
byte1 = Serial.read();
byte2 = Serial.read();
byte3 = Serial.read();
Midi_Send(byte1, byte2, byte3);
}
//***************
MIDI IN ***************//
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
{
action = OFF;
}
else if (incomingByte== 128) // Note off
{
action = ON;
}
else if (note==0 && action != WAIT) // note on, wait for note value
{
note=incomingByte;
}
else if (note!=0 && action != WAIT) // velocity
{
velocity=incomingByte;
if(action == ON){
Midi_Send(0x90,note,velocity);
}
if(action == OFF){
Midi_Send(0x80,note,velocity);
}
note=0;
velocity=0;
action=WAIT;
}
else{
}
}
}
void Midi_Send(byte cmd, byte data1, byte data2) {
Serial.print(cmd, BYTE);
Serial.print(data1, BYTE);
Serial.print(data2, BYTE);
}
void blink(){
digitalWrite(STAT1, HIGH);
delay(100);
digitalWrite(STAT1, LOW);
delay(100);
}
char button(char button_num)
{
return (!(digitalRead(button_num)));
}[/vc_column_text][/vc_tab][/vc_tour][/vc_column][/vc_row]
Leave a Reply
You must be logged in to post a comment.