energy.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:15  matteo
00008 mer feb 12 14:56:57 CET 2003
00009 
00010 Revision 1.1.1.1  2003/02/12 13:59:15  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:17  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 energy_(integer *len, real *speech, real *rms);
00031 #endif
00032 
00033 /* ********************************************************************* */
00034 
00035 /*    ENERGY Version 50 */
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:15  matteo
00042  * mer feb 12 14:56:57 CET 2003
00043  *
00044  * Revision 1.1.1.1  2003/02/12 13:59:15  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:17  jaf
00051  * Initial revision
00052  * */
00053 /* Revision 1.3  1996/03/18  21:17:41  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  16:46:02  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:40  jaf */
00062 /* Initial revision */
00063 
00064 
00065 /* ********************************************************************* */
00066 
00067 /* Compute RMS energy. */
00068 
00069 /* Input: */
00070 /*  LEN    - Length of speech buffer */
00071 /*  SPEECH - Speech buffer */
00072 /*           Indices 1 through LEN read. */
00073 /* Output: */
00074 /*  RMS    - Root Mean Square energy */
00075 
00076 /* This subroutine has no local state. */
00077 
00078 /* Subroutine */ int energy_(integer *len, real *speech, real *rms)
00079 {
00080     /* System generated locals */
00081     integer i__1;
00082 
00083     /* Builtin functions */
00084     double sqrt(doublereal);
00085 
00086     /* Local variables */
00087     integer i__;
00088 
00089 /*       Arguments */
00090 /*       Local variables that need not be saved */
00091     /* Parameter adjustments */
00092     --speech;
00093 
00094     /* Function Body */
00095     *rms = 0.f;
00096     i__1 = *len;
00097     for (i__ = 1; i__ <= i__1; ++i__) {
00098    *rms += speech[i__] * speech[i__];
00099     }
00100     *rms = (real)sqrt(*rms / *len);
00101     return 0;
00102 } /* energy_ */
00103 

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