>Is there some clever way to achieve the same goal for 24bit data without
>copying everything into a new 32-bit array?
I agree with the other post, Int8 x 3 can be used with slices to get a lot done, depending on data tasks desired, but not all
>The typical 24bit audio file contains two interleaved channels, i.e.
>frames of 3bytes+3bytes, so it can be cast to (nframes,3) Int32, or
>(nframes,2,3) Int8 array, but this is hardly a useful representation for
>audio data.
Along these liners, I have been working with 24 bit ADC data returned from pyUSB as tuples, which I need to convert to Float32 and save, like this:
WRAP = 2.**23
BITS24 = 2.**24
try:
chValue = struct.unpack(">I",
struct.pack(">4b", 0,*dataTuple[byteN:byteN+3])
)[0]
except:
chValue = 0
if chValue>WRAP:
chValue = ((BITS24-chValue) / WRAP) * gainFactors[thisCh]
else:
chValue = (-chValue / WRAP) * gainFactors[thisCh]
data[thisCh].append(chValue)
which is really slow (no real time is possible).
Is there a much faster way evident to others here?
We are going to do a pyd in C otherwise...
Ray