Asterisk - The Open Source Telephony Project GIT-master-7921072
difmag.c
Go to the documentation of this file.
1/*
2
3$Log$
4Revision 1.15 2004/06/26 03:50:14 markster
5Merge source cleanups (bug #1911)
6
7Revision 1.14 2003/02/12 13:59:14 matteo
8mer feb 12 14:56:57 CET 2003
9
10Revision 1.1.1.1 2003/02/12 13:59:14 matteo
11mer feb 12 14:56:57 CET 2003
12
13Revision 1.2 2000/01/05 08:20:39 markster
14Some OSS fixes and a few lpc changes to make it actually work
15
16 * Revision 1.1 1996/08/19 22:32:31 jaf
17 * Initial revision
18 *
19
20*/
21
22/* -- translated by f2c (version 19951025).
23 You must link the resulting object file with the libraries:
24 -lf2c -lm (in that order)
25*/
26
27#include "f2c.h"
28
29#ifdef P_R_O_T_O_T_Y_P_E_S
30extern int difmag_(real *speech, integer *lpita, integer *tau, integer *ltau, integer *maxlag, real *amdf, integer *minptr, integer *maxptr);
31#endif
32
33/* ********************************************************************** */
34
35/* DIFMAG Version 49 */
36
37/* $Log$
38 * Revision 1.15 2004/06/26 03:50:14 markster
39 * Merge source cleanups (bug #1911)
40 *
41 * Revision 1.14 2003/02/12 13:59:14 matteo
42 * mer feb 12 14:56:57 CET 2003
43 *
44 * Revision 1.1.1.1 2003/02/12 13:59:14 matteo
45 * mer feb 12 14:56:57 CET 2003
46 *
47 * Revision 1.2 2000/01/05 08:20:39 markster
48 * Some OSS fixes and a few lpc changes to make it actually work
49 *
50 * Revision 1.1 1996/08/19 22:32:31 jaf
51 * Initial revision
52 * */
53/* Revision 1.3 1996/03/15 23:09:39 jaf */
54/* Just added a few comments about which array indices of the arguments */
55/* are used, and mentioning that this subroutine has no local state. */
56
57/* Revision 1.2 1996/03/13 14:41:31 jaf */
58/* Comments added explaining that none of the local variables of this */
59/* subroutine need to be saved from one invocation to the next. */
60
61/* Revision 1.1 1996/02/07 14:45:04 jaf */
62/* Initial revision */
63
64
65/* ********************************************************************* */
66
67/* Compute Average Magnitude Difference Function */
68
69/* Inputs: */
70/* SPEECH - Low pass filtered speech */
71/* Indices MIN_N1 through MAX_N1+LPITA-1 are read, where */
72/* MIN_N1 = (MAXLAG - MAX_TAU)/2+1 MAX_TAU = max of TAU(I) for I=1,LTAU
73*/
74/* MAX_N1 = (MAXLAG - MIN_TAU)/2+1 MIN_TAU = min of TAU(I) for I=1,LTAU
75*/
76/* LPITA - Length of speech buffer */
77/* TAU - Table of lags */
78/* Indices 1 through LTAU read. */
79/* LTAU - Number of lag values to compute */
80/* MAXLAG - Maximum possible lag value */
81/* Outputs: */
82/* (All of these outputs are also read, but only after being written.) */
83/* AMDF - Average Magnitude Difference for each lag in TAU */
84/* Indices 1 through LTAU written */
85/* MINPTR - Index of minimum AMDF value */
86/* MAXPTR - Index of maximum AMDF value */
87
88/* This subroutine has no local state. */
89
90/* Subroutine */ int difmag_(real *speech, integer *lpita, integer *tau,
91 integer *ltau, integer *maxlag, real *amdf, integer *minptr, integer *
92 maxptr)
93{
94 /* System generated locals */
95 integer i__1, i__2;
96 real r__1;
97
98 /* Local variables */
99 integer i__, j, n1, n2;
100 real sum;
101
102/* Arguments */
103/* Local variables that need not be saved */
104/* Local state */
105/* None */
106 /* Parameter adjustments */
107 --amdf;
108 --tau;
109 --speech;
110
111 /* Function Body */
112 *minptr = 1;
113 *maxptr = 1;
114 i__1 = *ltau;
115 for (i__ = 1; i__ <= i__1; ++i__) {
116 n1 = (*maxlag - tau[i__]) / 2 + 1;
117 n2 = n1 + *lpita - 1;
118 sum = 0.f;
119 i__2 = n2;
120 for (j = n1; j <= i__2; j += 4) {
121 sum += (r__1 = speech[j] - speech[j + tau[i__]], abs(r__1));
122 }
123 amdf[i__] = sum;
124 if (amdf[i__] < amdf[*minptr]) {
125 *minptr = i__;
126 }
127 if (amdf[i__] > amdf[*maxptr]) {
128 *maxptr = i__;
129 }
130 }
131 return 0;
132} /* difmag_ */
int difmag_(real *speech, integer *lpita, integer *tau, integer *ltau, integer *maxlag, real *amdf, integer *minptr, integer *maxptr)
Definition: difmag.c:90
#define abs(x)
Definition: f2c.h:195
float real
Definition: lpc10.h:79
INT32 integer
Definition: lpc10.h:80