DIRECTORY Commander, IO, Real, RealFns, Rope, U255; LarkSlaveTableImpl: PROGRAM IMPORTS Commander, IO, Real, RealFns, U255 = { OPEN U255; Main: Commander.CommandProc = TRUSTED { ENABLE ABORTED => GOTO Quit; out: IO.STREAM; name: Rope.ROPE; res: BOOL; l: NAT; rloss: REAL; out _ cmd.out; out.PutF["\nLarkSlaveTables running at %t\n", IO.time[]]; name _ "LarkSilence.table"; out.PutF["Writing %g ... ", IO.rope[name]]; res _ WriteBitsFile[name: name, data: MakeSilenceTable[], byteSwap: TRUE]; out.PutF[IF res THEN "OK.\n" ELSE "Failed!\n"]; name _ "LarkMuLaw.table"; out.PutF["Writing %g ... ", IO.rope[name]]; res _ WriteBitsFile[name: name, data: MakeMuLawTable[], byteSwap: TRUE]; out.PutF[IF res THEN "OK.\n" ELSE "Failed!\n"]; FOR i: NAT IN [0..4] DO l _ i*5; name _ IO.PutFR["LossTable%02d.table", IO.int[l]]; out.PutF["Writing %g ... ", IO.rope[name]]; res _ WriteBitsFile[name: name, data: MakeLossTable[dBToLoss[l]], byteSwap: TRUE]; out.PutF[IF res THEN "OK.\n" ELSE "Failed!\n"]; ENDLOOP; FOR i: NAT IN [0..8] DO l _ i*25; rloss _ l; rloss _ rloss/10; name _ IO.PutFR["LossTable%03d.table", IO.int[l]]; out.PutF["Writing %g ... ", IO.rope[name]]; res _ WriteBitsFile[name: name, data: MakeLossTable[dBToLoss[rloss]], byteSwap: TRUE]; out.PutF[IF res THEN "OK.\n" ELSE "Failed!\n"]; ENDLOOP; FOR i: NAT IN [0..2] DO l _ i*3; name _ IO.PutFR["LarkLinear%02d.table", IO.int[l]]; out.PutF["Writing %g ... ", IO.rope[name]]; res _ WriteBitsFile[name: name, data: MakeLinearTable[dBToLoss[l]], byteSwap: TRUE]; out.PutF[IF res THEN "OK.\n" ELSE "Failed!\n"]; ENDLOOP; out.PutF["\nLarkSlaveTables finished at %t\n", IO.time[]]; out.Flush[]; EXITS Quit => NULL; }; MakeLinearTable: PROC [loss: REAL] RETURNS [t: REF WTab] = { x: REAL; t _ NEW[WTab[256]]; FOR i: CARDINAL IN [0..256) DO t[i] _ U255.Decode[LOOPHOLE[i]]; x _ t[i]; x _ x*loss; t[i] _ Real.RoundI[x]; t[i] _ IntToRJInt[t[i]]; ENDLOOP; }; MakeSilenceTable: PROC RETURNS [t: REF WTab] = { wi: INTEGER; ary: ARRAY [0..128) OF REAL; min: REAL _ Real.LargestNumber; max: REAL _ 0; limit: REAL _ 408; i: NAT; t _ NEW[WTab[256]]; FOR i IN [0..128) DO wi _ U255.Decode[i]; wi _ ABS[wi]; ary[i] _ wi; ary[i] _ ary[i] * ary[i]; -- square ENDLOOP; FOR i IN [0..128) DO IF ary[i] > max THEN max _ ary[i]; ENDLOOP; FOR i IN [0..128) DO ary[i] _ ary[i] * (limit / max); ENDLOOP; FOR i IN [0..128) DO ary[i] _ ary[i] + 1; ENDLOOP; FOR i: CARDINAL IN [0..128) DO t[i] _ i; ENDLOOP; FOR i IN [0..128) DO t[128 + i] _ Real.FixC[ary[i]]; ENDLOOP; }; MakeLossTable: PROC [loss: REAL] RETURNS [t: REF BTab] = { int: INTEGER; x: REAL; t _ NEW[BTab[256]]; FOR i: CARDINAL IN [0..256) DO int _ U255.Decode[LOOPHOLE[i]]; x _ int; x _ x*loss; int _ Real.RoundI[x]; t[i] _ U255.Encode[int]; ENDLOOP; }; MakeMuLawTable: PROC RETURNS [t: REF BTab] = { t _ NEW[BTab[2048]]; FOR i: CARDINAL IN [0..2048) DO t[i] _ U255.Encode[Shift[i, 4]]; ENDLOOP; }; dBToLoss: PROC [dBloss: REAL] RETURNS [loss:REAL] = { RETURN [RealFns.Power[base: 10.0, exponent: -dBloss/20.0]]; }; Init: PROC = {Commander.Register["LarkTables", Main, "Construct tables for slave CPU"]; }; Init[]; }. December 22, 1983 3:08 pm, Stewart, Cedar 5 BLarkSlaveTableImpl.mesa Last modified: Stewart, December 22, 1983 3:08 pm Constructs a 256 x 16 table Address = U255 Value = silence value to be added to silence register Constructs a 2048 x 8 table Address = right justified (positive) 12 bit two's complement Value = right justified u-255 Constructs a 256 x 8 bit table Address = u-255 value Value = u-255 value attenuated by slos Constructs a 256 x 8 bit table Address = u-255 value Value = u-255 value attenuated by loss Constructs a 256 x 16 bit table Address = u-255 value Value = right justified 12 bit two's complement Constructs a 256 x 16 bit table Address = u-255 value Value = right justified 12 bit two's complement Constructs a 256 x 16 table The table is in two halves. The lower half is absolute value, the upper is square law. Entries [0..128): Address = U255 Value = silence value to be added to silence register Absolute value of mu law encoded sample Entries [128..256): Address = U255 Value = silence value to be added to silence register Square law convert to linear coded REAL find maximum scale high end round up low end fill in result table Constructs a 256 x 8 bit table Address = u-255 value Value = u-255 value attenuated by loss Constructs a 2048 x 8 table Address = right justified (positive) 12 bit two's complement Value = right justified u-255 Main program Ę;˜Jšœ™Jšœ™Jšœ"™"J˜šĎk ˜ J˜ Jšœ˜J˜J˜J˜J˜J˜—Jšœœœ œ˜Jšœ˜ J˜—šœœ˜'šœœœ˜J˜—Jšœœœ˜Jšœ œ˜Jšœœ˜ Jšœœ˜Jšœœ˜ J˜J˜J˜šœ.œ ˜9J˜—Jšœ™Jšœ™šœ5™5J˜Jšœœ ˜+JšœDœ˜JJšœ œœ œ˜/J˜—Jšœ™Jšœ<™<šœ™J˜Jšœœ ˜+JšœBœ˜HJšœ œœ œ˜/J˜—Jšœ™Jšœ™šœ&™&šœœœ˜J˜Jšœœœ ˜2Jšœœ ˜+JšœLœ˜RJšœ œœ œ˜/Jšœ˜——J˜Jšœ™Jšœ™šœ&™&šœœœ˜J˜ J˜ J˜Jšœœœ ˜2Jšœœ ˜+JšœPœ˜VJšœ œœ œ˜/Jšœ˜——J˜Jšœ™Jšœ™šœ/™/šœœœ˜J˜Jšœœœ ˜3Jšœœ ˜+JšœNœ˜TJšœ œœ œ˜/Jšœ˜J˜—Jšœ/œ ˜:J˜ Jš˜Jšœœ˜ J˜J˜——Jšœ™Jšœ™Jšœ/™/š Ďnœœœœœ ˜