Rob Lee wrote:
> Joel VanderWerf wrote:
>> Rob Lee wrote:
>>> puts f.read(3).unpack('H6').first.to_i(16)
>> I think you want 'h' instead of 'H', and you need to reverse the 
>> nibbles:
>>
>> puts f.read(3).unpack('h6').first.reverse.to_i(16)
> 
> Ah, OK that works with my example script - thanks.  However, that means 
> the Bitstruct definition I gave is incorrect.  The binary file I'm 
> trying to modify correctly unpacks the integer using :
> 
> f.read(3).unpack('H6').first.to_i(16)
> 
> However, I'm really confused over what the Bitstruct definition should 
> be to support this - do you have any suggestions ?
> 
> Thanks
> 

Then probably your data is in big endian order--I should have grokked 
that from your code. Try this:

class Audio < BitStruct
    signed       :aheader,       8
    unsigned     :alength,       3*8
    signed       :afooter,       8
end

-- 
       vjoel : Joel VanderWerf : path berkeley edu : 510 665 3407