python - How do I write a file in headerless PCM format? -
how write file in headerless pcm format? source data in numpy array, , have application expecting data in headerless pcm file, can't find documentation of file format? same data chunk in wave file?
the problem there no 1 "headerless pcm" format. example, 8-bit mono 22k , little-endian 16-bit stereo 48k both fine examples of pcm, , whole point of "headerless" need know information through out-of-band channel.
but, assuming have expected format, it's simple sounds.
for sample in samples: channel in channels: f.write(the_bytes_in_the_right_endianness)
and if you've got data in format, write file 1 big block.
the "default" codec wav files—and 1 supported python's wave
module—is pcm. so, yes, if have wav file in same format want, can copy raw frame data headerless file, , you've got headerless pcm file. (and if have wav
in wrong format, can use simple transformation, or @ worst out of audioop
, convert it.)
Comments
Post a Comment