<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD>
<META http-equiv=Content-Type content="text/html; charset=iso-8859-1">
<META content="MSHTML 6.00.2800.1106" name=GENERATOR>
<STYLE></STYLE>
</HEAD>
<BODY bgColor=#f8fcf8>
<DIV><FONT face=Arial size=2>Hi Bill</FONT></DIV>
<DIV><FONT face=Arial size=2></FONT> </DIV>
<DIV><FONT face=Arial size=2>Does your code account for running status? 
</FONT></DIV>
<DIV><FONT face=Arial size=2>I am asking cause this s<FONT face=Arial 
size=2>ounds like a problem with running status to me.</FONT></FONT></DIV>
<DIV><FONT face=Arial size=2>In this case, running status would result in one 
note on status message followed by multiple note-number and velocity value 
bytes.</FONT></DIV>
<DIV><FONT face=Arial size=2>Also not just 3 bytes but:</FONT></DIV>
<DIV><FONT face=Arial size=2>Note on; note number; velo; note number; velo; 
ect.</FONT></DIV>
<DIV><FONT face=Arial size=2></FONT> </DIV>
<DIV><FONT face=Arial size=2>There are two things that make receiving midi notes 
a bit complicated.</FONT></DIV>
<DIV><FONT face=Arial size=2>First there is the running status data 
compression.</FONT></DIV>
<DIV><FONT face=Arial size=2>For even more fun there is also "real time 
messages" that can come in-between the bytes of other messages.</FONT></DIV>
<DIV><FONT face=Arial size=2>A bit less trouble is old Yamaha stuff sending end 
of exclusive messages to check the midi connection, </FONT></DIV>
<DIV><FONT face=Arial size=2>only Bohm and other Yamaha stuff gets messed 
up from this..</FONT></DIV>
<DIV><FONT face=Arial size=2>Fun isn't it?</FONT></DIV>
<DIV><FONT face=Arial size=2></FONT> </DIV>
<DIV><FONT face=Arial size=2>The real time messages are one byte 
only.</FONT></DIV>
<DIV><FONT face=Arial size=2>So just check if a message is real time, then do 
something with it, like nothing at all.</FONT></DIV>
<DIV><FONT face=Arial size=2></FONT> </DIV>
<DIV><FONT face=Arial size=2>Next is just to get you started, not completely 
structured as you would like to code it.</FONT></DIV>
<DIV><FONT face=Arial size=2>Best follow it through a few times, it does make 
sense...</FONT></DIV>
<DIV><FONT face=Arial size=2></FONT> </DIV>
<DIV><FONT face=Arial size=2>When receiving a byte always first check if it 
is a status byte. </FONT></DIV>
<DIV><FONT face=Arial size=2>If statusbyte (bit 7 set) 
and i</FONT><FONT face=Arial size=2>f not a "real time" message and 
not a "start of sysex" message or a "end of sysex" message,</FONT></DIV>
<DIV><FONT face=Arial size=2>then write it to the "running status buffer" and 
clear the "second byte" flag.</FONT></DIV>
<DIV><FONT face=Arial size=2>Done.</FONT></DIV>
<DIV><FONT face=Arial size=2></FONT> </DIV>
<DIV><FONT face=Arial size=2>If real time, do what you have to do. (leave the 
"running status" buffer like it is!!)</FONT></DIV>
<DIV><FONT face=Arial size=2>Done</FONT></DIV>
<DIV><FONT face=Arial size=2></FONT> </DIV>
<DIV><FONT face=Arial size=2>If sysex start, clear the "running status buffer" 
and goto sysex mode(until a end of sysex) or ignore if the sysex is 
not for you.</FONT> </DIV>
<DIV><FONT face=Arial size=2>Done.</FONT></DIV>
<DIV><FONT face=Arial size=2></FONT> </DIV>
<DIV><FONT face=Arial size=2>If not a status byte check if the running status 
buffer is empty,</FONT></DIV>
<DIV><FONT face=Arial size=2>when it is; just throw the byte away, its a error 
or part of sysex data that your not interested in. </FONT></DIV>
<DIV><FONT face=Arial size=2>Done.</FONT></DIV>
<DIV><FONT face=Arial size=2></FONT> </DIV>
<DIV><FONT face=Arial size=2>When the "running status buffer" is not empty 
then:</FONT></DIV>
<DIV><FONT face=Arial size=2>Check if the "second byte flag" is 
set.</FONT></DIV>
<DIV><FONT face=Arial size=2></FONT> </DIV>
<DIV><FONT face=Arial size=2>If the "second byte flag" is not set then this 
is the first data byte of whatever message type is in the "running status 
buffer".</FONT></DIV>
<DIV><FONT face=Arial size=2>If there is a 2 byte message type in the 
running status buffer your ready now.</FONT></DIV>
<DIV><FONT face=Arial size=2>Together with the data from the running status 
buffer you have your 2 byte midi message.</FONT></DIV>
<DIV><FONT face=Arial size=2>If there is a 3 byte message type in the running 
status buffer:</FONT></DIV>
<DIV><FONT face=Arial size=2>Store the received byte for the time being in "fist 
byte buffer" and set the "second byte flag"</FONT></DIV>
<DIV><FONT face=Arial size=2>Done.</FONT></DIV>
<DIV><FONT face=Arial size=2></FONT> </DIV>
<DIV><FONT face=Arial size=2>If the "second byte flag" is set then this is the 
second data byte of whatever message type is in the "running status 
buffer".</FONT></DIV>
<DIV><FONT face=Arial size=2>Now your 3 byte message is complete, together with 
the value of the running status buffer and the "first byte buffer" a 3 byte midi 
message.</FONT></DIV>
<DIV><FONT face=Arial size=2>Do whit it whatever you like, but before you 
do clear the "second byte flag"</FONT></DIV>
<DIV><FONT face=Arial size=2>Done.</FONT></DIV>
<DIV><FONT face=Arial size=2></FONT> </DIV>
<DIV><FONT face=Arial size=2>As you can see the "running status buffer" stays as 
it is for most of the time.</FONT></DIV>
<DIV><FONT face=Arial size=2></FONT> </DIV>
<DIV><FONT face=Arial size=2>HTH</FONT></DIV>
<DIV><FONT face=Arial size=2>Theo</FONT></DIV>
<DIV><FONT face=Arial size=2></FONT> </DIV>
<DIV><FONT face=Arial size=2></FONT> </DIV>
<BLOCKQUOTE 
style="PADDING-RIGHT: 0px; PADDING-LEFT: 5px; MARGIN-LEFT: 5px; BORDER-LEFT: #000000 2px solid; MARGIN-RIGHT: 0px">
  <DIV style="FONT: 10pt arial">----- Original Message ----- </DIV>
  <DIV 
  style="BACKGROUND: #e4e4e4; FONT: 10pt arial; font-color: black"><B>From:</B> 
  <A title=housenationmedia@yahoo.com 
  href="mailto:housenationmedia@yahoo.com">bill berzinskas</A> </DIV>
  <DIV style="FONT: 10pt arial"><B>To:</B> <A title=synth-diy@dropmix.xs4all.nl 
  href="mailto:synth-diy@dropmix.xs4all.nl">synth-diy@dropmix.xs4all.nl</A> 
  </DIV>
  <DIV style="FONT: 10pt arial"><B>Sent:</B> Tuesday, July 13, 2004 1:48 
