1 /*
2 ** Surge Synthesizer is Free and Open Source Software
3 **
4 ** Surge is made available under the Gnu General Public License, v3.0
5 ** https://www.gnu.org/licenses/gpl-3.0.en.html
6 **
7 ** Copyright 2004-2020 by various individuals as described by the Git transaction log
8 **
9 ** All source at: https://github.com/surge-synthesizer/surge.git
10 **
11 ** Surge was a commercial product from 2004-2018, with Copyright and ownership
12 ** in that period held by Claes Johanson at Vember Audio. Claes made Surge
13 ** open source in September 2018.
14 */
15 
16 #pragma once
17 
18 #include "DspUtilities.h"
19 #include "SurgeStorage.h"
20 
21 /*	base class			*/
22 
23 class alignas(16) Effect
24 {
25   public:
26     enum
27     {
28         KNumVuSlots = 24
29     };
30 
31     Effect(SurgeStorage *storage, FxStorage *fxdata, pdata *pd);
~Effect()32     virtual ~Effect() { return; }
33 
get_effectname()34     virtual const char *get_effectname() { return 0; }
35 
init()36     virtual void init(){};
37     virtual void init_ctrltypes();
init_default_values()38     virtual void init_default_values(){};
39 
40     // No matter what path is used to reload (whether created anew or what not) this is called after
41     // the loading state of an item has changed
updateAfterReload()42     virtual void updateAfterReload(){};
vu_type(int id)43     virtual int vu_type(int id) { return 0; };
vu_ypos(int id)44     virtual int vu_ypos(int id) { return id; }; // in 'half-hslider' heights
group_label(int id)45     virtual const char *group_label(int id) { return 0; };
group_label_ypos(int id)46     virtual int group_label_ypos(int id) { return 0; };
get_ringout_decay()47     virtual int get_ringout_decay()
48     {
49         return -1;
50     } // number of blocks it takes for the effect to 'ring out'
51 
process(float * dataL,float * dataR)52     virtual void process(float *dataL, float *dataR) { return; }
process_only_control()53     virtual void process_only_control()
54     {
55         return;
56     } // for controllers that should run regardless of the audioprocess
57     virtual bool process_ringout(float *dataL, float *dataR,
58                                  bool indata_present = true); // returns rtue if outdata is present
59     // virtual void processSSE(float *dataL, float *dataR){ return; }
60     // virtual void processSSE2(float *dataL, float *dataR){ return; }
61     // virtual void processSSE3(float *dataL, float *dataR){ return; }
62     // virtual void processT<int architecture>(float *dataL, float *dataR){ return; }
suspend()63     virtual void suspend() { return; }
64     float vu[KNumVuSlots]; // stereo pairs, just use every other when mono
65 
handleStreamingMismatches(int streamingRevision,int currentSynthStreamingRevision)66     virtual void handleStreamingMismatches(int streamingRevision, int currentSynthStreamingRevision)
67     {
68         // No-op here.
69     }
70 
checkHasInvalidatedUI()71     inline bool checkHasInvalidatedUI()
72     {
73         auto x = hasInvalidated;
74         hasInvalidated = false;
75         return x;
76     }
77 
78   protected:
79     SurgeStorage *storage;
80     FxStorage *fxdata;
81     pdata *pd;
82     int ringout;
83     float *f[n_fx_params];
84     int *pdata_ival[n_fx_params]; // f is not a great choice for a member name, but 'i' woudl be
85                                   // worse!
86     bool hasInvalidated;
87 };
88 
89 // Some common constants
90 const int max_delay_length = 1 << 18;
91 const int slowrate = 8;
92 const int slowrate_m1 = slowrate - 1;
93 
94 Effect *spawn_effect(int id, SurgeStorage *storage, FxStorage *fxdata, pdata *pd);
95