I have been working with 24 bit ADC data returned from pyUSB as byte-tuples, 
which I need to convert to Float32 and save, I currently do it like this:
<code>
WRAP = 2.**23
BITS24 = 2.**24
data = []
for byteN in range(0, len(dataTuple), 3):
            try:
                chValue = struct.unpack(">I", 
                                  struct.pack(">4b", 
0,*dataTuple[byteN:byteN+3])
                                )[0]
            except:
                chValue = 0
            if chValue>WRAP: 
                chValue = ((BITS24-chValue) / WRAP)
            else:
                chValue = (-chValue / WRAP)
            data[thisCh].append(chValue)
return data
</code>

It is really slow...
I have not been able to come up with a trick way to do it in numpy, either.
What is really needed is a 24 bit type, or at least a type-cast ability to go 
to Float32, in core; all of the latest sound cards are now 24 bit, so the 
demand should be coming.
http://www.koders.com/c/fid2226C89ED85B3FF15286288F7CF31CD8647CDD79.aspx
for instance, is an LGPL C module for working with them.

Cheers,
Ray

_______________________________________________
ActivePython mailing list
ActivePython@listserv.ActiveState.com
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs
Other options: http://listserv.ActiveState.com/mailman/listinfo/ActivePython

Reply via email to