USB Composite library MIDI
Posted: Mon Jan 27, 2020 10:14 am
Hey all!
Had a question about working with the midi portion of the USB composite library. I'm trying to set up a piece of code that when a certain midi note is receive will spit out a different midi note here is my code:
Now this code does not compile because when i do midi.sendNoteOn, "midi" hasnt been declared yet. basically i'm wondering if theres a way to make this work more along the lines of the regular arduino midi library. where i can send a receive midi information without having to poll and make a class with event handlers.
Had a question about working with the midi portion of the USB composite library. I'm trying to set up a piece of code that when a certain midi note is receive will spit out a different midi note here is my code:
Code: Select all
#include <USBComposite.h>
class myMidi : public USBMIDI {
virtual void handleNoteOff(unsigned int channel, unsigned int note, unsigned int velocity) {
if((channel == 0) && ( note == 0x00) && (velocity == 0x00)){
midi.sendNoteOn(0, 0x00, 0x7f);
}
}
virtual void handleNoteOn(unsigned int channel, unsigned int note, unsigned int velocity) {
}
};
myMidi midi;
USBCompositeSerial CompositeSerial;
void setup() {
USBComposite.setProductId(0x0030);
midi.registerComponent();
CompositeSerial.registerComponent();
USBComposite.begin();
}
void loop() {
midi.poll();
}