Thanks for the advice. I implemented some changes, per your advice, but my output is very similar to before (and still puzzling).
Revised code: doesn't use SoftwareSerial; reads all input into a buffer, then outputs buffer
void setup() {
Serial1.begin(31250);
Serial.begin(9600);
}
void loop() {
if (Serial1.available()) {
// push serial input onto buffer
while (Serial1.available()) {
byte in = Serial1.read();
pushBuffer(in);
}
// output vector onto monitor
if (bufferLen > 2) {
for (byte i=0; i < bufferLen; i++) {
Serial.print(buffer[i]); Serial.print(" \t ");
}
Serial.println();
clearBuffer();
}
}
}
New output:
243 186 2
243 250 0
19 221 0
19 253 0
51 221 0
51 253 0
83 221 0
83 253 0
115 221 0
115 253 0
147 221 0
147 253 0
179 221 0
179 253 0
211 221 0
211 253 0
243 221 0
243 253 0
19 117 2
19 245 0
51 117 2
51 245 0
83 117 2
83 245 0
115 117 2
115 245 0
This output doesn't show any exact repetition, but it does occur outside of this sample. For instance, 3rd A# above middle C matches 2nd F# above middle C (note on: 51 221 0; note off: 51 253 0).
Have I done something wrong in my code?