USB MIDI Example sketches are missing from my TeensyLC install, Plz help!

Status
Not open for further replies.

IPFreely

Member
I picked up a teensyLC for a MIDI project and the USB MIDI examples seem to be missing from my install. I do see a huge list of examples that installed and there is one for USBHost_t36 but the main USB MIDI examples that I keep seeing referenced in threads here seems to be missing. Is there a way I can get my hands on it? I really need to read through them. :)

Currently I'm trying to get a simple two button sketch to mate up with FL Studio and it isn't working. However, it does send the proper commands to a monitor app so it almost works! I've had it working with UNO but I think I'm initiating the midi part wrong with teensy but I can't find an example that makes it clear. My understanding is that I only need to have const int channel = 1; at the top and while (usbMIDI.read()) {} delay(25); added at the bottom. However, I'm also playing around with Serial.begin(9600); since I see it so often in other sketches but I'm not clear if I need to have that or not. (I've also seen this: while (usbMIDI.read()); delay(25); which is a different syntax than my first example. It closes with ; instead of {} I'm not sure which one is correct.) I was hoping to hack it together with the official examples but they didn't install. Thanks In Advance! Here is my nooby code for reference:

const int LEDA = 11;
const int LEDB = 12;
const int buttonPinA = 7;
const int buttonPinB = 6;
int buttonStateA = 0;
int buttonStateB = 0;
int lastButtonStateA = 0;
int lastButtonStateB = 0;
int toggleStateA = 0;
int toggleStateB = 0;
const int channel = 1;

void setup () {
Serial.begin(9600);
pinMode (buttonPinA, INPUT);
pinMode (LEDA, OUTPUT);
pinMode (buttonPinB, INPUT);
pinMode (LEDB, OUTPUT);
}

void loop () {
buttonStateA = digitalRead (buttonPinA);
buttonStateB = digitalRead (buttonPinB);

// check whether the input is HIGH (button pressed)
if (buttonStateA == HIGH){
digitalWrite (LEDA,HIGH); // turn LED on
}else{
digitalWrite (LEDA,LOW);
}

if (buttonStateA != lastButtonStateA && buttonStateA == 1 && toggleStateA == 0) {
usbMIDI.sendControlChange (1, 127, 1);
delay (50);
toggleStateA = 1;
}
else if (buttonStateA != lastButtonStateA && buttonStateA == 1 && toggleStateA == 1) {
usbMIDI.sendControlChange (1, 0, 1);
delay (50);
toggleStateA = 0;
}
lastButtonStateA = buttonStateA;

// check whether the input is HIGH (button pressed)
if (buttonStateB == HIGH){
digitalWrite (LEDB,HIGH); // turn LED on
}else{
digitalWrite (LEDB,LOW);
}

if (buttonStateB != lastButtonStateB && buttonStateB == 1 && toggleStateB == 0) {
usbMIDI.sendControlChange (2, 127, 1);
delay (50);
toggleStateB = 1;
}
else if (buttonStateB != lastButtonStateB && buttonStateB == 1 && toggleStateB == 1) {
usbMIDI.sendControlChange (2, 0, 1);
delay (50);
toggleStateB = 0;
}
lastButtonStateB = buttonStateB;
while (usbMIDI.read()) {} // read and discard any incoming MIDI messages
delay(25);
}
 
You might simply be looking in the wrong place - they are in the teensy part of the menu, not the libraries part.

midi-examples.jpg
 
Are you using Mac, Windows or Linux?

I'm using windows.

Thanks Nantonos, you are correct that I was looking in the wrong spot. I didn't realize there are two different sets of Teensy examples, the list is so long it's easy to miss that I guess. I must have read about the TeensyLC set and went right to that not realizing there is another separate set. Thanks!
 
Status
Not open for further replies.
Back
Top