SpectMorph
smmorphlfomodule.hh
1 // Licensed GNU LGPL v2.1 or later: http://www.gnu.org/licenses/lgpl-2.1.html
2 
3 #ifndef SPECTMORPH_MORPH_LFO_MODULE_HH
4 #define SPECTMORPH_MORPH_LFO_MODULE_HH
5 
6 #include "smmorphoperatormodule.hh"
7 #include "smmorphlfo.hh"
8 #include "smwavset.hh"
9 
10 namespace SpectMorph
11 {
12 
14 {
15  const MorphLFO::Config *cfg = nullptr;
16 
17  struct LFOState
18  {
19  double phase = 0;
20  double raw_phase = 0;
21  double last_random_value = 0;
22  double random_value = 0;
23  double value = 0;
24  double ppq_count = 0;
25  double last_ppq_pos = 0;
26  double last_time_ms = 0;
27  } local_lfo_state;
28 
29  struct SharedState : public MorphModuleSharedState
30  {
31  bool initialized = false;
32  LFOState global_lfo_state;
33  };
34  SharedState *shared_state = nullptr;
35  MorphModuleSharedState *create_shared_state() override;
36  void set_shared_state (MorphModuleSharedState *new_shared_state) override;
37 
38  void update_lfo_value (LFOState& state, const TimeInfo& time_info);
39  void restart_lfo (LFOState& state, const TimeInfo& time_info);
40 public:
42  ~MorphLFOModule();
43 
44  void set_config (const MorphOperatorConfig *cfg) override;
45  float value() override;
46  void reset_value (const TimeInfo& time_info) override;
47  void update_shared_state (const TimeInfo& time_info) override;
48 };
49 }
50 
51 #endif
Definition: smmorphlfomodule.hh:14
Definition: smmorphoperatormodule.hh:20
Definition: smmorphoperatormodule.hh:27
Definition: smmorphplanvoice.hh:16
Definition: smtimeinfo.hh:11
Definition: smmorphlfo.hh:56
Definition: smmorphoperator.hh:18