Re: Q: converting 24 bit signed to float32?
by RayS other posts by this author
Jun 24 2006 6:18AM messages near this date
view in the new Beta List Site
Q: converting 24 bit signed to float32?
|
Re: [Pythonmac-SIG] Installing wxPython with ActivePython and OSX
Hi Charles,
That is the current/next step - a colleague is writing a C module
we'll wrap/include with weave. I was hoping there was a trick
Numeric.where() methodology (which I'm just learning) to do it and
push most all down to C anyway.
Thanks, Ray
At 12:07 AM 6/24/2006, you wrote:
> Why not wrap the C code for use as an C exstension?
>
> Charles BUrnaford
>
>
> Ray Schumacher wrote:
> >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
> >
> >
> >
> >
_______________________________________________
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
|