User:1sfoerster/enes100/fall2013/p2music/Midi-Channels

void setup { Serial.begin(31250); //MIDI protocol baud rate is 31250 bits per second } void loop { // channel 0 alto sax (65) 0xC0,0x41 Serial.write(0xC0); Serial.write(0x41); // channel 1 piano 0 0xC1,0x00 Serial.write(0xC1); Serial.write(0x00); // channel 9 drums 0 Serial.write(0xC9); Serial.write(0x00);

//t=0 ... from www.music-software-development.com/midi-tutorial.html noteOn(0x90, 0x48, 0x40); // start sax noteOn(0x91, 0x3C, 0x40); //start piano noteOn(0x91, 0x43, 0x40); //start piano noteOn(0x91, 0x4C, 0x40); //start piano noteOn(0x99, 0x23, 0x7F); //start bass drum delay(414); //t=1 noteOn(0x90, 0x48, 0x00); //stop sax noteOn(0x99, 0x23, 0x00); //stop bass drum noteOn(0x90, 0x4A, 0x40); //start sax delay(414); //t=2 noteOn(0x90, 0x4A, 0x00); //stop sax noteOn(0x90, 0x4C, 0x40); //start sax noteOn(0x99, 0x23, 0x7F); //start bass drum delay(414); //t=3 noteOn(0x90, 0x4C, 0x00); //stop sax noteOn(0x99, 0x23, 0x00); //stop bass drum noteOn(0x90, 0x4F, 0x40); //start sax delay(414);

//t=4 noteOn(0x90, 0x4F, 0x00); //start sax noteOn(0x91, 0x3C, 0x40); //play cord again noteOn(0x91, 0x43, 0x40); //play cord again noteOn(0x91, 0x4C, 0x40); //play cord again delay(2000); //End song //Wait 2 seconds after the last note is struck to repeat } void noteOn(int cmd, int pitch, int velocity) { //Sets what each of the 3 values in the "noteOn" function does Serial.write(cmd); //All MIDI protocol messages start with 0x90 to signify the start of a MIDI message Serial.write(pitch); //The note. Middle C (0x3C), for example Serial.write(velocity); //Length of time the note is played. Values range from 0 to 127 (0x64), for example }