24 bit signed integer binary conversion help needed

Grant Edwards invalid at invalid.invalid
Fri Jan 8 22:24:36 CET 2010

On 2010-01-08, Robert Somerville <rsomerville at sjgeophysics.com> wrote:

> I am trying to read 24bit signed WAV format (little endian) data from a 
> WAV file and convert it to 32 bit little endian integer format ... can 
> anybody please tell me how to do the conversion from 24 bit to 32 bit 
> with a snippet of Python code ???

def sext24(d):
    if ord(d[2]) & 0x80:
        return d+'\xff'
        return d+'\x00'
Grant Edwards                   grante             Yow! Am I having fun yet?

More information about the Python-list mailing list