remove whitespace at eol
[goodguy/history.git] / cinelerra-5.1 / plugins / vocoder / vocoder.h
1
2 /*
3  * CINELERRA
4  * Copyright (C) 1997-2011 Adam Williams <broadcast at earthling dot net>
5  *
6  * This program is free software; you can redistribute it and/or modify
7  * it under the terms of the GNU General Public License as published by
8  * the Free Software Foundation; either version 2 of the License, or
9  * (at your option) any later version.
10  *
11  * This program is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14  * GNU General Public License for more details.
15  *
16  * You should have received a copy of the GNU General Public License
17  * along with this program; if not, write to the Free Software
18  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
19  *
20  */
21
22 // Originally from the following:
23 /* vocoder.c
24    Version 0.3
25
26    LADSPA Unique ID: 1441
27
28    Version 0.3
29    Added support for changing bands in real time 2003-12-09
30
31    Version 0.2
32    Adapted to LADSPA by Josh Green <jgreen@users.sourceforge.net>
33    15.6.2001 (for the LinuxTag 2001!)
34
35    Original program can be found at:
36    http://www.sirlab.de/linux/
37    Author: Achim Settelmeier <settel-linux@sirlab.de>
38 */
39
40 #ifndef VOCODER_H
41 #define VOCODER_H
42
43
44 #include "bchash.inc"
45 #include "guicast.h"
46 #include "mutex.h"
47 #include "fourier.h"
48 #include "pluginaclient.h"
49 #include "vframe.inc"
50
51
52
53 #define MAX_BANDS 32
54
55 class Vocoder;
56 class VocoderWindow;
57
58
59
60
61
62
63 class VocoderConfig
64 {
65 public:
66         VocoderConfig();
67
68         int equivalent(VocoderConfig &that);
69         void copy_from(VocoderConfig &that);
70         void interpolate(VocoderConfig &prev,
71                 VocoderConfig &next,
72                 int64_t prev_frame,
73                 int64_t next_frame,
74                 int64_t current_frame);
75
76         int carrier_track;
77         int bands;
78         double level;
79         double wetness;
80 };
81
82
83
84
85
86
87 class VocoderWetness : public BC_FPot
88 {
89 public:
90         VocoderWetness(Vocoder *plugin, int x, int y);
91         int handle_event();
92         Vocoder *plugin;
93 };
94
95
96
97
98 class VocoderLevel : public BC_FPot
99 {
100 public:
101         VocoderLevel(Vocoder *plugin, int x, int y);
102         int handle_event();
103         Vocoder *plugin;
104 };
105
106
107
108
109 class VocoderCarrier : public BC_TumbleTextBox
110 {
111 public:
112         VocoderCarrier(Vocoder *plugin,
113                 VocoderWindow *window,
114                 int x,
115                 int y);
116         int handle_event();
117         Vocoder *plugin;
118 };
119
120
121 class VocoderBands : public BC_TumbleTextBox
122 {
123 public:
124         VocoderBands(Vocoder *plugin,
125                 VocoderWindow *window,
126                 int x,
127                 int y);
128         int handle_event();
129         Vocoder *plugin;
130 };
131
132
133
134
135
136 class VocoderWindow : public PluginClientWindow
137 {
138 public:
139         VocoderWindow(Vocoder *plugin);
140         ~VocoderWindow();
141
142         void create_objects();
143         void update_gui();
144
145         VocoderCarrier  *output;
146         VocoderBands *bands;
147         VocoderWetness *wetness;
148         VocoderLevel *level;
149         Vocoder *plugin;
150 };
151
152 class VocoderBand
153 {
154 public:
155         VocoderBand();
156         void reset();
157         void copy_from(VocoderBand *src);
158
159         double c, f, att;
160
161         double freq;
162         double low1, low2;
163         double mid1, mid2;
164         double high1, high2;
165         double y;
166 };
167
168 class VocoderOut
169 {
170 public:
171         VocoderOut();
172         void reset();
173
174         double decay;
175         double oldval;
176         double level;           /* 0.0 - 1.0 level of this output band */
177 };
178
179 class Vocoder : public PluginAClient
180 {
181 public:
182         Vocoder(PluginServer *server);
183         ~Vocoder();
184
185         int is_realtime();
186         int is_multichannel();
187         void read_data(KeyFrame *keyframe);
188         void save_data(KeyFrame *keyframe);
189         int process_buffer(int64_t size,
190                 Samples **buffer,
191                 int64_t start_position,
192                 int sample_rate);
193
194         void reset();
195         void reconfigure();
196         void update_gui();
197
198         void do_bandpasses(VocoderBand *bands, double sample);
199         VocoderBand formant_bands[MAX_BANDS];
200         VocoderBand carrier_bands[MAX_BANDS];
201         VocoderOut output_bands[MAX_BANDS];
202         int current_bands;
203
204         int need_reconfigure;
205         PLUGIN_CLASS_MEMBERS2(VocoderConfig)
206
207 };
208
209
210
211 #endif