Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
main.cpp
00001 // Drums via MIDI! 00002 #include "mbed.h" 00003 #include "USBMIDI.h" 00004 00005 DigitalOut drum[] = {p5, p6, p7, p8}; // the four outputs 00006 00007 void drums(int id, bool on) { 00008 if(id >= 0 && id <= 3) { 00009 drum[id] = on; 00010 } 00011 } 00012 00013 void do_message(MIDIMessage msg) { 00014 switch (msg.type()) { 00015 case MIDIMessage::NoteOnType: 00016 drums(msg.key() - 64, msg.velocity() != 0); 00017 break; 00018 case MIDIMessage::NoteOffType: 00019 drums(msg.key() - 64, 0); 00020 break; 00021 } 00022 } 00023 00024 USBMIDI midi; 00025 00026 int main() { 00027 midi.attach(do_message); // call back for messages received 00028 while (1); 00029 }
Generated on Tue Jul 12 2022 22:46:31 by
