rusty@garnet.berkeley.edu (09/22/89)
We have a Sun Sparcstation 1. The chip inside that it uses for D/A and A/D is the AM79C30 Digital Subscriber Controller. The chip uses a sampling rate of 8192 samples per second, with each sample being 8-bits. The chip uses either u-law or A-law compression. I would like to take uncompressed digital sound samples, say generated by a software synthesis program (computer music for example), 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? Or point me at some references (that I could try and puzzle over; my math is zip)? -- -------------------------------------- rusty c. wright rusty@violet.berkeley.edu ucbvax!violet!rusty
chip@vector.Dallas.TX.US (Chip Rosenthal) (09/23/89)
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
esker@abaa.uucp (Lawrence Esker) (09/26/89)
In article <RUSTY.89Sep21171741@garnet.berkeley.edu> rusty@garnet.berkeley.edu writes: >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? Or >point me at some references (that I could try and puzzle over; my math >is zip)? > rusty c. wright I am trying this from memory, so bear with me. I'm not too sure on the sign bit treatment. The best reference would be the data manual on the AM79C30. First, the data is separated into inverted sign bit plus magnetude. The magnetude is fractionalized into 0 through 7 leading zero's, four bits of data, and trash. The number of leading zero's subtracted from 7 is converted to binary. The compressed value is the sign bit, binary zero lead, four data bits. Some examples: 1111 1111 1111 1111 = 1 1111 xxxxxxxxxxx = 0 111 1111 1000 0101 1110 0100 = 1 0000 1011 xxxxxxx = 0 011 1011 1001 0110 0011 1010 = 1 00 1011 xxxxxxxxx = 0 101 1011 1000 0000 0001 0000 = 1 0000000 0001 xxxx = 0 000 0001 0111 1111 1111 0000 = 0 0000000 0001 xxxx = 1 000 0001 0111 0001 1001 0110 = 0 000 1110 xxxxxxxx = 1 100 1110 0000 0000 0000 0001 = 0 1111 xxxxxxxxxxx = 1 111 1111 0000 0000 0000 0000 = no 2's complement = 1 111 1111 You can see from above that the best resolution of small signal information is 12 bits. The least significant four or more bits of 16 bit data is trashed. As I said before, the sign bit treatment is probably wrong. I hope the rest was done correctly. Anyone who knows how CD players and compandors treat polarity is welcome to correct me. -- ---------- Lawrence W. Esker ---------- Modern Amish: Thou shalt not need any computer that is not IBM compatible. UseNet Path: __!mailrus!sharkey!itivax!abaa!esker == esker@abaa.UUCP