Teensy USB MIDI Woes

Hi all,

I have been looking through the forum and google trying to find a solution but so far it’s not working for me. I want to use the usbMIDI that is shown in the docs with my Teensy 3.2. Any help is highly appreciated and welcomed!

I’ve added build_flags = -D USB_MIDI to the platformio.ini and it works. That is, the build succeeds. However, in my main.cpp it’s still giving me error messages:

identifier "usbMIDI" is undefinedC/C++(20)

I’ve tried each of the following includes in main.cpp

#include <MIDIUSB.h>
#include <MIDI.h>
#include <MIDI.hpp>

I’ve tried each of the following configurations in platformio.ini

lib_extra_dirs = ~/Arduino/libraries
lib_ignore = MIDIUSB, Audio
; current platformio.ini -- lib configs are trials (didn't seem to work)
[env:teensy31]
platform = teensy
board = teensy31
framework = arduino
build_flags = -D USB_MIDI -D TEENSY_OPT_FASTEST
lib_extra_dirs = ~/Arduino/libraries
lib_ignore = MIDIUSB, Audio

Full platformio.ini? What Teensy is this even for?

Thank you @maxgerhardt. Updated OP.
tl;dr: Teensy 3.2 with default .ini plus build flags -D USB_MIDI -D TEENSY_OPT_FASTEST and mentioned lib flags.

Compiles for me with your platformio.ini and a basic sketch

#include <Arduino.h>

void setup() {
    usbMIDI.begin();
}

void loop() {
}
Checking size .pio\build\teensy31\firmware.elf
Building .pio\build\teensy31\firmware.hex
Advanced Memory Usage is available via "PlatformIO Home > Project Inspect"
RAM:   [=         ]   5.2% (used 3408 bytes from 65536 bytes)
Flash: [          ]   3.1% (used 8224 bytes from 262144 bytes)
============================= [SUCCESS] Took 1.94 seconds =============================

What’s the full error log when executing a “Build”?

@maxgerhardt Build succeeds,

Checking size .pio/build/teensy31/firmware.elf
Advanced Memory Usage is available via "PlatformIO Home > Project Inspect"
RAM:   [=         ]   6.9% (used 4552 bytes from 65536 bytes)
Flash: [=         ]   5.2% (used 13504 bytes from 262144 bytes)
Configuring upload protocol...
AVAILABLE: jlink, teensy-cli, teensy-gui
CURRENT: upload_protocol = teensy-gui
Uploading .pio/build/teensy31/firmware.hex
=============================================================== [SUCCESS] Took 29.48 seconds ===============================================================

and midi logger shows activity for code usbMIDI.sendNoteOn(1,1,1); which means it’s technically building and uploading okay.

However, the intellisense doesn’t work and it’s showing me errors like this:

Try a Ctrl(Or, command)+Shift+P → Rebuild IntelliSense.

1 Like

As if by magic, that’s done the job! Thank you greatly. Any pointers as to why this was needed? What did I do that required it? Was it the build flag?