USB-MIDI
Hi
Im developing a USB-MIDI musical project using the Teensy 3.2. I have wrote a very basic program that plays a middle C in Musescore when I press a button on my electronic circuit that is connected to the Teensy board.
My question is, when I send a ubMIDI send program change to musescore, to change the instrument type, this has no effect and Musescore continues to use the Default piano instrument.
Could you explain if this is in fact possible, or am I doing something incorrect with my code, see below code:
include // Bounce library makes button change detection easy
include // MIDI Library
const int channel = 1;
Bounce button1 = Bounce(1, 5); // 5 = 5 ms debounce time, which is appropriate for good quality mechanical pushbuttons
void setup() {
pinMode(1, INPUT_PULLUP);
}
void loop() {
button1.update();
// Note On messages when each button is pressed
if (button1.fallingEdge()) {
usbMIDI.sendNoteOn(72, 99, channel); // 60 = C4 //usbMIDI.sendNoteOn(note, velocity, channel)
usbMIDI.sendProgramChange(65, channel);
usbMIDI.sendPitchBend(50, channel);
}
// Note Off messages when each button is released
if (button1.risingEdge()) {
usbMIDI.sendNoteOff(72, 0, channel); // 60 = C4
}
// MIDI Controllers should discard incoming MIDI messages.
while (usbMIDI.read()) {
}
}
Comments
The html sanitiser ate your headers' names, since it is between < and > You must just add it again. To get code highlighting, I enclosed the code in <cpp> tags.
In reply to #include // Bounce library… by Louis Cloete
In fact my code didn't paste properly, so I have added a screen shot, see attached file.
If you can advise me why the usbMIDI.sendProgramChange doesn't work that would be very helpful.