def _data_format(self, x):
"""The data types in numpy needs to be mapped to the equivalent type in
portaudio. This is an issue for 24 bit audio files since there isn't a
24 bit data type in numpy. This is currently not implemented. There are
some options on how to do this. We could for example use a 32 bit int and
store the 24 bits either so that bits 1 to 8 is set to zeroes or so that
bits 25 to 32 is set to zeros.
"""
retval = None
if x.samples.dtype == np.dtype(np.float32):
self._logger.debug("pyaudio.paFloat32")
retval = pyaudio.paFloat32
elif x.samples.dtype == np.dtype(np.int16):
self._logger.debug("pyaudio.paInt16")
retval = pyaudio.paInt16
elif x.samples.dtype == np.dtype(np.int32):
self._logger.debug("pyaudio.paInt32")
retval = pyaudio.paInt32
else:
raise NotImplementedError("Data type not understood: %s" %x.samples.dtype)
return retval
评论列表
文章目录