SpectMorph
smmorphgrid.hh
1 // Licensed GNU LGPL v2.1 or later: http://www.gnu.org/licenses/lgpl-2.1.html
2 
3 #ifndef SPECTMORPH_MORPH_GRID_HH
4 #define SPECTMORPH_MORPH_GRID_HH
5 
6 #include "smmorphoperator.hh"
7 #include "smmodulationlist.hh"
8 #include "smwavset.hh"
9 
10 #include <map>
11 
12 namespace SpectMorph
13 {
14 
16 {
17  MorphOperatorPtr op; // a node has either an operator (op) as input,
18  std::string smset; // or an instrument (smset)
19  WavSet *wav_set = nullptr;
20  double delta_db;
21 
22  MorphGridNode();
23 };
24 
25 class MorphGrid : public MorphOperator
26 {
27 public:
28  struct Config : public MorphOperatorConfig
29  {
30  int width;
31  int height;
32 
33  ModulationData x_morphing_mod;
34  ModulationData y_morphing_mod;
35 
36  std::vector< std::vector<MorphGridNode> > input_node;
37  };
38  static constexpr auto P_X_MORPHING = "x_morphing";
39  static constexpr auto P_Y_MORPHING = "y_morphing";
40 protected:
41  Config m_config;
42  int m_zoom;
43  int m_selected_x;
44  int m_selected_y;
45 
46  std::map<std::string, std::string> load_map;
47 
48  void update_size();
49 public:
50  MorphGrid (MorphPlan *morph_plan);
51  ~MorphGrid();
52 
53  // inherited from MorphOperator
54  const char *type() override;
55  int insert_order() override;
56  bool save (OutFile& out_file) override;
57  bool load (InFile& in_file) override;
58  void post_load (OpNameMap& op_name_map) override;
59  OutputType output_type() override;
60  MorphOperatorConfig *clone_config() override;
61 
62  std::vector<MorphOperator *> dependencies() override;
63 
64  void set_width (int width);
65  int width();
66 
67  void set_height (int height);
68  int height();
69 
70  void set_zoom (int new_zoom);
71  int zoom();
72 
73  void set_selected_x (int x);
74  void set_selected_y (int y);
75  int selected_x();
76  int selected_y();
77  bool has_selection();
78 
79  double x_morphing();
80  void set_x_morphing (double new_value);
81 
82  double y_morphing();
83  void set_y_morphing (double new_value);
84 
85  void set_input_node (int x, int y, const MorphGridNode& node);
86  MorphGridNode input_node (int x, int y);
87  std::string input_node_label (int x, int y);
88 
89 /* slots: */
90  void on_operator_removed (MorphOperator *op);
91 };
92 
93 }
94 
95 #endif
Class to read SpectMorph binary data.
Definition: sminfile.hh:27
Definition: smmodulationlist.hh:17
Definition: smmorphgrid.hh:26
Definition: smmorphoperator.hh:147
Definition: smmorphoperator.hh:27
Definition: smmorphplan.hh:18
Definition: smoutfile.hh:19
Definition: smwavset.hh:29
Definition: smmorphgrid.hh:16
Definition: smmorphgrid.hh:29
Definition: smmorphoperator.hh:18