On Tue, 2006-07-25 at 21:55 +0200, Jacob wrote:
> Hmmm, does this really work? I don't think so.
> 
> Example:
> 
>    1. status: note on   (-> thisByte -> runningStatus)
>    2. data:   key       (-> thisByte, ignored)
>    3. data:   vel       (-> thisByte, checked against 0, checked againt 0x80)
>    4. status: note off  (read as key !!!)
>    5. data:   key       (read as vel, checked against 0x80 !!!)
>    6. data:   vel       (read as key !!!)
>    7. status: note on   (read as vel, checked against 0x80 !!!)
> 
> The Problem is, that the second data byte is used for the running status
> byte test.
> 
> Yours,
> 
> Jacob

Ehmm ... Right! Just checking if you were awake :-D 

Furthermore, it did not do the single byte SysRt either. But there ought
to be a small, reasonable solution out there somewhere ... Giving it one
more try:

  
  for(;;)
    {
      thisByte = nextByte(); 
      
      if(thisByte & 0x80)  // got new status 
        runningStatus = thisByte, count = 0; 
      
      if(runningStatus == NOTE_ON || runningStatus == NOTE_OFF)
        {
          while(count < 2) // we need data1 and data2
            {
              thisByte = nextByte();
              // filter out single byte SysRt
              count += !(thisByte & 0x80);
            }

          if(thisByte == 0 || runningStatus == NOTE_OFF)
            setLed(NOTE_OFF);
          else
            setLed(NOTE_ON);  
          
          // assume we will keep runningStatus
          count = 1;
        }
    }
  


> On Tue, Jul 25, 2006 at 07:00:54PM +0200, Jens M Andreasen wrote:
> > Bzzzt ... My wrong!
> > 
> > 
> > thisByte = nextByte();
> > 
> > for(;;)
> > {
> > 
> >   if(thisByte & 0x80)
> >      runningStatus = thisByte;
> > 
> >   //... after which we get that:
> > 
> >   if(runningStatus == NOTE_ON || runningStatus == NOTE_OFF)
> >   {
> >     thisByte = nextByte();
> >     thisByte = nextByte();
> > 
> >     // note_on with zero velocity is note_off
> >     if(thisByte == 0 || runningStatus == NOTE_OFF)
> >       setLed(NOTE_OFF);
> >     else
> >       setLed(NOTE_ON);   
> >   }
> >   else
> >     thisByte = nextByte();
> > }
> > > > Lee
> > > > 
> > -- 
> > 
-- 

Reply via email to