This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author ncryptor
Recipients
Date 2007-04-14.23:07:14
SpamBayes Score
Marked as misclassified
Message-id
In-reply-to
Content
The audioop function lin2lin converts sample sizes of linear pcm fragments.
However, when converting to 8-bit, there is a pitfall (that wasted for me a few hours).
In some audio formats, such as .WAV files, 16 and 32 bit samples are signed, but 8 bit samples are unsigned. So when converting from 2 to 1 byte wide samples, you need to also add 128 to the result.
Example code:

new_frames = audioop.lin2lin(frames, old_width, new_width)
if 1 == new_width:
   new_frames = audioop.bias(new_frames, 1, 128)

the same, in reverse, has to be applied when converting from 8 to 16 or 32 bit width samples.

This wasted so much time for me and is hardly documented.
History
Date User Action Args
2007-08-23 14:53:07adminlinkissue1700821 messages
2007-08-23 14:53:07admincreate