PM</DIV>
  <DIV style="FONT: 10pt arial"><B>Subject:</B> [sdiy] Processing Midi - 
  Dropping Notes</DIV>
  <DIV><BR></DIV>
  <DIV>
  <BLOCKQUOTE class=replbq 
  style="PADDING-LEFT: 5px; MARGIN-LEFT: 5px; BORDER-LEFT: #1010ff 2px solid">
    <P>Hey everyone..</P>
    <P> </P>
    <P>I've been working on a midi-cv processor for my homebrew modular..  
    i've got it done, and got most of the code hashed out..   using 
    midi-ox, i can trigger the sounds..   It does get stuck in note on 
    sometimes tho, and won't take any more data..  also when i use it in 
    cubase, i get maybe 1 note, then it stops..   can someone give me 
    some suitable pseudo code to work through processing the data..   
    as  of now, i get th 3 bytes and go into an if to process the 
    data...  i've tried adding some running status parts where if the first 
    byte is a data byte, assume the last status message..  anyway, any help 
    would be great..  i'm using pic 18f452 and picbasic, but can get around 
    in ASM decently..  </P>
    <P>thanks</P>
    <P>--billie</P></BLOCKQUOTE></DIV>
  <P>
  <HR SIZE=1>
  Do you Yahoo!?<BR><A 
  href="http://us.rd.yahoo.com/mail_us/taglines/50x/*http://promotions.yahoo.com/new_mail/static/efficiency.html">Yahoo! 
  Mail</A> - 50x more storage than other providers!</BLOCKQUOTE></BODY></HTML>