I ran into this problem. I have a buffer containing all 32-bit signed samples, while in each example only 24 bits are used (the highest 8 bits are 0 additions, even if the number is negative). My decision:
samples_4byte = self.buffer.tobytes() byte_format = ('%ds %dx ' % (3, 1)) * self.sample_len * 2 samples_3byte = b''.join(struct.unpack(byte_format, samples_4byte))
Now I have a bytearray that can be written to the wave file:
with wave.open(file_abs, 'wb') as wav_file:
More importantly, I donβt want to wait for someone to fix the patch (like scipy) to complete my project.
source share