difmag.c

Go to the documentation of this file.
00001 /*
00002 
00003 $Log$
00004 Revision 1.15  2004/06/26 03:50:14  markster
00005 Merge source cleanups (bug #1911)
00006 
00007 Revision 1.14  2003/02/12 13:59:14  matteo
00008 mer feb 12 14:56:57 CET 2003
00009 
00010 Revision 1.1.1.1  2003/02/12 13:59:14  matteo
00011 mer feb 12 14:56:57 CET 2003
00012 
00013 Revision 1.2  2000/01/05 08:20:39  markster
00014 Some OSS fixes and a few lpc changes to make it actually work
00015 
00016  * Revision 1.1  1996/08/19  22:32:31  jaf
00017  * Initial revision
00018  *
00019 
00020 */
00021 
00022 /*  -- translated by f2c (version 19951025).
00023    You must link the resulting object file with the libraries:
00024    -lf2c -lm   (in that order)
00025 */
00026 
00027 #include "f2c.h"
00028 
00029 #ifdef P_R_O_T_O_T_Y_P_E_S
00030 extern int difmag_(real *speech, integer *lpita, integer *tau, integer *ltau, integer *maxlag, real *amdf, integer *minptr, integer *maxptr);
00031 #endif
00032 
00033 /* ********************************************************************** */
00034 
00035 /*    DIFMAG Version 49 */
00036 
00037 /* $Log$
00038  * Revision 1.15  2004/06/26 03:50:14  markster
00039  * Merge source cleanups (bug #1911)
00040  *
00041  * Revision 1.14  2003/02/12 13:59:14  matteo
00042  * mer feb 12 14:56:57 CET 2003
00043  *
00044  * Revision 1.1.1.1  2003/02/12 13:59:14  matteo
00045  * mer feb 12 14:56:57 CET 2003
00046  *
00047  * Revision 1.2  2000/01/05 08:20:39  markster
00048  * Some OSS fixes and a few lpc changes to make it actually work
00049  *
00050  * Revision 1.1  1996/08/19  22:32:31  jaf
00051  * Initial revision
00052  * */
00053 /* Revision 1.3  1996/03/15  23:09:39  jaf */
00054 /* Just added a few comments about which array indices of the arguments */
00055 /* are used, and mentioning that this subroutine has no local state. */
00056 
00057 /* Revision 1.2  1996/03/13  14:41:31  jaf */
00058 /* Comments added explaining that none of the local variables of this */
00059 /* subroutine need to be saved from one invocation to the next. */
00060 
00061 /* Revision 1.1  1996/02/07 14:45:04  jaf */
00062 /* Initial revision */
00063 
00064 
00065 /* ********************************************************************* */
00066 
00067 /*  Compute Average Magnitude Difference Function */
00068 
00069 /* Inputs: */
00070 /*  SPEECH - Low pass filtered speech */
00071 /*           Indices MIN_N1 through MAX_N1+LPITA-1 are read, where */
00072 /*      MIN_N1 = (MAXLAG - MAX_TAU)/2+1  MAX_TAU = max of TAU(I) for I=1,LTAU
00073 */
00074 /*      MAX_N1 = (MAXLAG - MIN_TAU)/2+1  MIN_TAU = min of TAU(I) for I=1,LTAU
00075 */
00076 /*  LPITA  - Length of speech buffer */
00077 /*  TAU    - Table of lags */
00078 /*           Indices 1 through LTAU read. */
00079 /*  LTAU   - Number of lag values to compute */
00080 /*  MAXLAG - Maximum possible lag value */
00081 /* Outputs: */
00082 /*  (All of these outputs are also read, but only after being written.) */
00083 /*  AMDF   - Average Magnitude Difference for each lag in TAU */
00084 /*           Indices 1 through LTAU written */
00085 /*  MINPTR - Index of minimum AMDF value */
00086 /*  MAXPTR - Index of maximum AMDF value */
00087 
00088 /* This subroutine has no local state. */
00089 
00090 /* Subroutine */ int difmag_(real *speech, integer *lpita, integer *tau, 
00091    integer *ltau, integer *maxlag, real *amdf, integer *minptr, integer *
00092    maxptr)
00093 {
00094     /* System generated locals */
00095     integer i__1, i__2;
00096     real r__1;
00097 
00098     /* Local variables */
00099     integer i__, j, n1, n2;
00100     real sum;
00101 
00102 /*       Arguments */
00103 /*       Local variables that need not be saved */
00104 /*       Local state */
00105 /*       None */
00106     /* Parameter adjustments */
00107     --amdf;
00108     --tau;
00109     --speech;
00110 
00111     /* Function Body */
00112     *minptr = 1;
00113     *maxptr = 1;
00114     i__1 = *ltau;
00115     for (i__ = 1; i__ <= i__1; ++i__) {
00116    n1 = (*maxlag - tau[i__]) / 2 + 1;
00117    n2 = n1 + *lpita - 1;
00118    sum = 0.f;
00119    i__2 = n2;
00120    for (j = n1; j <= i__2; j += 4) {
00121        sum += (r__1 = speech[j] - speech[j + tau[i__]], abs(r__1));
00122    }
00123    amdf[i__] = sum;
00124    if (amdf[i__] < amdf[*minptr]) {
00125        *minptr = i__;
00126    }
00127    if (amdf[i__] > amdf[*maxptr]) {
00128        *maxptr = i__;
00129    }
00130     }
00131     return 0;
00132 } /* difmag_ */
00133 

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