[comp.dcom.telecom] Voice Companding

chip@vector.dallas.tx.us (Chip Rosenthal) (09/23/89)

Patrick - I posted the following message to comp.dsp.  It was in response
to a message entitled "converting to/from compressed form" by Rusty
Wright (article <RUSTY.89Sep21171741@garnet.berkeley.edu>).  Thought it
might be applicable here, so I'm sending you a copy.

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

rusty@garnet.berkeley.edu writes:
>We have a Sun Sparcstation 1.  The chip inside that it uses for D/A and A/D
>is the AM79C30 Digital Subscriber Controller.  [...] I would like to take
>uncompressed digital sound samples, say generated by a [program], and feed
>it to this chip.

>Does anybody have any code or know where I can get my hands on some
>that would convert "normal" (uncompressed) 16 bit digital audio into
>the 8 bit u-law (or A-law) compressed form that the AM79C30 uses?

    Reference:	|Digital Telephony|, John C. Bellamy, John Wiley & Sons,
		1982, pp. 90-113.

These compression techniques are used in digital telecommunications to
try to squeeze reasonable sound quality ("toll quality") into 8-bits.

u-Law (that's "mu-law", not "you-law") compression is defined by:

			ln( 1 + u*|x| )
    F (x)  =  sgn(x) * ----------------
     u                   ln( 1 + u )

where -1 <= x <= +1, and sgn(x) is the sign function.

The compressed value is usually represented as an 8-bit signed
magnitude number: one sign bit plus seven magnitude bits.  In this
scheme, the most positive number is 0111111, the most negative number
is 11111111, 00000000 is a positive zero, and 1000000 is a negative
zero.

The u-Law expansion formula is:

     -1               1               |y|
    F (y) = sgn(y) * --- * [ ( 1 + u )   - 1 ]
     u                u

In modern telephony, a value of u=255 is used.  The first digital
telecommunication systems (the "D1" channel bank) used u=100, but with
the introduction of the "D2" channel bank a value of u=255 was
selected to simplify the conversion process.  This value allows Fu(x)
to be easily approximated by 15 linear segments.  This feature is not
so important these days since it's easy enough to build a conversion
lookup table into ROM.

Please see Bellamy for more information on the linear approximation
technique and details on constructing ROM lookup tables.  A-Law
companding is also discussed there.  u-Law is used primarily in the
North American and Japanese telecommunications networks, while A-Law
is used in Europe.


Chip Rosenthal / chip@vector.Dallas.TX.US / Dallas Semiconductor / 214-450-5337
Someday the whole country will be one big "Metroplex" - Zippy's friend Griffy