Messages in this thread | | | Date | Thu, 22 May 1997 03:25:41 +0200 (MESZ) | From | Kai Schulte <> | Subject | ulaw conversion tables |
| |
Why does the ulaw-dsp conversion table in the sound driver clip ulaw amplitudes larger than 0x60 instead of using a smaller scale for the translated signal? Is this limitation part of the "sun audio" specification?
Yesterday, I downloaded a few music files which are supposed to be ".au", and although they play fine on other machines, they sound terribly distorted with the linux sound driver. So I generated the following ulaw conversion table and everything was fine:
=========================================================================== /* generate ulaw-dsp conversion tables */
#include <stdio.h> #include <math.h>
#define STEPSIZE 0.038143205 /* ln(128)/127 */ #define SCALE 26.17461003 /* 127/ln(128) */
main() { int i; char delim=','; printf("int full_ulaw_dsp[256]={"); for (i=0;i<128;i++) { if (!(i%8)) printf("\n "); printf("%3i, ", (int)(0x81+0.5-exp(STEPSIZE*(0x7f-i)))); } for (i=0;i<128;i++) { if (!(i%8)) printf("\n "); if (i==127) delim=' '; printf("%3i%c ", (int)(0x7f+0.5+exp(STEPSIZE*(0x7f-i))), delim); } delim=','; printf("\n};\n\nint full_dsp_ulaw[256]={"); for (i=0;i<128;i++) { if (!(i%8)) printf("\n "); printf("%3i, ", (int)(0x7f+0.001-log(0x80-i)*SCALE)); } for (i=0;i<128;i++) { if (!(i%8)) printf("\n "); if (i==127) delim=' '; printf("%3i%c ", (int)(0xff+0.001-log(i+1)*SCALE), delim); } printf("\n};\n\n"); } ============================================================================ /* full_dynamic_ulaw.h */
int full_ulaw_dsp[256]={ 2, 7, 11, 16, 20, 24, 28, 32, 35, 39, 42, 46, 49, 52, 55, 57, 60, 63, 65, 67, 70, 72, 74, 76, 78, 80, 82, 84, 85, 87, 89, 90, 92, 93, 94, 96, 97, 98, 99, 100, 101, 102, 103, 104, 105, 106, 107, 108, 109, 109, 110, 111, 112, 112, 113, 113, 114, 115, 115, 116, 116, 117, 117, 118, 118, 118, 119, 119, 120, 120, 120, 121, 121, 121, 121, 122, 122, 122, 123, 123, 123, 123, 123, 124, 124, 124, 124, 124, 125, 125, 125, 125, 125, 125, 125, 126, 126, 126, 126, 126, 126, 126, 126, 127, 127, 127, 127, 127, 127, 127, 127, 127, 127, 127, 127, 127, 127, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 254, 249, 245, 240, 236, 232, 228, 224, 221, 217, 214, 210, 207, 204, 201, 199, 196, 193, 191, 189, 186, 184, 182, 180, 178, 176, 174, 172, 171, 169, 167, 166, 164, 163, 162, 160, 159, 158, 157, 156, 155, 154, 153, 152, 151, 150, 149, 148, 147, 147, 146, 145, 144, 144, 143, 143, 142, 141, 141, 140, 140, 139, 139, 138, 138, 138, 137, 137, 136, 136, 136, 135, 135, 135, 135, 134, 134, 134, 133, 133, 133, 133, 133, 132, 132, 132, 132, 132, 131, 131, 131, 131, 131, 131, 131, 130, 130, 130, 130, 130, 130, 130, 130, 129, 129, 129, 129, 129, 129, 129, 129, 129, 129, 129, 129, 129, 129, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128 };
int full_dsp_ulaw[256]={ 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 2, 2, 2, 2, 3, 3, 3, 3, 3, 4, 4, 4, 4, 5, 5, 5, 5, 6, 6, 6, 6, 7, 7, 7, 8, 8, 8, 8, 9, 9, 9, 10, 10, 10, 11, 11, 11, 11, 12, 12, 12, 13, 13, 13, 14, 14, 15, 15, 15, 16, 16, 16, 17, 17, 18, 18, 18, 19, 19, 20, 20, 21, 21, 22, 22, 23, 23, 24, 24, 25, 25, 26, 26, 27, 27, 28, 29, 29, 30, 31, 31, 32, 33, 33, 34, 35, 36, 37, 37, 38, 39, 40, 41, 42, 43, 44, 46, 47, 48, 49, 51, 52, 54, 56, 57, 59, 61, 64, 66, 69, 72, 76, 80, 84, 90, 98, 108, 127, 255, 236, 226, 218, 212, 208, 204, 200, 197, 194, 192, 189, 187, 185, 184, 182, 180, 179, 177, 176, 175, 174, 172, 171, 170, 169, 168, 167, 166, 165, 165, 164, 163, 162, 161, 161, 160, 159, 159, 158, 157, 157, 156, 155, 155, 154, 154, 153, 153, 152, 152, 151, 151, 150, 150, 149, 149, 148, 148, 147, 147, 146, 146, 146, 145, 145, 144, 144, 144, 143, 143, 143, 142, 142, 141, 141, 141, 140, 140, 140, 139, 139, 139, 139, 138, 138, 138, 137, 137, 137, 136, 136, 136, 136, 135, 135, 135, 134, 134, 134, 134, 133, 133, 133, 133, 132, 132, 132, 132, 131, 131, 131, 131, 131, 130, 130, 130, 130, 129, 129, 129, 129, 129, 128, 128, 128, 128, 128 }; =========================================================================
Kai
| |