initial commit
[goodguy/cinelerra.git] / cinelerra-5.1 / plugins / pitch / pitch.h
1
2 /*
3  * CINELERRA
4  * Copyright (C) 2008 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 PITCH_H
23 #define PITCH_H
24
25
26
27 #include "bchash.inc"
28 #include "fourier.h"
29 #include "guicast.h"
30 #include "mutex.h"
31 #include "pluginaclient.h"
32 #include "vframe.inc"
33
34
35 class PitchEffect;
36 class PitchWindow;
37
38 class PitchScale : public BC_FPot
39 {
40 public:
41         PitchScale(PitchEffect *plugin, int x, int y);
42         int handle_event();
43         PitchEffect *plugin;
44 };
45
46
47 class PitchSize : public BC_PopupMenu
48 {
49 public:
50         PitchSize(PitchWindow *window, PitchEffect *plugin, int x, int y);
51
52         int handle_event();
53         void create_objects();         // add initial items
54         void update(int size);
55
56         PitchEffect *plugin;
57 };
58
59 class PitchWindow : public PluginClientWindow
60 {
61 public:
62         PitchWindow(PitchEffect *plugin);
63         void create_objects();
64         void update();
65
66         PitchScale *scale;
67         PitchSize *size;
68         PitchEffect *plugin;
69 };
70
71
72
73
74 class PitchConfig
75 {
76 public:
77         PitchConfig();
78
79
80         int equivalent(PitchConfig &that);
81         void copy_from(PitchConfig &that);
82         void interpolate(PitchConfig &prev,
83                 PitchConfig &next,
84                 int64_t prev_frame,
85                 int64_t next_frame,
86                 int64_t current_frame);
87
88
89         double scale;
90         int size;
91 };
92
93 class PitchFFT : public CrossfadeFFT
94 {
95 public:
96         PitchFFT(PitchEffect *plugin);
97         ~PitchFFT();
98         int signal_process();
99         int read_samples(int64_t output_sample,
100                 int samples,
101                 Samples *buffer);
102         PitchEffect *plugin;
103         double *last_phase;
104         double *new_freq;
105         double *new_magn;
106         double *sum_phase;
107         double *anal_freq;
108         double *anal_magn;
109 };
110
111 class PitchEffect : public PluginAClient
112 {
113 public:
114         PitchEffect(PluginServer *server);
115         ~PitchEffect();
116
117         PLUGIN_CLASS_MEMBERS(PitchConfig);
118
119         int is_realtime();
120         void read_data(KeyFrame *keyframe);
121         void save_data(KeyFrame *keyframe);
122         int process_buffer(int64_t size,
123                 Samples *buffer,
124                 int64_t start_position,
125                 int sample_rate);
126
127
128
129
130         void reset();
131         void update_gui();
132
133
134         PitchFFT *fft;
135 };
136
137
138 #endif