1 /*
2  * Copyright (C) 2020 Linux Studio Plugins Project <https://lsp-plug.in/>
3  *           (C) 2020 Vladimir Sadovnikov <sadko4u@gmail.com>
4  *
5  * This file is part of lsp-plugins
6  * Created on: 11 янв. 2017 г.
7  *
8  * lsp-plugins is free software: you can redistribute it and/or modify
9  * it under the terms of the GNU Lesser General Public License as published by
10  * the Free Software Foundation, either version 3 of the License, or
11  * any later version.
12  *
13  * lsp-plugins is distributed in the hope that it will be useful,
14  * but WITHOUT ANY WARRANTY; without even the implied warranty of
15  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16  * GNU Lesser General Public License for more details.
17  *
18  * You should have received a copy of the GNU Lesser General Public License
19  * along with lsp-plugins. If not, see <https://www.gnu.org/licenses/>.
20  */
21 
22 #ifndef PLUGINS_EXPERIMENTAL_H_
23 #define PLUGINS_EXPERIMENTAL_H_
24 
25 #include <metadata/metadata.h>
26 #include <metadata/plugins.h>
27 
28 #include <core/plugin.h>
29 #include <core/filters/Filter.h>
30 #include <core/util/Counter.h>
31 
32 namespace lsp
33 {
34 #ifndef LSP_NO_EXPERIMENTAL
35     class test_plugin: public plugin_t, public test_plugin_metadata
36     {
37         protected:
38             typedef struct osc_t
39             {
40                 float       A0; // Initial amplitude
41                 float       X0; // Initial location
42                 float       W0; // Frequency
43                 float       P0; // Initial phase
44                 float       R0; // Reduction/Decay
45             } osc_t;
46 
47         protected:
48             IPort      *pIn[2];
49             IPort      *pOut[2];
50             IPort      *pMesh;
51             IPort      *pStream;
52             IPort      *pFB;
53             IPort      *pGain;
54             IPort      *pFileName;
55             IPort      *pHeadCut;
56             IPort      *pTailCut;
57             IPort      *pFadeIn;
58             IPort      *pFadeOut;
59             IPort      *pStatus;
60             IPort      *pLength;
61             IPort      *pData;
62 
63             IPort      *pOutFile;
64             IPort      *pOutCmd;
65             IPort      *pOutStatus;
66             IPort      *pOutProgress;
67 
68             float       fGain;
69             bool        bFileSet;
70             size_t      nPhase;
71             size_t      nColorID;
72             size_t      nStatus;
73             size_t      nProgCurr;
74             size_t      nProgLast;
75 
76             size_t      nOscPhase;
77             size_t      nOscLeft;
78             size_t      nRows;
79 
80             osc_t       vOsc[3];
81 
82             uint32_t    nLisCounter;        // Lissajous counter's max value
83             uint32_t    nLisPhase;          // Lissajous phase
84             uint32_t    nLisSteps;          // Lissajous phase step counter
85 
86             float       vBuffer[FRM_BUFFER_SIZE];
87             float       vLisX[LIS_BUFFER_SIZE];
88             float       vLisY[LIS_BUFFER_SIZE];
89             float       vLisS[LIS_BUFFER_SIZE];
90 
91         protected:
92             void        oscillate(float *dst, const osc_t *osc, float t, ssize_t n);
93 
94         public:
95             explicit test_plugin();
96             virtual ~test_plugin();
97 
98         public:
99             virtual void init(IWrapper *wrapper);
100 
101             virtual void process(size_t samples);
102 
103             virtual void update_settings();
104 
105             virtual bool inline_display(ICanvas *cv, size_t width, size_t height);
106     };
107 
108     class filter_analyzer:  public plugin_t, public filter_analyzer_metadata
109     {
110         protected:
111             typedef struct pfilter_t
112             {
113                 Filter              sFilter;
114                 filter_params_t     sFP;
115                 size_t              nOp;
116 
117                 IPort              *pType;
118                 IPort              *pSlope;
119                 IPort              *pOp;
120                 IPort              *pFreqLo;
121                 IPort              *pFreqHi;
122                 IPort              *pGain;
123                 IPort              *pQuality;
124             } pilter_;
125 
126         protected:
127             IPort      *pIn;
128             IPort      *pOut;
129             IPort      *pGraph;
130             pfilter_t   vFilters[2];
131             float       vChart[MESH_POINTS*2];
132             float       vTmpBuf[MESH_POINTS*2];
133 
134         public:
135             explicit filter_analyzer();
136             virtual ~filter_analyzer();
137 
138         public:
139             virtual void init(IWrapper *wrapper);
140 
141             virtual void process(size_t samples);
142 
143             virtual void update_settings();
144 
145             void set_sample_rate(long sr);
146     };
147 #endif
148 }
149 
150 #endif /* INCLUDE_PLUGINS_EXPERIMENTAL_H_ */
151