[ python-Bugs-1700821 ] audioop module - request to add a note

SourceForge.net noreply at sourceforge.net
Thu Apr 19 08:45:47 CEST 2007


Bugs item #1700821, was opened at 2007-04-14 18:07
Message generated for change (Comment added) made by rhettinger
You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=105470&aid=1700821&group_id=5470

Please note that this message will contain a full copy of the comment thread,
including the initial issue submission, for this request,
not just the latest update.
>Category: Documentation
Group: None
Status: Open
>Resolution: Accepted
Priority: 5
Private: No
Submitted By: ncryptor (ncryptor)
>Assigned to: Raymond Hettinger (rhettinger)
Summary: audioop module - request to add a note

Initial Comment:
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.


----------------------------------------------------------------------

>Comment By: Raymond Hettinger (rhettinger)
Date: 2007-04-19 01:45

Message:
Logged In: YES 
user_id=80475
Originator: NO

I will add a note.

----------------------------------------------------------------------

You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=105470&aid=1700821&group_id=5470


More information about the Python-bugs-list mailing list