dtmf_dolphin_audio.h 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  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(float freq1, float freq2, uint16_t pulses, uint16_t pulse_ms, uint16_t gap_ms);
  37. bool dtmf_dolphin_audio_stop_tones();
  38. bool dtmf_dolphin_audio_handle_tick();