<html><head><style type="text/css"><!-- DIV {margin:0px;} --></style></head><body><div style="font-family:times new roman,new york,times,serif;font-size:12pt"><div>Let's try this again, without the attachments. You can find them at the provided link.<br></div><div style="font-family: times new roman,new york,times,serif; font-size: 12pt;"><br><div style="font-family: times new roman,new york,times,serif; font-size: 12pt;"><font size="2" face="Tahoma">----- Forwarded Message ----<br><b><span style="font-weight: bold;">From:</span></b> Hans Lindauer <armatronix@sbcglobal.net><br><b><span style="font-weight: bold;">To:</span></b> dorkbotpdx-blabber@dorkbot.org<br><b><span style="font-weight: bold;">Sent:</span></b> Sunday, April 5, 2009 10:41:47 AM<br><b><span style="font-weight: bold;">Subject:</span></b> Programming Help Needed Please<br></font><br>
<div style="font-family: times new roman,new york,times,serif; font-size: 12pt;">
<div style="font-family: times new roman,new york,times,serif; font-size: 12pt;"><div>OK, I have (hopefully) one line to program to finish my re-write of my MIDI lights firmware. It's the line that modifies the MIDI library so that it passes any incoming bytes to the THRU port.<br><br>In my old program, I just did a Serial.read follower by a Serial.print, as follows:<br><br>void loop () {<br> if (Serial.available() > 0) {<br> newbyte = Serial.read(); // read the incoming byte<br> Serial.print(newbyte); // echo the incoming byte<br>...<br><br>I tried that again here, but with no luck. Then I looked at how they send data to the serial port for MIDI OUT in the library, and saw that they use a slightly different syntax: serial_.print (b, TYPE). So I tried adding that instead, as follows. I've included an extra snippet that shows how they're doing it, for context. My line is the one
with the asterisks. I assumed that I could ignore the type argument, since I'm just passing the (int) variable c straight thru. (I also tried it as INT and BYTE types):<br><br><br>// Try to read data at serial port & pass anything read to processing function<br>void Midi::poll(void)<br>{<br> int c;<br><br> // Just keep sucking data from serial port until it runs out, processing<br> // MIDI messages as we go<br> while((c = serial_.read()) != -1) {<br> recvByte(c);<br> serial_.print(c); // ***** pass MIDI data THRU *****<br> }<br>}<br><br><br>// Send Midi NOTE OFF message to a given channel, with note 0-127 and velocity 0-127<br>void Midi::sendNoteOff(unsigned int channel, unsigned int note, unsigned int velocity)<br>{<br> int status =
STATUS_EVENT_NOTE_OFF | ((channel - 1) & 0x0f);<br> <br> if (sendFullCommands_ || (lastStatusSent_ != status)) {<br> serial_.print(status, BYTE);<br> }<br> <br> serial_.print(note & 0x7f, BYTE);<br> serial_.print(velocity & 0x7f, BYTE);<br>}<br><br><br><span>If it helps to see the full library code from <a target="_blank" href="http://timothytwillman.com/?page_id=240">http://timothytwillman.com/?page_id=240</a>, it's attached (this snippet is in midi.cpp). Please let me know if you have any ideas. By the way, this MIDI library seems to work pretty well otherwise (with only one light).</span><br><br>Thanks,<br>-Hans<br></div></div></div></div></div></div></body></html>