add auto zoombar/status color, fix 3 batchrender boobies, rotate plugin tweaks, add...
[goodguy/cinelerra.git] / cinelerra-5.1 / plugins / piano / piano.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 PIANO_H
23 #define PIANO_H
24
25
26
27 #include "filexml.inc"
28 #include "guicast.h"
29 #include "mutex.h"
30 #include "pluginaclient.h"
31 #include "vframe.inc"
32
33
34 class Piano;
35 class PianoWindow;
36
37
38 class PianoCanvas;
39 class PianoWaveForm;
40 class PianoBaseFreq;
41 class PianoFreqPot;
42 class PianoOscGUI;
43 class PianoScroll;
44 class PianoSubWindow;
45 class PianoWetness;
46
47 class PianoWindow : public BC_Window
48 {
49 public:
50         PianoWindow(Piano *plugin, int x, int y);
51         ~PianoWindow();
52
53         void create_objects();
54         int close_event();
55         int resize_event(int w, int h);
56         void update_gui();
57         int waveform_to_text(char *text, int waveform);
58         void update_scrollbar();
59         void update_oscillators();
60
61
62         Piano *plugin;
63         PianoCanvas *canvas;
64 };
65
66
67 class PianoCanvas : public BC_SubWindow
68 {
69 public:
70         PianoCanvas(Piano *plugin,
71                 PianoWindow *window,
72                 int x,
73                 int y,
74                 int w,
75                 int h);
76         ~PianoCanvas();
77
78         int update();
79         Piano *plugin;
80         PianoWindow *window;
81 };
82
83
84 class PianoThread : public Thread
85 {
86 public:
87         PianoThread(Piano *synth);
88         ~PianoThread();
89
90         void run();
91
92         Mutex completion;
93         Piano *synth;
94         PianoWindow *window;
95 };
96
97
98
99 class PianoConfig
100 {
101 public:
102         PianoConfig();
103         ~PianoConfig();
104
105         int equivalent(PianoConfig &that);
106         void copy_from(PianoConfig &that);
107         void interpolate(PianoConfig &prev,
108                 PianoConfig &next,
109                 int64_t prev_frame,
110                 int64_t next_frame,
111                 int64_t current_frame);
112         void reset();
113
114 };
115
116
117 class Piano : public PluginAClient
118 {
119 public:
120         Piano(PluginServer *server);
121         ~Piano();
122
123
124
125         int is_realtime();
126         int is_synthesis();
127         int load_configuration();
128         const char* plugin_title();
129         void read_data(KeyFrame *keyframe);
130         void save_data(KeyFrame *keyframe);
131         int show_gui();
132         void raise_window();
133         int set_string();
134         int process_realtime(int64_t size, double *input_ptr, double *output_ptr);
135
136
137
138
139
140
141
142         void add_oscillator();
143         void delete_oscillator();
144         double get_total_power();
145         double get_oscillator_point(float x,
146                 double normalize_constant,
147                 int oscillator);
148         double solve_eqn(double *output,
149                 double x1,
150                 double x2,
151                 double normalize_constant,
152                 int oscillator);
153         double get_point(float x, double normalize_constant);
154         double function_square(double x);
155         double function_pulse(double x);
156         double function_noise();
157         double function_sawtooth(double x);
158         double function_triangle(double x);
159         void reconfigure();
160         int overlay_synth(int64_t start, int64_t length, double *input, double *output);
161         void update_gui();
162         void reset();
163
164
165
166         double *dsp_buffer;
167         int need_reconfigure;
168         PianoThread *thread;
169         PianoConfig config;
170         int w, h;
171         DB db;
172         int64_t waveform_length;           // length of loop buffer
173         int64_t waveform_sample;           // current sample in waveform of loop
174         int64_t samples_rendered;          // samples of the dsp_buffer rendered since last buffer redo
175         float period;            // number of samples in a period for this frequency
176 };
177
178
179
180
181
182
183
184
185 #endif