The McLaren Synth Kit — https://github.com/mclarenlabs/McLarenSynthKit — now includes an RTP-MIDI engine that you can include in your own projects. The engine is the same one that is in our well-known rtpmidi product! We’re providing the library so that you can set up RTP-MIDI connections as you like.
Background
We sometimes receive requests from users to add features to McLaren Labs’ rtpmidi
product to handle connections in a certain way. Some users might want to automatically find a particular endpoint or address. Another user might want automatic re-connect in a certain situation. Others want to experiment by translating events from non-MIDI sources into note events sent to a synthesizer on their network.
The McLaren MIDI Kit (MMK) makes all of this possible. It provides a simple interface to set-up and tear-down connections, and to send and receive MIDI events. Behind the scenes, the McLaren MIDI Kit performs the networking and bookkeeping to keep the connection flowing smoothly.
Example
Let’s say you wanted to advertise an RTP-MIDI service on your network that receives Note On and Off messages and invokes a corresponding functon to turn one of 64 lights On or Off a light. The light functions are called light_on
and light_off
and take a number corresponding to which light.
First, initialize the engine. The engine takes a parameter that specifies which port it is listening on. By default, the engine will advertise itself via Bonjour on the local network on that port.
#import "McLarenMidiKit/McLarenMidiKit.h"
NSError *err;
MMKEngine *engine = [[MMKEngine alloc] initWithPort:5006 error:&err];
Next, register a callback block to handle the notes. The callback extracts the note from the message.
// handle arriving events
[engine onSequencerEventReceived:^(ASKSeqEvent *evt) {
NSLog(@"event:%@", evt);
if (evt->_ev.type == SND_SEQ_EVENT_NOTEON) {
uint8_t note = evt->_ev.data.note.note;
if (note < 64) {
light_on(note);
}
}
if (evt->_ev.type == SND_SEQ_EVENT_NOTEOFF) {
uint8_t note = evt->_ev.data.note.note;
if (note < 64) {
light_off(note);
}
}
}];
Finally, launch the engine running in the background. It takes care of opening the UDP port, advertising the Bonjour service and everything else.
// start the engine
[engine start];
Detailed Examples
We have a couple of more examples on GitHub. Check out this link for some cool demos.
https://github.com/mclarenlabs/McLarenSynthKit/tree/main/examples-mmk
Doing More
There are a number of configuration options for setting the session name advertised on the network and for examining participants as they join and leave the running engine. You can read a lot more about its options here.
https://mclarenlabs.github.io/McLarenSynthKit/mmk-over/
Have fun, and let us know what you come up with!