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