summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGeorg Brandl <georg@python.org>2008-03-24 09:34:34 (GMT)
committerGeorg Brandl <georg@python.org>2008-03-24 09:34:34 (GMT)
commit9bdead0aed698aea001a9d5ace63e96e904d6fa3 (patch)
treebc31a92594f3c8f4330a2eb04fd525272e1aedaf
parentb72233ce6303aabe7960170f98c5626771751fe7 (diff)
downloadcpython-9bdead0aed698aea001a9d5ace63e96e904d6fa3.zip
cpython-9bdead0aed698aea001a9d5ace63e96e904d6fa3.tar.gz
cpython-9bdead0aed698aea001a9d5ace63e96e904d6fa3.tar.bz2
#1700821: add a note to audioop docs about signedness of sample formats.
-rw-r--r--Doc/library/audioop.rst12
1 files changed, 12 insertions, 0 deletions
diff --git a/Doc/library/audioop.rst b/Doc/library/audioop.rst
index f6d762f..02bd755 100644
--- a/Doc/library/audioop.rst
+++ b/Doc/library/audioop.rst
@@ -141,6 +141,18 @@ The module defines the following variables and functions:
Convert samples between 1-, 2- and 4-byte formats.
+ .. note::
+
+ In some audio formats, such as .WAV files, 16 and 32 bit samples are
+ signed, but 8 bit samples are unsigned. So when converting to 8 bit wide
+ samples for these formats, you need to also add 128 to the result::
+
+ new_frames = audioop.lin2lin(frames, old_width, 1)
+ 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.
+
.. function:: lin2ulaw(fragment, width)