A little bit manipulating help?

I have a number I'm reading in from a file.

4 bytes each byte has the high bit set to zero.

0XXXXXXX,0XXXXXXX,0XXXXXXX,0XXXXXXX

Now, the number I want is what I would get if I slid them all down compacting out the missing high order bits.

0000XXXX,XXXXXXXX,XXXXXXXX,XXXXXXXX

I.m betting there's a real quick and easy way to do this.

Little help?

Thanks!

-jim lee

What data type is the number read from the file ? Are they really bytes or are they chars ?

Its an encoded 4 byte int, .mp3 stuff. If I can decode it it will tell me how for ahead to jump to get over all the album artwork and other nonsense you find in there. Its causing havoc with the player chips.

I swear .mp3 files were designed by the IRS!

-jim lee

Something like:

if (Serial.available () >= 4)
{
  unsigned long result = 0ul ;
  for (byte i = 0 ; i < 4 ; i++)
  {
    result <<= 7 ;
    result |= (0x7F & Serial.read ()) ;
  }
  return result ;
}

YAHOO!! That worked!

It was the final bit of the puzzle that's been driving me nuts for days!

Now when I click "play" it starts right NOW!

Thanks again!

-jim lee