Files
loopy_midi_controller/include/midi_transport.h
T
ash 4d81386f78 Fix USB MIDI, add LED startup animation, improve logging
- Use ArduinoUSBMIDI library for proper USB MIDI device recognition
- Add LED startup colour cycle (red, green, blue, yellow, magenta, cyan, white)
- Add comprehensive console logging for all MIDI in/out and switch events
- Log unmapped MIDI messages
2026-06-23 13:06:57 +00:00

44 lines
906 B
C++

#pragma once
#include <cstdint>
#include <functional>
struct MidiEvent {
enum Type {
NOTE_ON,
NOTE_OFF,
CONTROL_CHANGE,
PROGRAM_CHANGE,
PITCH_BEND,
AFTERTOUCH_POLY,
AFTERTOUCH_CHAN,
SYSEX
} type;
uint8_t channel;
uint8_t data1;
uint8_t data2;
uint32_t timestamp;
};
class UsbMidiTransport {
public:
UsbMidiTransport();
~UsbMidiTransport();
bool begin();
void update();
void on_midi_receive(std::function<void(const MidiEvent&)> callback);
void send_note_on(uint8_t channel, uint8_t note, uint8_t velocity);
void send_note_off(uint8_t channel, uint8_t note, uint8_t velocity);
void send_cc(uint8_t channel, uint8_t cc, uint8_t value);
bool is_connected();
private:
std::function<void(const MidiEvent&)> receive_callback;
bool initialized;
};