dtmf_dolphin_audio.h 959 B

123456789101112131415161718192021222324252627282930313233343536373839404142
  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. size_t buffer_length;
  12. float* sample_buffer;
  13. uint16_t offset;
  14. } DTMFDolphinOsc;
  15. typedef struct {
  16. size_t buffer_length;
  17. size_t half_buffer_length;
  18. uint8_t *buffer_buffer;
  19. uint16_t *sample_buffer;
  20. float volume;
  21. bool playing;
  22. FuriMessageQueue *queue;
  23. DTMFDolphinOsc *osc1;
  24. DTMFDolphinOsc *osc2;
  25. } DTMFDolphinAudio;
  26. DTMFDolphinOsc* dtmf_dolphin_osc_alloc();
  27. DTMFDolphinAudio* dtmf_dolphin_audio_alloc();
  28. void dtmf_dolphin_audio_free(DTMFDolphinAudio* player);
  29. void dtmf_dolphin_osc_free(DTMFDolphinOsc* osc);
  30. bool dtmf_dolphin_audio_play_tones(float freq1, float freq2);
  31. bool dtmf_dolphin_audio_stop_tones();
  32. bool dtmf_dolphin_audio_handle_tick();