flizzer_tracker.h 4.8 KB

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