flizzer_tracker.h 4.0 KB

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