flizzer_tracker.h 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202
  1. #pragma once
  2. #include <cli/cli.h>
  3. #include <dialogs/dialogs.h>
  4. #include <furi.h>
  5. #include <gui/gui.h>
  6. #include <gui/modules/submenu.h>
  7. #include <gui/modules/widget.h>
  8. #include <input/input.h>
  9. #include <notification/notification_messages.h>
  10. #include <stdio.h>
  11. #include <toolbox/stream/file_stream.h>
  12. #include <storage/storage.h>
  13. #include <u8g2_glue.h>
  14. #include <gui/modules/text_input.h>
  15. #include <gui/view_dispatcher.h>
  16. #include "flizzer_tracker_hal.h"
  17. #include "sound_engine/freqs.h"
  18. #include "sound_engine/sound_engine_defs.h"
  19. #include "sound_engine/sound_engine_filter.h"
  20. #include "tracker_engine/tracker_engine_defs.h"
  21. #define FLIZZER_TRACKER_FOLDER "/ext/flizzer_tracker"
  22. #define FILE_NAME_LEN 64
  23. typedef enum
  24. {
  25. EventTypeInput,
  26. EventTypeSaveSong,
  27. } EventType;
  28. typedef struct
  29. {
  30. EventType type;
  31. InputEvent input;
  32. uint32_t period;
  33. } FlizzerTrackerEvent;
  34. typedef enum
  35. {
  36. PATTERN_VIEW,
  37. INST_EDITOR_VIEW,
  38. EXPORT_WAV_VIEW,
  39. } TrackerMode;
  40. typedef enum
  41. {
  42. EDIT_PATTERN,
  43. EDIT_SEQUENCE,
  44. EDIT_SONGINFO,
  45. EDIT_INSTRUMENT,
  46. EDIT_PROGRAM,
  47. } TrackerFocus;
  48. typedef enum
  49. {
  50. SI_PATTERNPOS,
  51. SI_SEQUENCEPOS,
  52. SI_SONGSPEED,
  53. SI_SONGRATE,
  54. SI_MASTERVOL,
  55. SI_SONGNAME,
  56. SI_CURRENTINSTRUMENT,
  57. SI_INSTRUMENTNAME,
  58. /* ======== */
  59. SI_PARAMS,
  60. } SongInfoParam;
  61. typedef enum
  62. {
  63. INST_CURRENTINSTRUMENT,
  64. INST_INSTRUMENTNAME,
  65. INST_CURRENT_NOTE,
  66. INST_FINETUNE,
  67. INST_SLIDESPEED,
  68. INST_SETPW,
  69. INST_PW,
  70. INST_SETCUTOFF,
  71. INST_WAVE_NOISE,
  72. INST_WAVE_PULSE,
  73. INST_WAVE_TRIANGLE,
  74. INST_WAVE_SAWTOOTH,
  75. INST_WAVE_NOISE_METAL,
  76. INST_WAVE_SINE,
  77. INST_ATTACK,
  78. INST_DECAY,
  79. INST_SUSTAIN,
  80. INST_RELEASE,
  81. INST_VOLUME,
  82. INST_ENABLEFILTER,
  83. INST_FILTERCUTOFF,
  84. INST_FILTERRESONANCE,
  85. INST_FILTERTYPE,
  86. INST_ENABLERINGMOD,
  87. INST_RINGMODSRC,
  88. INST_ENABLEHARDSYNC,
  89. INST_HARDSYNCSRC,
  90. INST_RETRIGGERONSLIDE,
  91. INST_ENABLEKEYSYNC,
  92. INST_ENABLEVIBRATO,
  93. INST_VIBRATOSPEED,
  94. INST_VIBRATODEPTH,
  95. INST_VIBRATODELAY,
  96. INST_ENABLEPWM,
  97. INST_PWMSPEED,
  98. INST_PWMDEPTH,
  99. INST_PWMDELAY,
  100. INST_PROGRAMEPERIOD,
  101. /* ========= */
  102. INST_PARAMS,
  103. } InstrumentParam;
  104. typedef struct
  105. {
  106. View *view;
  107. void *context;
  108. } TrackerView;
  109. typedef enum
  110. {
  111. VIEW_TRACKER,
  112. VIEW_KEYBOARD,
  113. VIEW_SUBMENU_PATTERN,
  114. VIEW_SUBMENU_INSTRUMENT,
  115. VIEW_FILE_OVERWRITE,
  116. } FlizzerTrackerViews;
  117. typedef enum
  118. {
  119. SUBMENU_PATTERN_RETURN,
  120. SUBMENU_PATTERN_LOAD_SONG,
  121. SUBMENU_PATTERN_SAVE_SONG,
  122. SUBMENU_PATTERN_EXIT,
  123. } PatternSubmenuParams;
  124. typedef enum
  125. {
  126. SUBMENU_INSTRUMENT_RETURN,
  127. SUBMENU_INSTRUMENT_EXIT,
  128. } InstrumentSubmenuParams;
  129. typedef struct
  130. {
  131. NotificationApp *notification;
  132. FuriMessageQueue *event_queue;
  133. Gui *gui;
  134. TrackerView *tracker_view;
  135. ViewDispatcher *view_dispatcher;
  136. TextInput *text_input;
  137. Storage* storage;
  138. Stream *stream;
  139. FuriString* filepath;
  140. DialogsApp *dialogs;
  141. Submenu *pattern_submenu;
  142. Submenu *instrument_submenu;
  143. Widget* overwrite_file_widget;
  144. char filename[FILE_NAME_LEN + 1];
  145. bool was_it_back_keypress;
  146. uint32_t current_time;
  147. uint32_t period;
  148. SoundEngine sound_engine;
  149. TrackerEngine tracker_engine;
  150. TrackerSong song;
  151. uint8_t selected_param;
  152. uint8_t mode, focus;
  153. uint8_t patternx, current_channel, current_digit, program_position, current_program_step, current_instrument, current_note;
  154. uint8_t inst_editor_shift;
  155. bool editing;
  156. bool was_editing;
  157. bool is_loading;
  158. bool is_saving;
  159. bool quit;
  160. } FlizzerTrackerApp;
  161. typedef struct
  162. {
  163. FlizzerTrackerApp *tracker;
  164. } TrackerViewModel;
  165. void draw_callback(Canvas *canvas, void *ctx);
  166. bool input_callback(InputEvent *input_event, void *ctx);