fix for vframe get_temp blunder, vicon zoom tweak
[goodguy/cinelerra.git] / cinelerra-5.1 / cinelerra / virtualnode.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 VIRTUALNODE_H
23 #define VIRTUALNODE_H
24
25 #include "arraylist.h"
26 #include "auto.inc"
27 #include "autos.inc"
28 #include "floatauto.inc"
29 #include "floatautos.inc"
30 #include "mwindow.inc"
31 #include "maxbuffers.h"
32 #include "patch.h"
33 #include "plugin.inc"
34 #include "pluginserver.inc"
35 #include "renderengine.inc"
36 #include "track.inc"
37 #include "transition.inc"
38 #include "virtualconsole.inc"
39
40 // The virtual node makes up the virtual console.
41 // It can be either a virtual module or a virtual plugin.
42
43
44 class VirtualNode
45 {
46 public:
47         VirtualNode(RenderEngine *renderengine,
48                 VirtualConsole *vconsole,
49                 Module *real_module,
50                 Plugin *real_plugin,
51                 Track *track,
52                 VirtualNode *parent_node);
53
54         friend class VirtualConsole;
55
56         virtual ~VirtualNode();
57         void dump(int indent);
58
59
60 // expand plugins
61         int expand(int persistent_plugins, int64_t current_position);
62 // create convenience pointers to shared memory depending on the data type
63         virtual int create_buffer_ptrs() { return 0; }
64 // create a node for a module and expand it
65         int attach_virtual_module(Plugin *plugin,
66                 int plugin_number,
67                 int duplicate,
68                 int64_t current_position);
69 // create a node for a plugin and expand it
70         int attach_virtual_plugin(Plugin *plugin,
71                 int plugin_number,
72                 int duplicate,
73                 int64_t current_position);
74         virtual VirtualNode* create_module(Plugin *real_plugin,
75                                                         Module *real_module,
76                                                         Track *track) { return 0; };
77         virtual VirtualNode* create_plugin(Plugin *real_plugin) { return 0; };
78
79
80 // Called by read_data to get the previous plugin in a parent node's subnode
81 // table.
82         VirtualNode* get_previous_plugin(VirtualNode *current_plugin);
83
84 // subnodes this node owns
85 // was vplugins
86         ArrayList<VirtualNode*> subnodes;
87 // Attachment point in Module if this is a virtual plugin
88         AttachmentPoint *attachment;
89
90         VirtualConsole *vconsole;
91 // node which created this node.
92         VirtualNode *parent_node;
93 // use these to determine if this node is a plugin or module
94 // Top level virtual node of module
95         Module *real_module;
96 // When this node is a plugin.  Redirected to the shared plugin in expansion.
97         Plugin *real_plugin;
98
99
100         Track *track;
101         RenderEngine *renderengine;
102
103 // for rendering need to know if the buffer is a master or copy
104 // These are set in expand()
105         int input_is_master;
106         int output_is_master;
107         int ring_buffers;       // number of buffers for master buffers
108         int64_t buffer_size;         // number of units in a master segment
109         int64_t fragment_size;       // number of units in a node segment
110         int plugin_type;          // type of plugin in case user changes it
111         int render_count;         // times this plugin has been added to the render list
112         int waiting_real_plugin;  //  real plugin tests this to see if virtual plugin is waiting on it when sorting
113 // attachment point needs to know what buffer to put data into from
114 // a multichannel plugin
115         int plugin_buffer_number;
116
117 // Mute automation.
118 // Return whether the next samples are muted and store the duration
119 // of the next status in fragment_len
120         void get_mute_fragment(int64_t input_position,
121                                 int &mute_constant,
122                                 int &fragment_len,
123                                 Autos *autos,
124                                 int direction,
125                                 int use_nudge);
126
127 // convenience routines for fade automation
128 /*
129  *      void get_fade_automation(double &slope,
130  *              double &intercept,
131  *              int64_t input_position,
132  *              int64_t &slope_len,
133  *              Autos *autos);
134  *
135  *      int init_automation(int &automate,
136  *                              double &constant,
137  *                              int64_t input_position,
138  *                              int64_t buffer_len,
139  *                              Autos *autos,
140  *                              Auto **before,
141  *                              Auto **after);
142  *
143  *      int init_slope(Autos *autos, Auto **before, Auto **after);
144  *      int get_slope(Autos *autos, int64_t buffer_len, int64_t buffer_position);
145  *      int advance_slope(Autos *autos);
146  */
147
148 protected:
149
150 // ======================= plugin automation
151         FloatAutos *plugin_autos;
152         FloatAuto *plugin_auto_before, *plugin_auto_after;
153
154 // temporary variables for automation
155         Auto *current_auto;
156         double slope_value;
157         double slope_start;
158         double slope_end;
159         double slope_position;
160         double slope;
161         double value;
162
163
164 private:
165         int sort_as_module(ArrayList<VirtualNode*>*render_list, int &result, int &total_result);
166         int sort_as_plugin(ArrayList<VirtualNode*>*render_list, int &result, int &total_result);
167         int expand_as_module(int duplicate, int64_t current_position);
168         int expand_as_plugin(int duplicate);
169         int is_exit;
170 };
171
172
173
174 #endif