TR-30.1/97-01- Telecommunications Industry Association (TIA) _________________________________________________________________ CONTRIBUTION to Technical Subcommittee TR-30.1 _________________________________________________________________ SOURCE: Hayes Microcomputer Products, Inc. CONTACT: David C. Rife office (770) 840-9200 ext 2048 fax (770) 447-0178 TITLE: Digital Pad Mapping Program PROJECT: PN-3838 DATE: February 28, 1997 DISTRIBUTION: TR-30.1 Meeting Attendees ABSTRACT This contribution contains the BASIC program used to generate the pad mapping tables of 3dbpadr1.txt. Copyright Statement The contributor grants a free, irrevocable license to the Telecommunications Industry Association (TIA) to incorporate text contained in this contribution and any modifications thereof in the creation of a TIA standards publication; to copyright in TIA's name any standards publication even though it may include portions of this contribution; and at TIA's sole discretion to permit others to reproduce in whole or in part the resulting TIA standards publication. Intellectual Property Statement The individual preparing this contribution does not know of patents, the use of which may be essential to a standard resulting in whole or in part from this contribution. ' Program to identify pad mapping for A-law and mu-law codecs. ' by David Rife ' 12-31-96 ' 01-02-97 Changed program to use command line loss value and ' added marks to duplicate output levels. ' 01-03-97 Added duplicate level counter to P routine. ' 01-14-97 Made the mapping routine a subroutine. ' 02-28-97 Corrected bug in mu-law section. ' This version uses the smaller of two output levels when both ' have the same absolute error. ' A-law codec output levels DATA 1, 3, 5, 7, 9, 11, 13, 15 DATA 17, 19, 21, 23, 25, 27, 29, 31 DATA 33, 35, 37, 39, 41, 43, 45, 47 DATA 49, 51, 53, 55, 57, 59, 61, 63 DATA 66, 70, 74, 78, 82, 86, 90, 94 DATA 98, 102, 106, 110, 114, 118, 122, 126 DATA 132, 140, 148, 156, 164, 172, 180, 188 DATA 196, 204, 212, 220, 228, 236, 244, 252 DATA 264, 280, 296, 312, 328, 344, 360, 376 DATA 392, 408, 424, 440, 456, 472, 488, 504 DATA 528, 560, 592, 624, 656, 688, 720, 752 DATA 784, 816, 848, 880, 912, 944, 976, 1008 DATA 1056, 1120, 1184, 1248, 1312, 1376, 1440, 1504 DATA 1568, 1632, 1696, 1760, 1824, 1888, 1952, 2016 DATA 2112, 2240, 2368, 2496, 2624, 2752, 2880, 3008 DATA 3136, 3264, 3392, 3520, 3648, 3776, 3904, 4032 ' mu-law codec output levels DATA 0, 2, 4, 6, 8, 10, 12, 14 DATA 16, 18, 20, 22, 24, 26, 28, 30 DATA 33, 37, 41, 45, 49, 53, 57, 61 DATA 65, 69, 73, 77, 81, 85, 89, 93 DATA 99, 107, 115, 123, 131, 139, 147, 155 DATA 163, 171, 179, 187, 195, 203, 211, 219 DATA 231, 247, 263, 279, 295, 311, 327, 343 DATA 359, 375, 391, 407, 423, 439, 455, 471 DATA 495, 527, 559, 591, 623, 655, 687, 719 DATA 751, 783, 815, 847, 879, 911, 943, 975 DATA 1023, 1087, 1151, 1215, 1279, 1343, 1407, 1471 DATA 1535, 1599, 1663, 1727, 1791, 1855, 1919, 1983 DATA 2079, 2207, 2335, 2463, 2591, 2719, 2847, 2975 DATA 3103, 3231, 3359, 3487, 3615, 3743, 3871, 3999 DATA 4191, 4447, 4703, 4959, 5215, 5471, 5727, 5983 DATA 6239, 6495, 6751, 7007, 7263, 7519, 7775, 8031 DIM A(128), M(128), X(128), Y(128) FOR I = 1 TO 128 ' reading A-law table READ A(I) NEXT I FOR I = 1 TO 128 ' reading æ-law table READ M(I) NEXT I Q$ = COMMAND$ ' Note: remove this line if using QBASIC. IF Q$ = "" THEN INPUT "How many db of loss do you want";Q$ IF Q$ = "" THEN END Q = VAL(Q$) R = 10 ^ (Q / 20) GOSUB A GOSUB M END A: ' A-law mapping LAW$ = "A" FOR I = 1 TO 128 'write the map to X(I) X(I) = A(I) NEXT I GOSUB S OPEN "PAD.OUT" FOR APPEND AS #1 PRINT #1, "" PRINT #1, "Mapping of "; Q; "-db pad for A-law codec." GOSUB P CLOSE RETURN M: ' æ-law mapping LAW$ = "MU" FOR I = 1 TO 128 'write the map to X(I) X(I) = M(I) NEXT I GOSUB S OPEN "PAD.OUT" FOR APPEND AS #1 PRINT #1, CHR$(12) PRINT #1, "" PRINT #1, "Mapping of "; Q; "-db pad for mu-law codec." GOSUB P CLOSE RETURN S: ' mapping routine FOR I = 1 TO 128 Z = X(I) / R C = 10000 FOR J = 1 TO 128 IF ABS(X(J) - Z) < C THEN Y(I) = J C = ABS(X(J) - Z) END IF NEXT J NEXT I RETURN P: ' This bit does the rounding, counting of duplicates, and printing. DUPS = 0 PRINT #1, "" PRINT #1, "index in index out level in level out error duplicate" FOR I = 1 TO 128 E0 = X(I) / R - X(Y(I)) IF E0 < 0 THEN E = -INT(-100*E0 + .5)/100 ELSE E = INT(100*E0 + .5)/100 ENDIF PRINT X(I), X(Y(I)), E, IF LAW$ = "A" THEN PRINT #1, I, Y(I), IF LAW$ = "MU" THEN PRINT #1, I - 1, Y(I) - 1, PRINT #1, X(I), X(Y(I)), E, IF I = 1 THEN PRINT #1, "" PRINT ENDIF IF I > 1 THEN IF Y(I-1) = Y(I) THEN PRINT "*" PRINT #1, "*" DUPS = DUPS + 1 ELSE PRINT PRINT #1,"" ENDIF ENDIF NEXT I PRINT PRINT "Duplicates: ";DUPS PRINT #1, "" PRINT #1, "Duplicates: ";DUPS PRINT #1, "" RETURN END