libcm is a C development framework with an emphasis on audio signal processing applications.
Você não pode selecionar mais de 25 tópicos Os tópicos devem começar com uma letra ou um número, podem incluir traços ('-') e podem ter até 35 caracteres.

cmOp.c 1.6KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283
  1. #include "cmPrefix.h"
  2. #include "cmGlobal.h"
  3. #include "cmFloatTypes.h"
  4. #include "cmOp.h"
  5. void vs_Zero( cmSample_t v[], unsigned vn)
  6. { memset(v,0,sizeof(v[0])*vn); }
  7. cmReal_t vs_Sine( cmSample_t v[], unsigned vn, cmReal_t hzRad, cmReal_t initPhs )
  8. {
  9. const cmSample_t* ep = v + vn;
  10. double phs = initPhs;
  11. while(v<ep)
  12. {
  13. *v++ = (cmSample_t)sin( phs );
  14. phs += hzRad;
  15. }
  16. return (cmReal_t)phs;
  17. }
  18. void vs_Rand( cmSample_t v[], unsigned vn, cmSample_t min, cmSample_t max )
  19. {
  20. const cmSample_t* ep = v + vn;
  21. while(v<ep)
  22. *v++ = ((cmSample_t)rand()/RAND_MAX) * (max-min) + min;
  23. }
  24. void vs_MultVVS( cmSample_t d[], const cmSample_t s[], unsigned n, cmReal_t mult )
  25. {
  26. const cmSample_t* ep = d + n;
  27. while(d<ep)
  28. *d++ = *s++ * mult;
  29. }
  30. void vs_SumMultVVS( cmSample_t d[], const cmSample_t s[], unsigned n, cmReal_t mult )
  31. {
  32. const cmSample_t* ep = d + n;
  33. while(d<ep)
  34. *d++ += *s++ * mult;
  35. }
  36. void vs_Copy( cmSample_t d[], const cmSample_t s[], unsigned n )
  37. {
  38. memcpy(d,s,n*sizeof(d[0]));
  39. }
  40. cmSample_t vs_SquaredSum( const cmSample_t s[], unsigned n )
  41. {
  42. cmSample_t sum = 0;
  43. const cmSample_t* ep = s + n;
  44. for(;s<ep;++s)
  45. sum += *s * *s;
  46. return sum;
  47. }
  48. /*
  49. unsigned vs_Interp2( cmSample_t v[], unsigned vn, const cmSample_t[] xx, const cmSample_t y[], unsigned yn )
  50. {
  51. unsigned i = 0;
  52. for(; i<vn; ++i)
  53. {
  54. double x = fmod(*xx++,yn);
  55. unsigned x0 = floor(x);
  56. unsigned x1 = x0 + 1;
  57. double d = x - x0;
  58. if( x1>=yn || x0>=yn)
  59. break;
  60. *v++ = y[x0] + (y[x1] - y[x0]) * d;
  61. }
  62. return i;
  63. }
  64. */