54 lines
1.3 KiB
C++
54 lines
1.3 KiB
C++
#pragma once
|
|
|
|
#include "MIDI_Interface.hpp"
|
|
#include <MIDI_Parsers/USBMIDI_Parser.hpp>
|
|
|
|
#include "tusb.h"
|
|
|
|
BEGIN_CS_NAMESPACE
|
|
|
|
struct TinyUSBPuller {
|
|
uint8_t itf;
|
|
bool pull(USBMIDI_Parser::MIDIUSBPacket_t &packet) {
|
|
return tud_midi_n_packet_read(itf, packet.data);
|
|
}
|
|
};
|
|
|
|
class USBMIDI_Interface : public MIDI_Interface {
|
|
public:
|
|
explicit USBMIDI_Interface(uint8_t cable_num = 0)
|
|
: cableNum(cable_num) {}
|
|
|
|
void begin() override {}
|
|
void update() override;
|
|
|
|
MIDIReadEvent read();
|
|
ChannelMessage getChannelMessage() const;
|
|
SysCommonMessage getSysCommonMessage() const;
|
|
RealTimeMessage getRealTimeMessage() const;
|
|
SysExMessage getSysExMessage() const;
|
|
|
|
protected:
|
|
void sendChannelMessageImpl(ChannelMessage msg) override;
|
|
void sendSysCommonImpl(SysCommonMessage msg) override;
|
|
void sendSysExImpl(SysExMessage msg) override;
|
|
void sendRealTimeImpl(RealTimeMessage msg) override;
|
|
void sendNowImpl() override {}
|
|
|
|
private:
|
|
#if !DISABLE_PIPES
|
|
void handleStall() override { MIDI_Interface::handleStall(this); }
|
|
#ifdef DEBUG_OUT
|
|
const char *getName() const override { return "usb"; }
|
|
#endif
|
|
#endif
|
|
|
|
static MIDICodeIndexNumber CIN(uint8_t status);
|
|
void writePacket(uint8_t cin, uint8_t b0, uint8_t b1, uint8_t b2);
|
|
|
|
USBMIDI_Parser parser;
|
|
uint8_t cableNum;
|
|
};
|
|
|
|
END_CS_NAMESPACE
|