Enables an Arduino with IP/UDP capabilities (Ethernet shield, ESP8266, ESP32, ...) to particpate in an AppleMIDI session.
- Build on top of the popular FortySevenEffects MIDI library
- Tested with AppleMIDI on Mac OS (Catalina) 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')
- Compiles on Arduino, MacOS (XCode) and Windows (MSVS)
From the Arduino IDE Library Manager, search for AppleMIDI
This will also install FortySevenEffects MIDI library
#include <Ethernet.h>
#include <AppleMIDI.h>
APPLEMIDI_CREATE_DEFAULTSESSION_INSTANCE();
void setup()
{
MIDI.begin();
// Optional
AppleMIDI.setHandleConnected(OnAppleMidiConnected);
}
void loop()
{
// Listen to incoming notes
MIDI.read();
// Send MIDI note 40 on, velocity 55 on channel 1
MIDI.sendNoteOn(40, 55, 1);
}
void OnAppleMidiConnected(uint32_t ssrc, const char* name) {
}
APPLEMIDI_CREATE_DEFAULTSESSION_INSTANCE();
creates 2 instance: MIDI
and AppleMIDI
. MIDI
is the instance that manages all MIDI interaction, AppleMIDI
is the instance this manages the rtp transport layer.
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
This library is not using any dynamic memory allocation methods - all buffers have a fixed size, set in the AppleMIDI_Settings.h
file, avoiding potential memory leaks and memory fragmentation.
The minimum buffer size (MaxBufferSize
) should be set to 64 bytes (also the default). Setting it to a higher value will make sending larger SysEx messages more efficiant (large SysEx messages are chopped in pieces, the larger the buffer, the less pieces needed), at the price of a bigger memory footprint.
MaxNumberOfParticipants
is another way to cut memory - each particpants uses approx 300 bytes. Default number of participants is 1 (using 2 sockets).
Beware: the number of sockets on the Arduino is limited. The W5100 support 4, the W5200 and W5500 based IP chips can use 8 sockets. (Each participant uses 2 sockets: port 5004 and 5004+1). (Base port can be set in APPLEMIDI_CREATE_DEFAULT_INSTANCE
)
- Arduino Ethernet shield (Wiznet W5100 and W5500)
- Arduino Wifi R3 shield
- MKR ETH shield
- Teensy WIZ820io W5200
- 1.8.10
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.