Merge CV, ver=5.1; ops/methods from HV, and interface from CV where possible
[goodguy/history.git] / cinelerra-5.1 / cinelerra / amodule.h
1
2 /*
3  * CINELERRA
4  * Copyright (C) 2008-2013 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 AMODULE_H
23 #define AMODULE_H
24
25 class AModuleGUI;
26 class AModuleTitle;
27 class AModulePan;
28 class AModuleFade;
29 class AModuleInv;
30 class AModuleMute;
31 class AModuleReset;
32
33 #include "aedit.inc"
34 #include "amodule.inc"
35 #include "aplugin.inc"
36 #include "asset.inc"
37 #include "datatype.h"
38 #include "edl.inc"
39 #include "file.inc"
40 #include "filexml.inc"
41 #include "floatautos.inc"
42 #include "maxchannels.h"
43 #include "module.h"
44 #include "resample.h"
45 #include "samples.inc"
46 #include "sharedlocation.inc"
47 #include "track.inc"
48 #include "units.h"
49
50 class AModuleResample : public Resample
51 {
52 public:
53         AModuleResample(AModule *module);
54         ~AModuleResample();
55
56 // All positions are in source sample rate
57         int read_samples(Samples *buffer, int64_t start, int64_t len);
58         
59         AModule *module;
60 // output for nested EDL if resampled
61         Samples *nested_output[MAX_CHANNELS];
62 // number of samples allocated
63         int nested_allocation;
64 };
65
66 class AModule : public Module
67 {
68 public:
69         AModule(RenderEngine *renderengine, 
70                 CommonRender *commonrender, 
71                 PluginArray *plugin_array,
72         Track *track);
73         virtual ~AModule();
74
75         void create_objects();
76         CICache* get_cache();
77
78         int import_samples(AEdit *playable_edit, 
79                 int64_t start_project,
80                 int64_t edit_startproject,
81                 int64_t edit_startsource,
82                 int direction,
83                 int sample_rate,
84                 Samples *buffer,
85                 int64_t fragment_len);
86
87
88         int render(Samples *buffer, 
89                 int64_t input_len,
90                 int64_t input_position,
91                 int direction,
92                 int sample_rate,
93                 int use_nudge);
94         int get_buffer_size();
95
96         AttachmentPoint* new_attachment(Plugin *plugin);
97
98
99
100
101 // synchronization with tracks
102         FloatAutos* get_pan_automation(int channel);  // get pan automation
103         FloatAutos* get_fade_automation();       // get the fade automation for this module
104
105
106         double *level_history;
107         int64_t *level_samples;
108         int current_level;
109
110 // Temporary buffer for rendering transitions
111         Samples *transition_temp;
112 // Temporary buffer for rendering speed curve
113         Samples *speed_temp;
114 // Previous buffers for rendering speed curve
115 #define SPEED_OVERLAP 4
116         double prev_head[SPEED_OVERLAP];
117         double prev_tail[SPEED_OVERLAP];
118
119 // Pointer to an asset for the resampler
120         Asset *asset;
121 // Channel to import from the source
122         int channel;
123 // File being read if source is a file.
124         File *file;
125
126 // Temporary buffer for rendering a nested audio EDL.
127 // Sharing nested output between modules wouldn't work because if the 
128 // segment was cut inside input_len, the shared channels would have to 
129 // initialize their EDL's at different starting points and botch their 
130 // starting states.
131         Samples *nested_output[MAX_CHANNELS];
132 // number of samples allocated
133         int nested_allocation;
134 // resampling for nested output
135         AModuleResample *resample;
136 };
137
138
139 #endif
140