dtmf_dolphin_audio.h 914 B

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