Sending and Receiving with usbMIDI.read

Status
Not open for further replies.

nicnut

Well-known member
Hi,

I am attempting to make a midi controller with 14 analog inputs and 11 digital outputs (LEDs).

In my void loop() I need usbMIDI.read(MIDIchannel); because I only want to receive midi messages on a specified channel to control the LEDs.

To create my code I altered some of the example code for analog inputs and at the bottom of the example I see this:

Code:
void loop() {
 

  // MIDI Controllers should discard incoming MIDI messages.
  // http://forum.pjrc.com/threads/24179-Teensy-3-Ableton-Analog-CC-causes-midi-crash
  while (usbMIDI.read()) {
    // ignore incoming messages
  }
}

So I can't have both of these instructions for usbMIDI.read, and I can't ignore the incoming midi messages because I need them.

I read the link provided, which details midi messages piling up. If I am actually reading the incoming midi messages will the Midi messages still pile up and create a crash or delay in midi?

thank you.

Nick
 
This message is specific to MIDI controllers where you might assume you don't need to call read() at all.

If you are processing incoming elsewhere with a read() then you already are avoiding the problem this note is aimed at.
 
If I am actually reading the incoming midi messages will the Midi messages still pile up and create a crash or delay in midi?

Reading one specific channel is fine. It will discard any & all messages from the other 15 channels.

You only need that example message-discard code when making an output-only MIDI controller.
 
@oddson, Yes I am using midi to control LEDs, but I am also using analog inputs for potentiometers. The LEDs are for getting visual feedback.

I am also using 2 Teensys in this controller and the other one is using more analog inputs and digital inputs for buttons, as there are not enough digital inputs on one teensy. I know there are ways to increase the inputs but this way was easier for me. And the two Teensys are on different midi channels.

I'm hoping to finish this up in a few days and I can post some images. I have a few more issues which I might post about soon, but I'm still installing all the sensors and LEDs. Thank you for all your suggestions, they have been extremely helpful.
 
Status
Not open for further replies.
Back
Top