initial commit
[goodguy/cinelerra.git] / cinelerra-5.1 / plugins / resamplert / resamplert.h
1
2 /*
3  * CINELERRA
4  * Copyright (C) 2010 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 RESAMPLERT_H
23 #define RESAMPLERT_H
24
25
26 #include "guicast.h"
27 #include "pluginaclient.h"
28 #include "resample.h"
29
30
31
32 class ResampleRT;
33 class ResampleRTWindow;
34
35 class ResampleRTConfig
36 {
37 public:
38         ResampleRTConfig();
39         void boundaries();
40         int equivalent(ResampleRTConfig &src);
41         void copy_from(ResampleRTConfig &src);
42         void interpolate(ResampleRTConfig &prev,
43                 ResampleRTConfig &next,
44                 int64_t prev_frame,
45                 int64_t next_frame,
46                 int64_t current_frame);
47 // was scale
48         double num;
49         double denom;
50 };
51
52
53 class ResampleRTNum : public BC_TumbleTextBox
54 {
55 public:
56         ResampleRTNum(ResampleRTWindow *window,
57                 ResampleRT *plugin,
58                 int x,
59                 int y);
60         int handle_event();
61         ResampleRT *plugin;
62 };
63
64 class ResampleRTDenom : public BC_TumbleTextBox
65 {
66 public:
67         ResampleRTDenom(ResampleRTWindow *window,
68                 ResampleRT *plugin,
69                 int x,
70                 int y);
71         int handle_event();
72         ResampleRT *plugin;
73 };
74
75 class ResampleRTWindow : public PluginClientWindow
76 {
77 public:
78         ResampleRTWindow(ResampleRT *plugin);
79         ~ResampleRTWindow();
80         void create_objects();
81
82         ResampleRT *plugin;
83         ResampleRTNum *num;
84         ResampleRTDenom *denom;
85 };
86
87
88 class ResampleRTResample : public Resample
89 {
90 public:
91         ResampleRTResample(ResampleRT *plugin);
92         int read_samples(Samples *buffer, int64_t start, int64_t len);
93         ResampleRT *plugin;
94 };
95
96
97
98 class ResampleRT : public PluginAClient
99 {
100 public:
101         ResampleRT(PluginServer *server);
102         ~ResampleRT();
103
104         PLUGIN_CLASS_MEMBERS(ResampleRTConfig)
105
106         void save_data(KeyFrame *keyframe);
107         void read_data(KeyFrame *keyframe);
108         void update_gui();
109         int is_realtime();
110         int is_synthesis();
111         int process_buffer(int64_t size,
112                 Samples *buffer,
113                 int64_t start_position,
114                 int sample_rate);
115         void render_stop();
116
117 // Start of current resample region in input sample rate
118         int64_t source_start;
119 // Start of playback in output sample rate.
120         int64_t dest_start;
121 // End of playback in output sample rate
122         int64_t dest_end;
123         int need_reconfigure;
124         int prev_scale;
125         ResampleRTResample *resample;
126 };
127
128
129 #endif
130