How to declare usbMIDI and beatClock

Hi Community,

i think i have a simple Problem but cant solve it on my own.
i started building a MIDI-controller on a teensy 3.2 with Arduino IDE, when i realized that its gonna be more Code then i thought, i wanted to switch to Platformio running on Atom, because of some reason you all know :wink:

so i take the code from the .ino file i wrote in Arduino IDE, copy/paste it to main.cpp include the Arduino.h library and the Midi.h library with

> #include <Arduino.h>
> #include <MIDI.h>

the files for the library are under /lib

platformio run
Compiling .pioenvs\teensy31\FrameworkArduino\pins_teensy.o
Compiling .pioenvs\teensy31\FrameworkArduino\ser_print.o
Compiling .pioenvs\teensy31\FrameworkArduino\serial1.o
src\main.cpp: In function 'void setup()':
src\main.cpp:32:3: error: 'usbMIDI' was not declared in this scope
usbMIDI.setHandleRealTimeSystem(beatClock);
^
src\main.cpp:32:35: error: 'beatClock' was not declared in this scope
usbMIDI.setHandleRealTimeSystem(beatClock);
^
src\main.cpp: In function 'void loop()':
src\main.cpp:50:3: error: 'usbMIDI' was not declared in this scope
usbMIDI.read();
^
*** [.pioenvs\teensy31\src\main.o] Error 1
 [ERROR] Took 3.17 seconds
 
Linter
Severity 	Provider 	Description	Line 
Error	Build	error: 'usbMIDI' was not declared in this scopee	32:3
Error	Build	error: 'beatClock' was not declared in this scopee	32:35
Error	Build	error: 'usbMIDI' was not declared in this scopee	50:3

i tried to put the files in /src/includes and project/inlcudes but didnt change a thing :frowning:
i cant even figure out if it is a library problem, a declaration problem,…

as you can see i’m pretty new to all of Arduino, Code, Platformio etc. so please help me to work on my project.

thank you Chris

Maybe this will help

1 Like

Well followed the link:

adding:

> void beatClock(byte realtimebyte);

was helping to declare beatClock :heart_eyes:

how to declare usbMIDI is still not clear to me, thank u for the help i gonna stay on ArduinoIDE i thought Platformio would make things easier… stuff is just getting more complicated to me

Why don’t youe want to use INO files without changes? PlatformIO works with INO files too.

> platformio run
> Looking for dependencies...
> No dependencies
> Compiling .pioenvs\teensy31\src\aufger_umt_16_led__ber_2_595.ino.o
> Compiling .pioenvs\teensy31\FrameworkArduino\AudioStream.o
> Compiling .pioenvs\teensy31\FrameworkArduino\DMAChannel.o
> Compiling .pioenvs\teensy31\FrameworkArduino\EventResponder.o
> Compiling .pioenvs\teensy31\FrameworkArduino\HardwareSerial1.o

> C:/Users/Chris/Documents/PlatformIO/Projects/171126-205858-teensy31/src/aufger_umt_16_led__ber_2_595.ino: In function 'voi
> d setup()':
> C:/Users/Chris/Documents/PlatformIO/Projects/171126-205858-teensy31/src/aufger_umt_16_led__ber_2_595.ino:26:3: error: 'usb
> MIDI' was not declared in this scope
> usbMIDI.setHandleRealTimeSystem(beatClock);
> ^
> C:/Users/Chris/Documents/PlatformIO/Projects/171126-205858-teensy31/src/aufger_umt_16_led__ber_2_595.ino: In function 'voi
> d loop()':
> C:/Users/Chris/Documents/PlatformIO/Projects/171126-205858-teensy31/src/aufger_umt_16_led__ber_2_595.ino:45:3: error: 'usb
> MIDI' was not declared in this scope
> usbMIDI.read();
> ^
> *** [.pioenvs\teensy31\src\aufger_umt_16_led__ber_2_595.ino.o] Error 1
>  [ERROR] Took 3.32 seconds

doesnt really work for me

See Teensy — PlatformIO latest documentation

build_flags = -D USB_MIDI

> platformio run
> Compiling .pioenvs\teensy31\FrameworkArduino\WMath.o
> Compiling .pioenvs\teensy31\FrameworkArduino\WString.o
> Compiling .pioenvs\teensy31\FrameworkArduino\analog.o
> C:/Users/Chris/Documents/PlatformIO/Projects/171126-205858-teensy31/src/aufger_umt_16_led__ber_2_595.ino:3:1: error: 'buil
> d_flags' does not name a type

> build_flags = -D USB_MIDI
> ^
> C:/Users/Chris/Documents/PlatformIO/Projects/171126-205858-teensy31/src/aufger_umt_16_led__ber_2_595.ino: In function 'voi
> d setup()':
> C:/Users/Chris/Documents/PlatformIO/Projects/171126-205858-teensy31/src/aufger_umt_16_led__ber_2_595.ino:27:3: error: 'usb
> MIDI' was not declared in this scope
> usbMIDI.setHandleRealTimeSystem(beatClock);
> ^
> C:/Users/Chris/Documents/PlatformIO/Projects/171126-205858-teensy31/src/aufger_umt_16_led__ber_2_595.ino: In function 'voi
> d loop()':
> C:/Users/Chris/Documents/PlatformIO/Projects/171126-205858-teensy31/src/aufger_umt_16_led__ber_2_595.ino:39:3: error: 'usb
> MIDI' was not declared in this scope
> usbMIDI.read();
> ^
> C:/Users/Chris/Documents/PlatformIO/Projects/171126-205858-teensy31/src/aufger_umt_16_led__ber_2_595.ino: In function 'voi
> d beatClock(byte)':
> C:/Users/Chris/Documents/PlatformIO/Projects/171126-205858-teensy31/src/aufger_umt_16_led__ber_2_595.ino:44:22: error: 'ST
> ART' was not declared in this scope
> if(realtimebyte == START) { zaehler = 0; zeitAlt = millis(); }
> ^
> Compiling .pioenvs\teensy31\FrameworkArduino\avr_emulation.o
> *** [.pioenvs\teensy31\src\aufger_umt_16_led__ber_2_595.ino.o] Error 1
>  [ERROR] Took 3.34 seconds

It should be added to platformio.ini.

1 Like

Thank you very much ivankravets! you spend enough time to help a noob like me. Lets keep on building my own MIDI-controller :musical_score:

Does it work now? Please give us a star :star: here

yes it works :beers: from now on programming on PlatformIO. :dizzy: Star done!
Thanks again!

1 Like