You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 

72 lines
1.7 KiB

  1. /*
  2. * Atpdec
  3. * Copyright (c) 2004 by Thierry Leconte (F4DWV)
  4. *
  5. * $Id$
  6. *
  7. * This library is free software; you can redistribute it and/or modify
  8. * it under the terms of the GNU Library General Public License as
  9. * published by the Free Software Foundation; either version 2 of
  10. * the License, or (at your option) any later version.
  11. *
  12. * This program is distributed in the hope that it will be useful,
  13. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  14. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  15. * GNU Library General Public License for more details.
  16. *
  17. * You should have received a copy of the GNU Library General Public
  18. * License along with this library; if not, write to the Free Software
  19. * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  20. *
  21. */
  22. #include "filter.h"
  23. #include <math.h>
  24. float fir(float *buff, const float *coeff, const int len)
  25. {
  26. int i;
  27. double r;
  28. r = 0.0;
  29. for (i = 0; i < len; i++) {
  30. r += buff[i] * coeff[i];
  31. }
  32. return r;
  33. }
  34. void iqfir(float *buff, const float *coeff, const int len,double *I,double *Q)
  35. {
  36. int k;
  37. double i,q;
  38. i=q=0.0;
  39. for (k = 0; k < len-1; k++) {
  40. q += buff[2*k] * coeff[k];
  41. i += buff[2*k+1] ;
  42. }
  43. q += buff[2*k] * coeff[k];
  44. i= buff[len-1]-i/len;
  45. *I=i,*Q=q;
  46. }
  47. float
  48. rsfir(float *buff, const float *coeff, const int len, const double offset,
  49. const double delta)
  50. {
  51. int i;
  52. double n;
  53. double out;
  54. out = 0.0;
  55. for (i = 0, n = offset; i < (len-1)/delta-1; n += delta, i++) {
  56. int k;
  57. double alpha;
  58. k = (int)floor(n);
  59. alpha = n - k;
  60. out += buff[i]*(coeff[k]*(1.0-alpha)+coeff[k + 1]*alpha);
  61. }
  62. return out;
  63. }