flizzer_tracker.h 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204
  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. EventTypeLoadSong,
  28. } EventType;
  29. typedef struct
  30. {
  31. EventType type;
  32. InputEvent input;
  33. uint32_t period;
  34. } FlizzerTrackerEvent;
  35. typedef enum
  36. {
  37. PATTERN_VIEW,
  38. INST_EDITOR_VIEW,
  39. EXPORT_WAV_VIEW,
  40. } TrackerMode;
  41. typedef enum
  42. {
  43. EDIT_PATTERN,
  44. EDIT_SEQUENCE,
  45. EDIT_SONGINFO,
  46. EDIT_INSTRUMENT,
  47. EDIT_PROGRAM,
  48. } TrackerFocus;
  49. typedef enum
  50. {
  51. SI_PATTERNPOS,
  52. SI_SEQUENCEPOS,
  53. SI_SONGSPEED,
  54. SI_SONGRATE,
  55. SI_MASTERVOL,
  56. SI_SONGNAME,
  57. SI_CURRENTINSTRUMENT,
  58. SI_INSTRUMENTNAME,
  59. /* ======== */
  60. SI_PARAMS,
  61. } SongInfoParam;
  62. typedef enum
  63. {
  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. {
  108. View *view;
  109. void *context;
  110. } TrackerView;
  111. typedef enum
  112. {
  113. VIEW_TRACKER,
  114. VIEW_KEYBOARD,
  115. VIEW_SUBMENU_PATTERN,
  116. VIEW_SUBMENU_INSTRUMENT,
  117. VIEW_FILE_OVERWRITE,
  118. } FlizzerTrackerViews;
  119. typedef enum
  120. {
  121. SUBMENU_PATTERN_RETURN,
  122. SUBMENU_PATTERN_LOAD_SONG,
  123. SUBMENU_PATTERN_SAVE_SONG,
  124. SUBMENU_PATTERN_EXIT,
  125. } PatternSubmenuParams;
  126. typedef enum
  127. {
  128. SUBMENU_INSTRUMENT_RETURN,
  129. SUBMENU_INSTRUMENT_EXIT,
  130. } InstrumentSubmenuParams;
  131. typedef struct
  132. {
  133. NotificationApp *notification;
  134. FuriMessageQueue *event_queue;
  135. Gui *gui;
  136. TrackerView *tracker_view;
  137. ViewDispatcher *view_dispatcher;
  138. TextInput *text_input;
  139. Storage* storage;
  140. Stream *stream;
  141. FuriString* filepath;
  142. DialogsApp *dialogs;
  143. Submenu *pattern_submenu;
  144. Submenu *instrument_submenu;
  145. Widget* overwrite_file_widget;
  146. char filename[FILE_NAME_LEN + 1];
  147. bool was_it_back_keypress;
  148. uint32_t current_time;
  149. uint32_t period;
  150. SoundEngine sound_engine;
  151. TrackerEngine tracker_engine;
  152. TrackerSong song;
  153. uint8_t selected_param;
  154. uint8_t mode, focus;
  155. uint8_t patternx, current_channel, current_digit, program_position, current_program_step, current_instrument, current_note;
  156. uint8_t inst_editor_shift;
  157. bool editing;
  158. bool was_editing;
  159. bool is_loading;
  160. bool is_saving;
  161. bool quit;
  162. } FlizzerTrackerApp;
  163. typedef struct
  164. {
  165. FlizzerTrackerApp *tracker;
  166. } TrackerViewModel;
  167. void draw_callback(Canvas *canvas, void *ctx);
  168. bool input_callback(InputEvent *input_event, void *ctx);