Take back control of your electronic setup with our small, smart music tools: The RK002 Smart MIDI Processor cable, RK006 all-connecting music hub and RK008 Realtime MIDI Recorder!

Retrokits / RK-002 MIDI Processing? Just DUY it!

Writing sketches

The RK002 is not an Arduino board in the traditional sense (for example: it doesn’t have LEDs or GPIO etc.). Basically we’ve implemented the relevant parts of the Arduino platform in the RK002 support package:

  • Time
  • Math
  • Trigonometry
  • Characters
  • Random Numbers
  • Bits and Bytes
  • Communication (serial)

but not: (makes no sense on the RK002)

  • Digital I/O
  • Analog I/O
  • Zero, Due or MKR Family
  • External Interrupts
  • Interrupts
  • USB

more information about these functions can be found here: https://www.arduino.cc/reference

The only possible communication with the outside world is through the MIDI input and MIDI output ports. MIDI communication is realized by means of Arduino’s serial port. In principle the RK002 support package brings you a naked Arduino-ready platform, on which you can implement user-defined sketches.

In order to actually implement useful MIDI sketches it’s needed to process MIDI input, and to generate valid MIDI output. On the RK002 cable you have 2 choices for developing your Arduino sketch:

  1. using the standard Arduino MIDI library
  2. using our RK002 support library

Writing RK002 sketches using the standard Arduino MIDI library

RK002’s serial port is directly compatible with the standard MIDI library, so all sketches using the library should work without the need to adapt. Drawback of using this library is that is could be a bit hard to learn, and the functionality of this library is not directly tailored for the typical usage inside a RK002 cable. For more information see: https://playground.arduino.cc/Main/MIDILibrary

Writing RK002 sketches using the Retrokits RK002 library

Using the general purpose MIDI library can be a bit cumbersome, because the functionality is not explicitly tailored for the typical RK002 use-case.
Therefore we’ve implemented the Retrokits RK002 library which is specifically suited for writing simple MIDI processors.

The most simple RK002 Arduino sketch is listed below:

#include <rk002.h>

RK002_DECLARE_INFO("SAMPLE CODE","duy@retrokits.com","1.0","7b47d3dd-991a-4197-ac02-d340cdabfb59")

void setup()

// the main loop
void loop()

The sketch basically consists of the most trivial Arduino sketch with calling the RK002 library’s setup and loop functions. This will result in-effect a MIDI-thru cable 🙂 = all MIDI data arriving at the input will be put through to the output, and no processing is done.

In order to process the MIDI stream it’s necessary to implement callback functions. These functions have to be named using the specific reserved RK002’s names:

#include <RK002.h>

RK002_DECLARE_INFO("SAMPLE CODE","duy@retrokits.com","1.0","7b47d3dd-991a-4197-ac02-d340cdabfb59")

boolean RK002_onNoteOn(byte channel, byte key, byte velocity)
  RK002_sendNoteOn(channel, key+7, velocity);
  return true;

boolean RK002_onNoteOff(byte channel, byte key, byte velocity)
  RK002_sendNoteOff(channel, key+7, velocity);
  return true;

void setup()

void loop()

In the above example:

  • two callback functions (for MIDI note-on and note-off messages) are defined.
  • an example of MIDI processing is implemented here: every note-message (note on and note off) will be preceded with a note message where it’s key is transposed by 7 notes; this should give a nice half-octave doubler effect.
  • both callback functions return ‘true’ to indicate that the original received message should be sent-thru,

By the way: If you want a short and technical roundup on the MIDI commands: Here is a list of messages and how they are constructed: ccrma.stanford.edu/~craig/articles/linuxmidi/misc/essenmidi.html

Shopping cart0
There are no products in the cart!
Continue shopping