SF [ 1231053 ] audioop - alaw encoding/decoding added, code updated
 This patch adds a-LAW encoding to audioop and replaces the old
u-LAW encoding/decoding code with the current code from sox.

Possible issues: the code from sox uses int16_t.

Code by Lars Immisch
diff --git a/Doc/lib/libaudioop.tex b/Doc/lib/libaudioop.tex
index 76bcdbf..52c6f3d 100644
--- a/Doc/lib/libaudioop.tex
+++ b/Doc/lib/libaudioop.tex
@@ -12,9 +12,10 @@
 modules.  All scalar items are integers, unless specified otherwise.
 
 % This para is mostly here to provide an excuse for the index entries...
-This module provides support for u-LAW and Intel/DVI ADPCM encodings.
+This module provides support for a-LAW, u-LAW and Intel/DVI ADPCM encodings.
 \index{Intel/DVI ADPCM}
 \index{ADPCM, Intel/DVI}
+\index{a-LAW}
 \index{u-LAW}
 
 A few of the more complicated operations only take 16-bit samples,
@@ -42,6 +43,13 @@
 has the width specified in \var{width}.
 \end{funcdesc}
 
+\begin{funcdesc}{alaw2lin}{fragment, width}
+Convert sound fragments in a-LAW encoding to linearly encoded sound
+fragments.  a-LAW encoding always uses 8 bits samples, so \var{width}
+refers only to the sample width of the output fragment here.
+\versionadded{2.5}
+\end{funcdesc}
+
 \begin{funcdesc}{avg}{fragment, width}
 Return the average over all samples in the fragment.
 \end{funcdesc}
@@ -98,10 +106,6 @@
 Return the value of sample \var{index} from the fragment.
 \end{funcdesc}
 
-\begin{funcdesc}{lin2lin}{fragment, width, newwidth}
-Convert samples between 1-, 2- and 4-byte formats.
-\end{funcdesc}
-
 \begin{funcdesc}{lin2adpcm}{fragment, width, state}
 Convert samples to 4 bit Intel/DVI ADPCM encoding.  ADPCM coding is an
 adaptive coding scheme, whereby each 4 bit number is the difference
@@ -117,6 +121,18 @@
 packed 2 4-bit values per byte.
 \end{funcdesc}
 
+\begin{funcdesc}{lin2alaw}{fragment, width}
+Convert samples in the audio fragment to a-LAW encoding and return
+this as a Python string.  a-LAW is an audio encoding format whereby
+you get a dynamic range of about 13 bits using only 8 bit samples.  It
+is used by the Sun audio hardware, among others.
+\versionadded{2.5}
+\end{funcdesc}
+
+\begin{funcdesc}{lin2lin}{fragment, width, newwidth}
+Convert samples between 1-, 2- and 4-byte formats.
+\end{funcdesc}
+
 \begin{funcdesc}{lin2ulaw}{fragment, width}
 Convert samples in the audio fragment to u-LAW encoding and return
 this as a Python string.  u-LAW is an audio encoding format whereby