flizzer_tracker.h 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225
  1. #pragma once
  2. #include <dialogs/dialogs.h>
  3. #include <furi.h>
  4. #include <gui/gui.h>
  5. #include <gui/modules/submenu.h>
  6. #include <gui/modules/widget.h>
  7. #include <input/input.h>
  8. #include <notification/notification_messages.h>
  9. #include <stdio.h>
  10. #include <storage/storage.h>
  11. #include <toolbox/stream/file_stream.h>
  12. #include <gui/modules/text_input.h>
  13. #include <gui/modules/variable_item_list.h>
  14. #include <gui/view_dispatcher.h>
  15. #include "flizzer_tracker_hal.h"
  16. #include "sound_engine/freqs.h"
  17. #include "sound_engine/sound_engine_defs.h"
  18. #include "sound_engine/sound_engine_filter.h"
  19. #include "tracker_engine/tracker_engine_defs.h"
  20. #define APPSDATA_FOLDER "/ext/apps_data"
  21. #define FLIZZER_TRACKER_FOLDER "/ext/apps_data/flizzer_tracker"
  22. #define FLIZZER_TRACKER_INSTRUMENTS_FOLDER "/ext/apps_data/flizzer_tracker/instruments"
  23. #define FILE_NAME_LEN 64
  24. typedef enum {
  25. EventTypeInput,
  26. EventTypeSaveSong,
  27. EventTypeLoadSong,
  28. EventTypeLoadInstrument,
  29. EventTypeSaveInstrument,
  30. EventTypeSetAudioMode,
  31. } EventType;
  32. typedef struct {
  33. EventType type;
  34. InputEvent input;
  35. uint32_t period;
  36. } FlizzerTrackerEvent;
  37. typedef enum {
  38. PATTERN_VIEW,
  39. INST_EDITOR_VIEW,
  40. EXPORT_WAV_VIEW,
  41. } TrackerMode;
  42. typedef enum {
  43. EDIT_PATTERN,
  44. EDIT_SEQUENCE,
  45. EDIT_SONGINFO,
  46. EDIT_INSTRUMENT,
  47. EDIT_PROGRAM,
  48. } TrackerFocus;
  49. typedef enum {
  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. INST_CURRENTINSTRUMENT,
  63. INST_INSTRUMENTNAME,
  64. INST_CURRENT_NOTE,
  65. INST_FINETUNE,
  66. INST_SLIDESPEED,
  67. INST_SETPW,
  68. INST_PW,
  69. INST_SETCUTOFF,
  70. INST_WAVE_NOISE,
  71. INST_WAVE_PULSE,
  72. INST_WAVE_TRIANGLE,
  73. INST_WAVE_SAWTOOTH,
  74. INST_WAVE_NOISE_METAL,
  75. INST_WAVE_SINE,
  76. INST_ATTACK,
  77. INST_DECAY,
  78. INST_SUSTAIN,
  79. INST_RELEASE,
  80. INST_VOLUME,
  81. INST_ENABLEFILTER,
  82. INST_FILTERCUTOFF,
  83. INST_FILTERRESONANCE,
  84. INST_FILTERTYPE,
  85. INST_ENABLERINGMOD,
  86. INST_RINGMODSRC,
  87. INST_ENABLEHARDSYNC,
  88. INST_HARDSYNCSRC,
  89. INST_RETRIGGERONSLIDE,
  90. INST_ENABLEKEYSYNC,
  91. INST_ENABLEVIBRATO,
  92. INST_VIBRATOSPEED,
  93. INST_VIBRATODEPTH,
  94. INST_VIBRATODELAY,
  95. INST_ENABLEPWM,
  96. INST_PWMSPEED,
  97. INST_PWMDEPTH,
  98. INST_PWMDELAY,
  99. INST_PROGRESTART,
  100. INST_PROGRAMEPERIOD,
  101. /* ========= */
  102. INST_PARAMS,
  103. } InstrumentParam;
  104. typedef struct {
  105. View* view;
  106. void* context;
  107. } TrackerView;
  108. typedef enum {
  109. VIEW_TRACKER,
  110. VIEW_KEYBOARD,
  111. VIEW_SUBMENU_PATTERN,
  112. VIEW_SUBMENU_PATTERN_COPYPASTE,
  113. VIEW_SUBMENU_INSTRUMENT,
  114. VIEW_FILE_OVERWRITE,
  115. VIEW_INSTRUMENT_FILE_OVERWRITE,
  116. VIEW_SETTINGS,
  117. } FlizzerTrackerViews;
  118. typedef enum {
  119. SUBMENU_PATTERN_LOAD_SONG,
  120. SUBMENU_PATTERN_SAVE_SONG,
  121. SUBMENU_PATTERN_SETTINGS,
  122. SUBMENU_PATTERN_HELP,
  123. SUBMENU_PATTERN_EXIT,
  124. } PatternSubmenuParams;
  125. typedef enum {
  126. SUBMENU_PATTERN_COPYPASTE_COPY,
  127. SUBMENU_PATTERN_COPYPASTE_PASTE,
  128. SUBMENU_PATTERN_COPYPASTE_CUT,
  129. SUBMENU_PATTERN_COPYPASTE_CLEAR,
  130. } PatternCopypasteSubmenuParams;
  131. typedef enum {
  132. SUBMENU_INSTRUMENT_LOAD,
  133. SUBMENU_INSTRUMENT_SAVE,
  134. SUBMENU_INSTRUMENT_EXIT,
  135. } InstrumentSubmenuParams;
  136. typedef struct {
  137. NotificationApp* notification;
  138. FuriMessageQueue* event_queue;
  139. Gui* gui;
  140. TrackerView* tracker_view;
  141. ViewDispatcher* view_dispatcher;
  142. TextInput* text_input;
  143. Storage* storage;
  144. Stream* stream;
  145. FuriString* filepath;
  146. DialogsApp* dialogs;
  147. Submenu* pattern_submenu;
  148. Submenu* pattern_copypaste_submenu;
  149. Submenu* instrument_submenu;
  150. VariableItemList* settings_list;
  151. Widget* overwrite_file_widget;
  152. Widget* overwrite_instrument_file_widget;
  153. char filename[FILE_NAME_LEN + 1];
  154. bool was_it_back_keypress;
  155. uint32_t current_time;
  156. uint32_t period;
  157. bool external_audio;
  158. SoundEngine sound_engine;
  159. TrackerEngine tracker_engine;
  160. TrackerSong song;
  161. uint8_t selected_param;
  162. uint8_t mode, focus;
  163. uint8_t patternx, current_channel, current_digit, program_position, current_program_step,
  164. current_instrument, current_note, current_volume;
  165. uint8_t inst_editor_shift;
  166. int16_t source_pattern_index;
  167. bool editing;
  168. bool was_editing;
  169. bool is_loading;
  170. bool is_saving;
  171. bool is_loading_instrument;
  172. bool is_saving_instrument;
  173. bool showing_help;
  174. bool cut_pattern; //if we need to clear the pattern we pasted from
  175. bool quit;
  176. char eq[2];
  177. char param[80];
  178. char value[10];
  179. } FlizzerTrackerApp;
  180. typedef struct {
  181. FlizzerTrackerApp* tracker;
  182. } TrackerViewModel;
  183. void draw_callback(Canvas* canvas, void* ctx);
  184. bool input_callback(InputEvent* input_event, void* ctx);