wav_player_view.h 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  1. #pragma once
  2. #include <gui/view.h>
  3. #include <furi.h>
  4. #include <furi_hal.h>
  5. #include <cli/cli.h>
  6. #include <gui/gui.h>
  7. #include <stm32wbxx_ll_dma.h>
  8. #include <dialogs/dialogs.h>
  9. #include <notification/notification_messages.h>
  10. #include <gui/view_dispatcher.h>
  11. #include <toolbox/stream/file_stream.h>
  12. #ifdef __cplusplus
  13. extern "C" {
  14. #endif
  15. typedef struct WavPlayerView WavPlayerView;
  16. typedef enum {
  17. WavPlayerCtrlVolUp,
  18. WavPlayerCtrlVolDn,
  19. WavPlayerCtrlMoveL,
  20. WavPlayerCtrlMoveR,
  21. WavPlayerCtrlOk,
  22. WavPlayerCtrlBack,
  23. } WavPlayerCtrl;
  24. typedef void (*WavPlayerCtrlCallback)(WavPlayerCtrl ctrl, void* context);
  25. #define DATA_COUNT 116
  26. struct WavPlayerView {
  27. View* view;
  28. WavPlayerCtrlCallback callback;
  29. void* context;
  30. };
  31. typedef struct {
  32. bool play;
  33. float volume;
  34. size_t start;
  35. size_t end;
  36. size_t current;
  37. uint8_t data[DATA_COUNT];
  38. uint16_t bits_per_sample;
  39. uint16_t num_channels;
  40. } WavPlayerViewModel;
  41. WavPlayerView* wav_player_view_alloc();
  42. void wav_player_view_free(WavPlayerView* wav_view);
  43. View* wav_player_view_get_view(WavPlayerView* wav_view);
  44. void wav_player_view_set_volume(WavPlayerView* wav_view, float volume);
  45. void wav_player_view_set_start(WavPlayerView* wav_view, size_t start);
  46. void wav_player_view_set_end(WavPlayerView* wav_view, size_t end);
  47. void wav_player_view_set_current(WavPlayerView* wav_view, size_t current);
  48. void wav_player_view_set_play(WavPlayerView* wav_view, bool play);
  49. void wav_player_view_set_data(WavPlayerView* wav_view, uint16_t* data, size_t data_count);
  50. void wav_player_view_set_bits(WavPlayerView* wav_view, uint16_t bit);
  51. void wav_player_view_set_chans(WavPlayerView* wav_view, uint16_t chn);
  52. void wav_player_view_set_ctrl_callback(WavPlayerView* wav_view, WavPlayerCtrlCallback callback);
  53. void wav_player_view_set_context(WavPlayerView* wav_view, void* context);
  54. #ifdef __cplusplus
  55. }
  56. #endif