Why does MIDI.read() pass MIDI from Input to Output?

Status
Not open for further replies.

vanwerk

Member
Hi everyone! I'm working on a MIDI filter using a Teensy 2.0. I've built the DIN MIDI input and output ports according to the schematic on the MIDI Library page here. Using only the code below, I noticed that the Teensy is always passing data from the Input port to the Output port unchanged, regardless from what channel I specify in MIDI.begin() or MIDI.read(). I don't want the Teensy to output any MIDI data unless I explicitly say so, and I'd like to at least understand why this is happening. On to the code:

Code:
#include <MIDI.h>

MIDI_CREATE_INSTANCE(HardwareSerial, Serial1, MIDI);

void setup() {
   MIDI.begin(1); // receive on channel 1
}

void loop() {
   MIDI.read(1);
}

To generate MIDI data, I'm using an Akai MPC1000 playing a simple one-note loop over 2 bars at 120BPM, with some MIDI CC messages sprinkled in. I connected the MPC1000's MIDI Out port to the MIDI In port on my Teensy-based circuit. Regardless of what MIDI channel I output this data from the MPC1000, the Teensy is allowing it to pass through.

Upon commenting out "MIDI.read(1);" the Teensy stopped passing MIDI data through. Therefore, it would appear that MIDI.read() is the culprit. Further, it appears that the argument "1" to the function read() has no bearing on whether data passes through. Any ideas why this is happening?

Lastly, I took a look at "serialMIDI.h" in the MIDI library's src folder, but I didn't gain any further clarity:

Code:
(Line 80) byte read()
(Line 81)	{
(Line 82)		return mSerial.read();
(Line 83)	};
 
The Midi library has Thru turned on by default so to turn it off add this line to void setup();

Code:
MIDI.turnThruOff();
 
The Midi library has Thru turned on by default so to turn it off add this line to void setup();

Code:
MIDI.turnThruOff();

Perfect, thank you! I wish I had a better understanding of how to learn what a given library is capable of... I often find myself aimlessly poking around .h files. Cheers.
 
Status
Not open for further replies.
Back
Top