wav_player_view.h 1.6 KB

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