rework canvas zoom, add 3 plugins from 7.2, tweak cwdw boundry, vdevicex11 dupl close...
[goodguy/cinelerra.git] / cinelerra-5.1 / plugins / flanger / flanger.h
1
2 /*
3  * CINELERRA
4  * Copyright (C) 2008-2019 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 #ifndef FLANGER_H
23 #define FLANGER_H
24
25 class Flanger;
26
27 #include "pluginaclient.h"
28
29
30 class FlangerConfig
31 {
32 public:
33         FlangerConfig();
34
35
36         int equivalent(FlangerConfig &that);
37         void copy_from(FlangerConfig &that);
38         void interpolate(FlangerConfig &prev, 
39                 FlangerConfig &next, 
40                 int64_t prev_frame, 
41                 int64_t next_frame, 
42                 int64_t current_frame);
43         void boundaries();
44
45 // phase offset in ms
46         float offset;
47 // starting position of oscillation in %
48         float starting_phase;
49 // how much the phase oscillates in ms
50         float depth;
51 // rate of phase oscillation in Hz
52         float rate;
53 // how much of input signal
54         float wetness;
55 };
56
57
58 // state of a single voice
59 class Voice
60 {
61 public:
62     Voice();
63
64 // position in the waveform table
65     int table_offset;
66 };
67
68 // each sample in the flanging waveform
69 typedef struct 
70 {
71     double input_sample;
72     double input_period;
73 } flange_sample_t;
74
75 class Flanger : public PluginAClient
76 {
77 public:
78         Flanger(PluginServer *server);
79         ~Flanger();
80
81         void update_gui();
82
83
84
85 // required for all realtime/multichannel plugins
86         PLUGIN_CLASS_MEMBERS(FlangerConfig);
87     int process_buffer(int64_t size, 
88             Samples *buffer, 
89             int64_t start_position,
90             int sample_rate);
91     void reallocate_dsp(int new_dsp_allocated);
92     void reallocate_history(int new_allocation);
93
94         int is_realtime();
95         int is_synthesis();
96         int is_multichannel();
97         void save_data(KeyFrame *keyframe);
98         void read_data(KeyFrame *keyframe);
99
100         double *history_buffer;
101 // Number of samples in the history buffer 
102         int64_t history_size;
103
104 // the temporary all voices are painted on
105         double *dsp_in;
106     int dsp_in_allocated;
107
108     Voice voice;
109 // flanging table is a whole number of samples that repeats
110 // always an even number
111     int table_size;
112     flange_sample_t *flanging_table;
113
114 // detect seeking
115     int64_t last_position;
116
117         int need_reconfigure;
118 };
119
120
121
122
123
124 class FlangerWindow : public PluginClientWindow
125 {
126 public:
127         FlangerWindow(Flanger *plugin);
128         ~FlangerWindow();
129         
130         void create_objects();
131     void update();
132     void param_updated();
133
134         Flanger *plugin;
135     PluginParam *offset;
136     PluginParam *starting_phase;
137     PluginParam *depth;
138     PluginParam *rate;
139     PluginParam *wetness;
140 };
141
142
143
144
145 #endif
146
147
148