dtmf_dolphin_audio.h 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. #pragma once
  2. // #include "dtmf_dolphin_i.h"
  3. #include "dtmf_dolphin_event.h"
  4. #include "dtmf_dolphin_hal.h"
  5. #define SAMPLE_BUFFER_LENGTH 8192
  6. #define PERIOD_2_PI 6.2832
  7. #define CPU_CLOCK_FREQ 64000000
  8. typedef struct {
  9. float cached_freq;
  10. size_t period;
  11. float* lookup_table;
  12. uint16_t offset;
  13. } DTMFDolphinOsc;
  14. typedef struct {
  15. float duration;
  16. size_t period;
  17. bool* lookup_table;
  18. uint16_t offset;
  19. } DTMFDolphinPulseFilter;
  20. typedef struct {
  21. size_t buffer_length;
  22. size_t half_buffer_length;
  23. uint8_t* buffer_buffer;
  24. uint16_t* sample_buffer;
  25. float volume;
  26. FuriMessageQueue* queue;
  27. DTMFDolphinOsc* osc1;
  28. DTMFDolphinOsc* osc2;
  29. DTMFDolphinPulseFilter* filter;
  30. bool playing;
  31. } DTMFDolphinAudio;
  32. DTMFDolphinOsc* dtmf_dolphin_osc_alloc();
  33. DTMFDolphinAudio* dtmf_dolphin_audio_alloc();
  34. void dtmf_dolphin_audio_free(DTMFDolphinAudio* player);
  35. void dtmf_dolphin_osc_free(DTMFDolphinOsc* osc);
  36. bool dtmf_dolphin_audio_play_tones(
  37. float freq1,
  38. float freq2,
  39. uint16_t pulses,
  40. uint16_t pulse_ms,
  41. uint16_t gap_ms);
  42. bool dtmf_dolphin_audio_stop_tones();
  43. bool dtmf_dolphin_audio_handle_tick();