energy.c 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102
  1. /*
  2. $Log$
  3. Revision 1.15 2004/06/26 03:50:14 markster
  4. Merge source cleanups (bug #1911)
  5. Revision 1.14 2003/02/12 13:59:15 matteo
  6. mer feb 12 14:56:57 CET 2003
  7. Revision 1.1.1.1 2003/02/12 13:59:15 matteo
  8. mer feb 12 14:56:57 CET 2003
  9. Revision 1.2 2000/01/05 08:20:39 markster
  10. Some OSS fixes and a few lpc changes to make it actually work
  11. * Revision 1.1 1996/08/19 22:32:17 jaf
  12. * Initial revision
  13. *
  14. */
  15. /* -- translated by f2c (version 19951025).
  16. You must link the resulting object file with the libraries:
  17. -lf2c -lm (in that order)
  18. */
  19. #include "f2c.h"
  20. #ifdef P_R_O_T_O_T_Y_P_E_S
  21. extern int energy_(integer *len, real *speech, real *rms);
  22. #endif
  23. /* ********************************************************************* */
  24. /* ENERGY Version 50 */
  25. /* $Log$
  26. * Revision 1.15 2004/06/26 03:50:14 markster
  27. * Merge source cleanups (bug #1911)
  28. *
  29. * Revision 1.14 2003/02/12 13:59:15 matteo
  30. * mer feb 12 14:56:57 CET 2003
  31. *
  32. * Revision 1.1.1.1 2003/02/12 13:59:15 matteo
  33. * mer feb 12 14:56:57 CET 2003
  34. *
  35. * Revision 1.2 2000/01/05 08:20:39 markster
  36. * Some OSS fixes and a few lpc changes to make it actually work
  37. *
  38. * Revision 1.1 1996/08/19 22:32:17 jaf
  39. * Initial revision
  40. * */
  41. /* Revision 1.3 1996/03/18 21:17:41 jaf */
  42. /* Just added a few comments about which array indices of the arguments */
  43. /* are used, and mentioning that this subroutine has no local state. */
  44. /* Revision 1.2 1996/03/13 16:46:02 jaf */
  45. /* Comments added explaining that none of the local variables of this */
  46. /* subroutine need to be saved from one invocation to the next. */
  47. /* Revision 1.1 1996/02/07 14:45:40 jaf */
  48. /* Initial revision */
  49. /* ********************************************************************* */
  50. /* Compute RMS energy. */
  51. /* Input: */
  52. /* LEN - Length of speech buffer */
  53. /* SPEECH - Speech buffer */
  54. /* Indices 1 through LEN read. */
  55. /* Output: */
  56. /* RMS - Root Mean Square energy */
  57. /* This subroutine has no local state. */
  58. /* Subroutine */ int energy_(integer *len, real *speech, real *rms)
  59. {
  60. /* System generated locals */
  61. integer i__1;
  62. /* Builtin functions */
  63. double sqrt(doublereal);
  64. /* Local variables */
  65. integer i__;
  66. /* Arguments */
  67. /* Local variables that need not be saved */
  68. /* Parameter adjustments */
  69. --speech;
  70. /* Function Body */
  71. *rms = 0.f;
  72. i__1 = *len;
  73. for (i__ = 1; i__ <= i__1; ++i__) {
  74. *rms += speech[i__] * speech[i__];
  75. }
  76. *rms = (real)sqrt(*rms / *len);
  77. return 0;
  78. } /* energy_ */