Enables an Arduino with IP/UDP capabilities (Ethernet shield, ESP8266, ESP32, ...) to particpate in an AppleMIDI session.
- Tested with AppleMIDI on Mac OS (High Sierra) and using rtpMIDI from Tobias Erichsen on Windows 10
- Send and receive all MIDI messages
- Uses callbacks to receive MIDI commands (no need for polling)
- Automatic instantiation of AppleMIDI object (see at the end of 'AppleMidi.h')
From the Arduino IDE Library Manager, search for AppleMIDI
#include "AppleMidi.h"
APPLEMIDI_CREATE_DEFAULT_INSTANCE();
void setup()
{
// ...setup ethernet connection
AppleMIDI.begin("test"); // 'test' will show up as the session name
}
void loop()
{
AppleMIDI.run();
// ...
// Send MIDI note 40 on, velocity 55 on channel 1
AppleMIDI.sendNoteOn(40, 55, 1);
}
More usages in the examples
folder
- Arduino/Genuino (Mega, Uno, Arduino Ethernet, MKRZERO, ...)
- ESP8266 (Adafruit HUZZAH ESP8266, Sparkfun ESP8266 Thing Dev)
- ESP32 (Adafruit HUZZAH32 – ESP32 Feather Board)
- Teensy 3.2
- Adafruit Feather M0 WiFi - ATSAMD21 + ATWINC1500
The code has been pseudo optimized to minimize the memory footprint.
Internal buffers also use valuable memory space. The biggest buffer PACKET_MAX_SIZE
is set to 350 by default in AppleMidi_Settings.h
. Albeit this number is somewhat arbitratry (large enough to receive full SysEx messages), it can be reduced significantly if you do not have to receive large messages.
On an Arduino, 2 sessions can be active at once (W5100 can have max 4 sockets open at the same time, each session needs 2 UDP sockets). Setting MAX_SESSIONS to 1 saves 228 bytes (each session takes 228 bytes).
Save memory (about 2000 bytes) when the device does not initiate sessions by #undef APPLEMIDI_REMOTE_SESSIONS
in AppleMidi_Settings.h
. See the EthernetShield_NoteOnOffEverySec.ino
example
- Arduino Ethernet shield (Wiznet W5100)
- Arduino Wifi R3 shield
- MKR ETH shield
- Teensy WIZ820io W5200
- 1.8.9
I would love to include your enhancements or bug fixes! In lieu of a formal styleguide, please take care to maintain the existing coding style. Please test your code before sending a pull request. It would be very helpful if you include a detailed explanation of your changes in the pull request.