Skip to content

Migration from v1.* to v2.*

lathoub edited this page Feb 22, 2020 · 1 revision

Version 2 of this library is not backward compatible with the API from version 1.*. Reason is the adoption of the calling syntax of the 47effect Arduino MIDI library. Another reason is that MIDI and rtpMIDI/AppleMIDI are separate modules; in fact: rtpMIDI/AppleMIDI is just another transport mechanism for the MIDI protocol, just like USB, BT or the default serial.

Declaration

Previously APPLEMIDI_CREATE_DEFAULT_INSTANCE(); created an instance called AppleMIDI and the session name was given in the begin part of the sketch. The new version create 2 objects: AppleMIDI and MIDI, respectively dealing with the AppleMIDI protocol and MIDI protocol. The session name defaults to 'Arduino'. Just like with any other MIDI application, the channel is given in setup(). If you would like to change the session name (or default UDP port), use APPLEMIDI_CREATE_DEFAULT_INSTANCE.

APPLEMIDI_CREATE_DEFAULT_INSTANCE(); becomes APPLEMIDI_CREATE_DEFAULTSESSION_INSTANCE();

setup()

The session name is provided in de declaration to the AppleMIDI protocol. In the setup the channel number is provided. This approach is much cleaner than in version 1.*

AppleMIDI.begin("test"); becomes MIDI.begin(1);

loop()

Both protocols are separated conceptually (using static polymorphism) and each have their object instance: AppleMIDI and MIDI. In version 1.* both protocols were served using a single AppleMIDI instance.

AppleMIDI.read(); becomes MIDI.read();

The C# style On* for events, was replaced with the callback style from the 47effects library: AppleMIDI.OnConnected(OnAppleMidiConnected); becomes AppleMIDI.setHandleConnected(OnAppleMidiConnected);

AppleMIDI.sendNoteOn(note, velocity, channel); becomes MIDI.sendNoteOn(note, velocity, channel);