<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
</head>
<body bgcolor="#ffffff" text="#000000">
thanks Grant, your sext24 function does the trick (<b><i>this Python
newbie thanks you a lot </i></b>...)<br>
<br>
so i loop on d=wave.readframes(1) <br>
call dd=sext24(d) on the frame read , then<br>
unpack(dd) the output of sext24 into a 32bit integer (seems to do
the trick correctly for signed 24 bit integers ....)<br>
<br>
<pre>><i> On 2010-01-08, Robert Somerville <<a
href="http://mail.python.org/mailman/listinfo/python-list">rsomerville at sjgeophysics.com</a>> wrote:
</i>><i>
</i>>><i> I am trying to read 24bit signed WAV format (little endian) data from a
</i>>><i> WAV file and convert it to 32 bit little endian integer format ... can
</i>>><i> anybody please tell me how to do the conversion from 24 bit to 32 bit
</i>>><i> with a snippet of Python code ???
</i>><i>
</i>><i> def sext24(d):
</i>><i> if ord(d[2]) & 0x80:
</i>><i> return d+'\xff'
</i>><i> else:
</i>><i> return d+'\x00'
</i>
</pre>
<br>
<br>
</body>
</html>