]> granicus.if.org Git - python/commitdiff
#1700821: add a note to audioop docs about signedness of sample formats.
authorGeorg Brandl <georg@python.org>
Mon, 24 Mar 2008 09:34:34 +0000 (09:34 +0000)
committerGeorg Brandl <georg@python.org>
Mon, 24 Mar 2008 09:34:34 +0000 (09:34 +0000)
Doc/library/audioop.rst

index f6d762f63bdca4bdd51c43cd25c7f04d58344f6a..02bd75597f902d5fb30ba49ab0ef9538a8f92dae 100644 (file)
@@ -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)