flizzer_tracker.h 3.9 KB

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