ASPN ActiveState Programmer Network
ActiveState
/ Home / Perl / PHP / Python / Tcl / XSLT /
/ Safari / My ASPN /
Cookbooks | Documentation | Mailing Lists | Modules | News Feeds | Products | User Groups


Recent Messages
List Archives
About the List
List Leaders
Subscription Options

View Subscriptions
Help

View by Topic
ActiveState
.NET Framework
Open Source
Perl
PHP
Python
Tcl
Web Services
XML & XSLT

View by Category
Database
General
SOAP
System Administration
Tools
User Interfaces
Web Programming
XML Programming


MyASPN >> Mail Archive >> activepython
activepython
Q: converting 24 bit signed to float32?
by Ray Schumacher other posts by this author
Jun 20 2006 10:39AM messages near this date
view in the new Beta List Site
Re: _winreg.SaveKey question | Re: Q: converting 24 bit signed to float32?
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@[...].com
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs
Other options: http://listserv.ActiveState.com/mailman/listinfo/ActivePython
Thread:
Ray Schumacher
RayS

Privacy Policy | Email Opt-out | Feedback | Syndication
© 2004 ActiveState, a division of Sophos All rights reserved