SpectMorph
smmorphoutput.hh
1 // Licensed GNU LGPL v2.1 or later: http://www.gnu.org/licenses/lgpl-2.1.html
2 
3 #ifndef SPECTMORPH_MORPH_OUTPUT_HH
4 #define SPECTMORPH_MORPH_OUTPUT_HH
5 
6 #include "smmorphoperator.hh"
7 #include "smutils.hh"
8 #include "smmath.hh"
9 #include "smproperty.hh"
10 #include "smmodulationlist.hh"
11 
12 #include <string>
13 
14 namespace SpectMorph
15 {
16 
17 class MorphOutput;
18 
19 class MorphOutput : public MorphOperator
20 {
21 public:
22  enum FilterType {
23  FILTER_TYPE_LADDER = 1,
24  FILTER_TYPE_SALLEN_KEY = 2
25  };
26  enum FilterLadderMode {
27  FILTER_LADDER_LP1 = 1,
28  FILTER_LADDER_LP2 = 2,
29  FILTER_LADDER_LP3 = 3,
30  FILTER_LADDER_LP4 = 4,
31  };
32  enum FilterSKMode {
33  FILTER_SK_LP1 = 1,
34  FILTER_SK_LP2 = 2,
35  FILTER_SK_LP3 = 3,
36  FILTER_SK_LP4 = 4,
37  FILTER_SK_LP6 = 5,
38  FILTER_SK_LP8 = 6,
39 
40  FILTER_SK_BP2 = 7,
41  FILTER_SK_BP4 = 8,
42  FILTER_SK_BP6 = 9,
43  FILTER_SK_BP8 = 10,
44 
45  FILTER_SK_HP1 = 11,
46  FILTER_SK_HP2 = 12,
47  FILTER_SK_HP3 = 13,
48  FILTER_SK_HP4 = 14,
49  FILTER_SK_HP6 = 15,
50  FILTER_SK_HP8 = 16,
51  };
52  struct Config : public MorphOperatorConfig
53  {
54  std::vector<MorphOperatorPtr> channel_ops;
55 
56  float velocity_sensitivity;
57  int pitch_bend_range;
58 
59  bool sines;
60  bool noise;
61 
62  bool unison;
63  int unison_voices;
64  float unison_detune;
65 
66  bool adsr;
67  float adsr_skip;
68  float adsr_attack;
69  float adsr_decay;
70  float adsr_sustain;
71  float adsr_release;
72 
73  bool filter;
74  FilterType filter_type;
75  FilterLadderMode filter_ladder_mode;
76  FilterSKMode filter_sk_mode;
77  float filter_attack;
78  float filter_decay;
79  float filter_sustain;
80  float filter_release;
81  float filter_depth;
82  float filter_key_tracking;
83  ModulationData filter_cutoff_mod;
84  ModulationData filter_resonance_mod;
85  ModulationData filter_drive_mod;
86 
87  bool portamento;
88  float portamento_glide;
89 
90  bool vibrato;
91  float vibrato_depth;
92  float vibrato_frequency;
93  float vibrato_attack;
94  };
95  Config m_config;
96 
97  static constexpr auto P_VELOCITY_SENSITIVITY = "velocity_sensitivity";
98  static constexpr auto P_PITCH_BEND_RANGE = "pitch_bend_range";
99 
100  static constexpr auto P_SINES = "sines";
101  static constexpr auto P_NOISE = "noise";
102 
103  static constexpr auto P_UNISON = "unison";
104  static constexpr auto P_UNISON_VOICES = "unison_voices";
105  static constexpr auto P_UNISON_DETUNE = "unison_detune";
106 
107  static constexpr auto P_ADSR = "adsr";
108  static constexpr auto P_ADSR_SKIP = "adsr_skip";
109  static constexpr auto P_ADSR_ATTACK = "adsr_attack";
110  static constexpr auto P_ADSR_DECAY = "adsr_decay";
111  static constexpr auto P_ADSR_SUSTAIN = "adsr_sustain";
112  static constexpr auto P_ADSR_RELEASE = "adsr_release";
113 
114  static constexpr auto P_FILTER = "filter";
115  static constexpr auto P_FILTER_TYPE = "filter_type";
116  static constexpr auto P_FILTER_LADDER_MODE = "filter_ladder_mode";
117  static constexpr auto P_FILTER_SK_MODE = "filter_sk_mode";
118  static constexpr auto P_FILTER_ATTACK = "filter_attack";
119  static constexpr auto P_FILTER_DECAY = "filter_decay";
120  static constexpr auto P_FILTER_SUSTAIN = "filter_sustain";
121  static constexpr auto P_FILTER_RELEASE = "filter_release";
122  static constexpr auto P_FILTER_DEPTH = "filter_depth";
123  static constexpr auto P_FILTER_KEY_TRACKING = "filter_key_tracking";
124  static constexpr auto P_FILTER_CUTOFF = "filter_cutoff";
125  static constexpr auto P_FILTER_RESONANCE = "filter_resonance";
126  static constexpr auto P_FILTER_DRIVE = "filter_drive";
127 
128  static constexpr auto P_PORTAMENTO = "portamento";
129  static constexpr auto P_PORTAMENTO_GLIDE = "portamento_glide";
130 
131  static constexpr auto P_VIBRATO = "vibrato";
132  static constexpr auto P_VIBRATO_DEPTH = "vibrato_depth";
133  static constexpr auto P_VIBRATO_FREQUENCY = "vibrato_frequency";
134  static constexpr auto P_VIBRATO_ATTACK = "vibrato_attack";
135 
136 protected:
137  std::vector<std::string> load_channel_op_names;
138 
139 public:
140  MorphOutput (MorphPlan *morph_plan);
141  ~MorphOutput();
142 
143  // inherited from MorphOperator
144  const char *type() override;
145  int insert_order() override;
146  bool save (OutFile& out_file) override;
147  bool load (InFile& in_file) override;
148  void post_load (OpNameMap& op_name_map) override;
149  OutputType output_type() override;
150 
151  std::vector<MorphOperator *> dependencies() override;
152  MorphOperatorConfig *clone_config() override;
153 
154  void set_channel_op (int ch, MorphOperator *op);
155  MorphOperator *channel_op (int ch);
156 
157 /* slots: */
158  void on_operator_removed (MorphOperator *op);
159 };
160 
161 }
162 
163 #endif
Class to read SpectMorph binary data.
Definition: sminfile.hh:27
Definition: smmodulationlist.hh:17
Definition: smmorphoperator.hh:27
Definition: smmorphoutput.hh:20
Definition: smmorphplan.hh:18
Definition: smoutfile.hh:19
Definition: smmorphoperator.hh:18
Definition: smmorphoutput.hh:53