1 /*
2  * ZamNoise  Noise detection and removal plugin
3  * Copyright (C) 2014  Damien Zammit <damien@zamaudio.com>
4  *
5  * This program is free software; you can redistribute it and/or
6  * modify it under the terms of the GNU General Public License as
7  * published by the Free Software Foundation; either version 2 of
8  * the License, or (at your option) any later version.
9  *
10  * This program is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13  * GNU General Public License for more details.
14  *
15  * For a full copy of the GNU General Public License see the doc/GPL.txt file.
16  */
17 
18 #ifndef ZAMNOISEPLUGIN_HPP_INCLUDED
19 #define ZAMNOISEPLUGIN_HPP_INCLUDED
20 
21 #include "DistrhoPlugin.hpp"
22 #include "Denoise.hpp"
23 
24 typedef struct {
25 	unsigned long cbsize; // size of circular buffer
26 	float* cbi;
27 } CircularBuffer;
28 
29 
30 START_NAMESPACE_DISTRHO
31 
32 // -----------------------------------------------------------------------
33 
34 class ZamNoisePlugin : public Plugin
35 {
36 public:
37     enum Parameters
38     {
39         paramNoiseToggle,
40         paramCount
41     };
42 
43     ZamNoisePlugin();
44     ~ZamNoisePlugin() override;
45 
46 protected:
47     // -------------------------------------------------------------------
48     // Information
49 
getLabel() const50     const char* getLabel() const noexcept override
51     {
52         return "ZamNoise";
53     }
54 
getDescription() const55     const char* getDescription() const noexcept override
56     {
57         return "";
58     }
59 
getMaker() const60     const char* getMaker() const noexcept override
61     {
62         return "Damien Zammit";
63     }
64 
getHomePage() const65     const char* getHomePage() const noexcept override
66     {
67         return "http://www.zamaudio.com";
68     }
69 
getLicense() const70     const char* getLicense() const noexcept override
71     {
72         return "GPL v2+";
73     }
74 
getVersion() const75     uint32_t getVersion() const noexcept override
76     {
77         return d_version(3, 8, 0);
78     }
79 
getUniqueId() const80     int64_t getUniqueId() const noexcept override
81     {
82         return d_cconst('Z', 'N', 'O', 'I');
83     }
84 
85     // -------------------------------------------------------------------
86     // Init
87 
88     void initParameter(uint32_t index, Parameter& parameter) override;
89     void initProgramName(uint32_t index, String& programName) override;
90 
91     // -------------------------------------------------------------------
92     // Internal data
93 
94     float getParameterValue(uint32_t index) const override;
95     void  setParameterValue(uint32_t index, float value) override;
96     void  loadProgram(uint32_t index) override;
97 
98     // -------------------------------------------------------------------
99     void activate() override;
100     void deactivate() override;
101     void run(const float** inputs, float** outputs, uint32_t frames) override;
102 
103     // -------------------------------------------------------------------
104 	float noisetoggle;
105 
106 	void InstantiateCircularBuffer(CircularBuffer* buffer, unsigned long SampleRate);
107 	inline void IncrementPointer(CircularBuffer& buffer);
108 	void init(float srate);
109 	int noverlap;
110 	CircularBuffer buffer;
111 	Denoise* zamnoise;
112 };
113 
114 // -----------------------------------------------------------------------
115 
116 END_NAMESPACE_DISTRHO
117 
118 #endif  // ZAMNOISE_HPP_INCLUDED
119