lpc10.h

Go to the documentation of this file.
00001 /*
00002 
00003 $Log$
00004 Revision 1.18  2004/08/31 13:32:11  markster
00005 Merge NetBSD and Courtesty tone with modifications (bug #2329)
00006 
00007 Revision 1.17  2003/10/26 18:50:49  markster
00008 Make it build and run on MacOS X
00009 
00010 Revision 1.3  2003/10/26 18:50:49  markster
00011 Make it build and run on MacOS X
00012 
00013 Revision 1.2  2003/04/23 19:13:35  markster
00014 More OpenBSD patches
00015 
00016 Revision 1.1.1.2  2003/03/16 22:37:30  matteo
00017 dom mar 16 23:37:23 CET 2003
00018 
00019 Revision 1.2  2003/03/16 16:09:48  markster
00020 Mere James's cleanups for fewer build warnings
00021 
00022 Revision 1.1  2000/01/05 00:20:06  markster
00023 Add broken lpc10 code...  It's not too far from working I don't think...
00024 
00025  * Revision 1.1  1996/08/19  22:47:31  jaf
00026  * Initial revision
00027  *
00028 
00029 */
00030 
00031 #ifndef __LPC10_H__
00032 #define __LPC10_H__
00033 
00034 #define P_R_O_T_O_T_Y_P_E_S
00035 
00036 #define LPC10_SAMPLES_PER_FRAME 180
00037 #define LPC10_BITS_IN_COMPRESSED_FRAME 54
00038 
00039 
00040 /*
00041 
00042   The "#if defined"'s in this file are by no means intended to be
00043   complete.  They are what Nautilus uses, which has been successfully
00044   compiled under DOS with the Microsoft C compiler, and under a few
00045   versions of Unix with the GNU C compiler.
00046 
00047  */
00048 
00049 #if defined(unix) || defined(__unix__) || defined(__NetBSD__)
00050 typedef short     INT16;
00051 typedef int       INT32;
00052 #endif
00053 
00054 
00055 #if defined(__MSDOS__) || defined(MSDOS)
00056 typedef int       INT16;
00057 typedef long      INT32;
00058 #endif
00059 
00060 #if defined(__APPLE__)
00061 typedef short     INT16;
00062 typedef int       INT32;
00063 #endif
00064 
00065 #if defined(WIN32) && defined(_MSC_VER)
00066 typedef __int16      INT16;
00067 typedef __int32      INT32;
00068 #pragma warning(disable: 4005)
00069 #endif
00070 
00071 
00072 /* The initial values for every member of this structure is 0, except
00073    where noted in comments. */
00074 
00075 /* These two lines are copied from f2c.h.  There should be a more
00076    elegant way of doing this than having the same declarations in two
00077    files. */
00078 
00079 typedef float real;
00080 typedef INT32 integer;
00081 typedef INT32 logical;
00082 typedef INT16 shortint;
00083 
00084 struct lpc10_encoder_state {
00085     /* State used only by function hp100 */
00086     real z11;
00087     real z21;
00088     real z12;
00089     real z22;
00090     
00091     /* State used by function analys */
00092     real inbuf[540], pebuf[540];
00093     real lpbuf[696], ivbuf[312];
00094     real bias;
00095     integer osbuf[10];  /* no initial value necessary */
00096     integer osptr;     /* initial value 1 */
00097     integer obound[3];
00098     integer vwin[6]  /* was [2][3] */;   /* initial value vwin[4] = 307; vwin[5] = 462; */
00099     integer awin[6]  /* was [2][3] */;   /* initial value awin[4] = 307; awin[5] = 462; */
00100     integer voibuf[8]   /* was [2][4] */;
00101     real rmsbuf[3];
00102     real rcbuf[30]   /* was [10][3] */;
00103     real zpre;
00104 
00105 
00106     /* State used by function onset */
00107     real n;
00108     real d__;   /* initial value 1.f */
00109     real fpc;   /* no initial value necessary */
00110     real l2buf[16];
00111     real l2sum1;
00112     integer l2ptr1;   /* initial value 1 */
00113     integer l2ptr2;   /* initial value 9 */
00114     integer lasti;    /* no initial value necessary */
00115     logical hyst;   /* initial value FALSE_ */
00116 
00117     /* State used by function voicin */
00118     real dither;   /* initial value 20.f */
00119     real snr;
00120     real maxmin;
00121     real voice[6] /* was [2][3] */;   /* initial value is probably unnecessary */
00122     integer lbve, lbue, fbve, fbue;
00123     integer ofbue, sfbue;
00124     integer olbue, slbue;
00125     /* Initial values:
00126    lbve = 3000;
00127    fbve = 3000;
00128    fbue = 187;
00129    ofbue = 187;
00130    sfbue = 187;
00131    lbue = 93;
00132    olbue = 93;
00133    slbue = 93;
00134    snr = (real) (fbve / fbue << 6);
00135    */
00136 
00137     /* State used by function dyptrk */
00138     real s[60];
00139     integer p[120]   /* was [60][2] */;
00140     integer ipoint;
00141     real alphax;
00142 
00143     /* State used by function chanwr */
00144     integer isync;
00145 
00146 };
00147 
00148 
00149 struct lpc10_decoder_state {
00150 
00151     /* State used by function decode */
00152     integer iptold;   /* initial value 60 */
00153     logical first;   /* initial value TRUE_ */
00154     integer ivp2h;
00155     integer iovoic;
00156     integer iavgp;   /* initial value 60 */
00157     integer erate;
00158     integer drc[30]  /* was [3][10] */;
00159     integer dpit[3];
00160     integer drms[3];
00161 
00162     /* State used by function synths */
00163     real buf[360];
00164     integer buflen;   /* initial value 180 */
00165 
00166     /* State used by function pitsyn */
00167     integer ivoico;   /* no initial value necessary as long as first_pitsyn is initially TRUE_ */
00168     integer ipito;   /* no initial value necessary as long as first_pitsyn is initially TRUE_ */
00169     real rmso;   /* initial value 1.f */
00170     real rco[10];   /* no initial value necessary as long as first_pitsyn is initially TRUE_ */
00171     integer jsamp;   /* no initial value necessary as long as first_pitsyn is initially TRUE_ */
00172     logical first_pitsyn;   /* initial value TRUE_ */
00173 
00174     /* State used by function bsynz */
00175     integer ipo;
00176     real exc[166];
00177     real exc2[166];
00178     real lpi1;
00179     real lpi2;
00180     real lpi3;
00181     real hpi1;
00182     real hpi2;
00183     real hpi3;
00184     real rmso_bsynz;
00185 
00186     /* State used by function random */
00187     integer j;   /* initial value 2 */
00188     integer k;   /* initial value 5 */
00189     shortint y[5];  /* initial value { -21161,-8478,30892,-10216,16950 } */
00190 
00191     /* State used by function deemp */
00192     real dei1;
00193     real dei2;
00194     real deo1;
00195     real deo2;
00196     real deo3;
00197 
00198 };
00199 
00200 
00201 
00202 /*
00203 
00204   Calling sequence:
00205 
00206   Call create_lpc10_encoder_state(), which returns a pointer to an
00207   already initialized lpc10_encoder_state structure.
00208 
00209   lpc10_encode reads indices 0 through (LPC10_SAMPLES_PER_FRAME-1) of
00210   array speech[], and writes indices 0 through
00211   (LPC10_BITS_IN_COMPRESSED_FRAME-1) of array bits[], and both reads
00212   and writes the lpc10_encoder_state structure contents.  The
00213   lpc10_encoder_state structure should *not* be initialized for every
00214   frame of encoded speech.  Once at the beginning of execution, done
00215   automatically for you by create_lpc10_encoder_state(), is enough.
00216 
00217   init_lpc10_encoder_state() reinitializes the lpc10_encoder_state
00218   structure.  This might be useful if you are finished processing one
00219   sound sample, and want to reuse the same lpc10_encoder_state
00220   structure to process another sound sample.  There might be other
00221   uses as well.
00222 
00223   Note that the comments in the lpc10/lpcenc.c file imply that indices
00224   1 through 180 of array speech[] are read.  These comments were
00225   written for the Fortran version of the code, before it was
00226   automatically converted to C by the conversion program f2c.  f2c
00227   seems to use the convention that the pointers to arrays passed as
00228   function arguments point to the first index used in the Fortran
00229   code, whatever index that might be (usually 1), and then it modifies
00230   the pointer inside of the function, like so:
00231 
00232   if (speech) {
00233       --speech;
00234   }
00235 
00236   So that the code can access the first value at index 1 and the last
00237   at index 180.  This makes the translated C code "closer" to the
00238   original Fortran code.
00239 
00240   The calling sequence for the decoder is similar to the encoder.  The
00241   only significant difference is that the array bits[] is read
00242   (indices 0 through (LPC10_BITS_IN_COMPRESSED_FRAME-1)), and the
00243   array speech[] is written (indices 0 through
00244   (LPC10_SAMPLES_PER_FRAME-1)).
00245   
00246   */
00247 
00248 struct lpc10_encoder_state * create_lpc10_encoder_state (void);
00249 void init_lpc10_encoder_state (struct lpc10_encoder_state *st);
00250 int lpc10_encode (real *speech, INT32 *bits, struct lpc10_encoder_state *st);
00251 
00252 struct lpc10_decoder_state * create_lpc10_decoder_state (void);
00253 void init_lpc10_decoder_state (struct lpc10_decoder_state *st);
00254 int lpc10_decode (INT32 *bits, real *speech, struct lpc10_decoder_state *st);
00255 
00256 #endif /* __LPC10_H__ */

Generated on Thu Apr 16 06:27:38 2015 for Asterisk - The Open Source Telephony Project by  doxygen 1.5.6