I had about a terabyte file that was in a 24-bit four-channel PCM.
Of course, I did not want to touch on any other part than what I wanted, and so I did this:
import numpy as np
from numpy.lib.stride_tricks import as_strided
rawdatamap = np.memmap('4ch24bit800GBdatafile.pcm', dtype=np.dtype('u1'),mode='r')
usablebytes = rawdatamap.shape[0]-rawdatamap.shape[0]%12
frames = int(usablebytes/12)
rawbytes = rawdatamap[:usablebytes]
realdata = as_strided(rawbytes.view(np.int32), strides=(12,3,), shape=(frames,4))
someusefulpart = realdata[hugeoffset:hugeoffset+smallerthanram]&0x00ffffff
This made a copy from the file smallerthanrambytes of memory.
bytemask! , 32- - , .
, :
scaled_ch2_datum_at_framenum = scalefactor*(realdata[framenum,1]&0x00ffffff)-shiftoffset
, , .
, , 64- .
NB. . endian, dtype ...&0x00ffffff ...&ffffff00>>8