So, I got a Leonardo because I plan to build a device to draw MIDI CC curves on a touchscreen TFT to be sent over MIDI to a DAW.

I'm in the initial testing stage, and got a basic Paint application to run fine, as well as a basic MIDI application that fires a laser when NoteOn messages are received and shuts it off when the note off message comes through. Those programs both run fine on their own.

The next step was to kind of combine those two programs, to handle MIDI on/off messages AND run the paint program. I've tried a few variations -- running the paint app while also listening on the MIDI channel for the note on/off messages (and firing the laser accordingly), firing the laser when drawing in paint while still listening to MIDI, etc. The programs all upload fine. But when I attempt to set up the MIDI routing from my DAW, I get the error message "Arduino Leonardo: there is not enough memory available for this task. Quite one or more apps to increase available memory."

The setup is this: DAW sends midi to an external virtual MIDI port, and a virtual MIDI routing program listens to that port, routing the output to the Leonardo. The problem arises when trying to connect the virtual port to the leonardo.

Is this a problem with the virtual MIDI software, or the leonardo, and is there a way to optimize my sketch to run? Sketch below:

    #include <MIDI.h>

#if defined(USBCON)
#include <midi_UsbTransport.h>

static const unsigned sUsbTransportBufferSize = 16;
typedef midi::UsbTransport<sUsbTransportBufferSize> UsbTransport;
UsbTransport sUsbTransport;
MIDI_CREATE_INSTANCE(UsbTransport, sUsbTransport, MIDI);

#else // No USB available, fallback to Serial

// --
int laserPin = A5;

void handleNoteOn(byte inChannel, byte inNumber, byte inVelocity)
    digitalWrite(laserPin, HIGH);
    Serial.print("NoteOn  ");
    Serial.print("\tvelocity: ");
void handleNoteOff(byte inChannel, byte inNumber, byte inVelocity)
    digitalWrite(laserPin, LOW);
    Serial.print("NoteOff ");
    Serial.print("\tvelocity: ");

void setup() {
    pinMode(laserPin, OUTPUT);
    while (!Serial);
    Serial.println("Arduino ready.");

void loop() {

I've also tried stripping all the serial.write commands, same result.

Edit: Yes, the error isn't being thrown by the Leo or the IDE; it's coming from MIDI-OX, the software used to route MIDI from my DAW to the Leo. It just sounded like the issue was that the Leo didn't have enough free memory to handle the routing (which doesn't make sense, as AFAIK all that's happening is MIDIOX is making a connection between the digital MIDI out from my DAW and the Leo). Nevertheless, I was hoping to get some pointers on possibly trimming down the memory used by the sketch itself, freeing up space on the Leo to see if it's ACTUALLY an issue with the Leo's memory, or a problem with the midi application.

  • 3
    That message sounds like something no Arduino would ever say. There's no such thing as apps on Arduino. The message must me coming from some other system. – Majenko Dec 13 '19 at 7:41

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.