KLST_PANDA features a so-called analog or serial MIDI interface for intput and output via two audio jacks ( see Technical Specifications ):

  • ㉑ :: MIDI out ( analog )
  • ㉒ :: MIDI in ( analog )
void midi_note_on(uint8_t channel, uint8_t note, uint8_t velocity);
void midi_note_off(uint8_t channel, uint8_t note, uint8_t velocity);
void midi_event(SerialDevice* serial_device);

bool midi_init();
void midi_deinit();
void midi_send(const uint8_t* data, uint16_t length);

@TODO( MIDI is missing some callbacks basic callbacks like midi_sysex, midi_control_change, midi_program_change and clock functions )

note, that there is also a USB-based MIDI interface, that allows to connect the board as a USB device to a host or act as a host for USB MIDI devices.

Example MIDI

/**
 * this example demonstrates how to use the debugging console to print messages to the serial console.
*/

#include <string>

#include "Arduino.h"
#include "System.h"
#include "Console.h"
#include "MIDI.h"
#include "KlangstromMIDIParser.h"

SerialDevice* serial_IDC_01;

void midi_note_on(uint8_t channel, uint8_t note, uint8_t velocity) {
    console_println("Note on: Channel %i, Note %i, Velocity %i", channel, note, velocity);
}

void setup() {
    system_init();
    midi_init();
    serial_IDC_01 = serialdevice_create(SERIAL_DEVICE_TYPE_IDC_01, 64, 115200);
}

void loop() {
    uint8_t note_on_data[3] = {0x90, 0x3C, 0x40};
    //    serialdevice_send(serial_IDC_01, (uint8_t*) note_on_data, 3);
    serialdevice_send(serial_IDC_01, (uint8_t*) note_on_data, 1);
    serialdevice_send(serial_IDC_01, (uint8_t*) (note_on_data + 1), 1);
    serialdevice_send(serial_IDC_01, (uint8_t*) (note_on_data + 2), 1);

    uint8_t note_off_data[3] = {0x80, 0x3C, 0x00};
    midi_send((uint8_t*) note_off_data, 3);

    console_println("...");
    delay(1000);
}