00001 00002 // 00003 // $Id: SndMuLaw.h 3240 2005-05-09 13:33:37Z leighsmith $ 00004 // 00005 // Description: 00006 // MuLaw and ALaw functions taken from 00007 // libst.c - portable sound tools library more commonly known as Sox. 00008 // 00009 // Original Author: 00010 // Craig Reese: IDA/Supercomputing Research Center 00011 // 00012 // 00013 // Copyright accompanying libst.h - include file for portable sound tools library 00014 // 00015 // Copyright (C) 1989 by Jef Poskanzer. 00016 // 00017 // Permission to use, copy, modify, and distribute this software and its 00018 // documentation for any purpose and without fee is hereby granted, provided 00019 // that the above copyright notice appear in all copies and that both that 00020 // copyright notice and this permission notice appear in supporting 00021 // documentation. This software is provided "as is" without express or 00022 // implied warranty. 00023 // 00024 // Portions Copyright (c) 1999, The MusicKit Project. All rights reserved. 00025 // 00026 // Permission is granted to use and modify this code for commercial and 00027 // non-commercial purposes so long as the author attribution and copyright 00028 // messages remain intact and accompany all relevant code. 00029 // 00031 00032 /* We #include this file regardless of the setting of 00033 HAVE_CONFIG_H so that other applications compiling against this 00034 header don't have to define it. If you are seeing errors for 00035 SndKitConfig.h not found when compiling the MusicKit, you haven't 00036 run ./configure 00037 */ 00038 #include "SndKitConfig.h" 00039 00040 #define MINLIN -32768 00041 #define MAXLIN 32767 00042 #define LINCLIP(x) do { if ( x < MINLIN ) x = MINLIN ; else if ( x > MAXLIN ) x = MAXLIN; } while ( 0 ) 00043 00044 /* These do not round data. Caller must round appropriately. */ 00045 00046 00047 #ifdef FAST_ULAW_CONVERSION 00048 extern int ulaw_exp_table[256]; 00049 extern unsigned char ulaw_comp_table[16384]; 00050 #define SndMuLawToLinear(ulawbyte) ulaw_exp_table[ulawbyte] 00051 #define SndLinearToMuLaw(linearword) ulaw_comp_table[(linearword / 4) & 0x3fff] 00052 #else 00053 00060 SNDKIT_API unsigned char SndLinearToMuLaw(short linearValue); 00061 00068 SNDKIT_API short SndMuLawToLinear(unsigned char mulawValue); 00069 00070 #endif 00071 00072 #ifdef FAST_ALAW_CONVERSION 00073 extern int Alaw_exp_table[256]; 00074 extern unsigned char Alaw_comp_table[16384]; 00075 #define SndALawToLinear(Alawbyte) Alaw_exp_table[Alawbyte] 00076 #define SndLinearToALaw(linearword) Alaw_comp_table[(linearword / 4) & 0x3fff] 00077 #else 00078 00085 SNDKIT_API unsigned char SndLinearToALaw(short linearValue); 00086 00093 SNDKIT_API short SndALawToLinear(unsigned char alawbyte); 00094 00095 #endif