libcm is a C development framework with an emphasis on audio signal processing applications.
選択できるのは25トピックまでです。 トピックは、先頭が英数字で、英数字とダッシュ('-')を使用した35文字以内のものにしてください。

cmMath.h 2.4KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  1. #ifndef cmMath_h
  2. #define cmMath_h
  3. double cmX80ToDouble( unsigned char s[10] );
  4. void cmDoubleToX80( double v, unsigned char s[10] );
  5. bool cmIsPowerOfTwo( unsigned i );
  6. unsigned cmNextPowerOfTwo( unsigned i );
  7. unsigned cmNearPowerOfTwo( unsigned i );
  8. bool cmIsOddU( unsigned v );
  9. bool cmIsEvenU( unsigned v );
  10. unsigned cmNextOddU( unsigned v );
  11. unsigned cmPrevOddU( unsigned v );
  12. unsigned cmNextEvenU( unsigned v );
  13. unsigned cmPrevEvenU( unsigned v );
  14. // modified bessel function of first kind, order 0
  15. // ref: orfandis appendix B io.m
  16. double cmBessel0( double x );
  17. //=================================================================
  18. // The following elliptic-related function approximations come from
  19. // Parks & Burrus, Digital Filter Design, Appendix program 9, pp. 317-326
  20. // which in turn draws directly on other sources
  21. // calculate complete elliptic integral (quarter period) K
  22. // given *complimentary* modulus kc
  23. cmReal_t cmEllipK( cmReal_t kc );
  24. // calculate elliptic modulus k
  25. // given ratio of complete elliptic integrals r = K/K'
  26. // (solves the "degree equation" for fixed N = K*K1'/K'K1)
  27. cmReal_t cmEllipDeg( cmReal_t r );
  28. // calculate arc elliptic tangent u (elliptic integral of the 1st kind)
  29. // given argument x = sc(u,k) and *complimentary* modulus kc
  30. cmReal_t cmEllipArcSc( cmReal_t x, cmReal_t kc );
  31. // calculate Jacobi elliptic functions sn, cn, and dn
  32. // given argument u and *complimentary* modulus kc
  33. cmRC_t cmEllipJ( cmReal_t u, cmReal_t kc, cmReal_t* sn, cmReal_t* cn, cmReal_t* dn );
  34. //=================================================================
  35. // bilinear transform
  36. // z = (2*sr + s)/(2*sr - s)
  37. cmRC_t cmBlt( unsigned n, cmReal_t sr, cmReal_t* rp, cmReal_t* ip );
  38. //=================================================================
  39. // Pitch conversion
  40. unsigned cmHzToMidi( double hz );
  41. float cmMidiToHz( unsigned midi );
  42. //=================================================================
  43. // Floating point byte swapping
  44. unsigned cmFfSwapFloatToUInt( float v );
  45. float cmFfSwapUIntToFloat( unsigned v );
  46. unsigned long long cmFfSwapDoubleToULLong( double v );
  47. double cmFfSwapULLongToDouble( unsigned long long v );
  48. //=================================================================
  49. int cmRandInt( int min, int max );
  50. unsigned cmRandUInt( unsigned min, unsigned max );
  51. float cmRandFloat( float min, float max );
  52. double cmRandDouble( double min, double max );
  53. #endif