audiotone.h 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687
  1. #ifndef __AUDIOTONE_H__
  2. #define __AUDIOTONE_H__
  3. #pragma once
  4. #ifdef __cplusplus
  5. extern "C" {
  6. #endif
  7. #include <apr_general.h>
  8. #include "audiostream.h"
  9. struct gen
  10. {
  11. float a, s0, s1;
  12. };
  13. struct gen_state
  14. {
  15. struct gen tone1;
  16. struct gen tone2;
  17. int has_tone2;
  18. };
  19. typedef struct audiotone_t {
  20. audiostream_t base;
  21. int options;
  22. int playback_options;
  23. int fade_in_len; /* fade in for this # of samples */
  24. int fade_out_len; /* fade out for this # of samples*/
  25. int clock;
  26. int ptime;
  27. /* Tone generation state */
  28. struct gen_state state;
  29. int dig_fi;
  30. int dig_samples; /* sample pos in cur digit */
  31. int freq1;
  32. int freq2;
  33. int on_msec;
  34. int off_msec;
  35. int volume;
  36. int flags;
  37. CRITICAL_SECTION lock;
  38. }audiotone_t;
  39. #define TONEGEN_LOOP 1
  40. apr_status_t audiotone_create(apr_pool_t *pool,
  41. audioengine_t *engine,
  42. int options,
  43. int clock,
  44. int ptime,
  45. audiotone_t **p_tone);
  46. void audiotone_destroy(audiotone_t *tone);
  47. // Volume (1-32767), or 0 for default
  48. apr_status_t audiotone_play_start_digit(audiotone_t *tone,
  49. int digit,
  50. int on_msec,
  51. int off_msec,
  52. int volume,
  53. int options);
  54. // freq 2 can be Optional
  55. apr_status_t audiotone_play_start_tone(audiotone_t *tone,
  56. int freq1,
  57. int freq2,
  58. int on_msec,
  59. int off_msec,
  60. int volume,
  61. int options);
  62. // stop play
  63. apr_status_t audiotone_play_end(audiotone_t *tone);
  64. #ifdef __cplusplus
  65. } // extern "C" {
  66. #endif
  67. #endif //__AUDIOTONE_H__