00001 #include "autoconf.h"
00002 #include "automation.h"
00003 #include "autos.h"
00004 #include "atrack.inc"
00005 #include "bcsignals.h"
00006 #include "colors.h"
00007 #include "edl.h"
00008 #include "edlsession.h"
00009 #include "filexml.h"
00010 #include "intautos.h"
00011 #include "track.h"
00012 #include "transportque.inc"
00013
00014
00015 Automation::Automation(EDL *edl, Track *track)
00016 {
00017 this->edl = edl;
00018 this->track = track;
00019 bzero(autos, sizeof(Autos*) * AUTOMATION_TOTAL);
00020 }
00021
00022 Automation::~Automation()
00023 {
00024 for(int i = 0; i < AUTOMATION_TOTAL; i++)
00025 {
00026 delete autos[i];
00027 }
00028 }
00029
00030 int Automation::create_objects()
00031 {
00032 autos[AUTOMATION_MUTE] = new IntAutos(edl, track, 0);
00033 autos[AUTOMATION_MUTE]->create_objects();
00034 return 0;
00035 }
00036
00037 Automation& Automation::operator=(Automation& automation)
00038 {
00039 printf("Automation::operator= 1\n");
00040 copy_from(&automation);
00041 return *this;
00042 }
00043
00044 void Automation::equivalent_output(Automation *automation, int64_t *result)
00045 {
00046 for(int i = 0; i < AUTOMATION_TOTAL; i++)
00047 {
00048 if(autos[i] && automation->autos[i])
00049 autos[i]->equivalent_output(automation->autos[i], 0, result);
00050 }
00051 }
00052
00053 void Automation::copy_from(Automation *automation)
00054 {
00055 for(int i = 0; i < AUTOMATION_TOTAL; i++)
00056 {
00057 if(autos[i] && automation->autos[i])
00058 autos[i]->copy_from(automation->autos[i]);
00059 }
00060 }
00061
00062
00063 static char *xml_titles[] =
00064 {
00065 "MUTEAUTOS",
00066 "CAMERA_X",
00067 "CAMERA_Y",
00068 "CAMERA_Z",
00069 "PROJECTOR_X",
00070 "PROJECTOR_Y",
00071 "PROJECTOR_Z",
00072 "FADEAUTOS",
00073 "PANAUTOS",
00074 "MODEAUTOS",
00075 "MASKAUTOS",
00076 "NUDGEAUTOS"
00077 };
00078
00079 int Automation::load(FileXML *file)
00080 {
00081 for(int i = 0; i < AUTOMATION_TOTAL; i++)
00082 {
00083 if(file->tag.title_is(xml_titles[i]) && autos[i])
00084 {
00085 autos[i]->load(file);
00086 return 1;
00087 }
00088 }
00089 return 0;
00090 }
00091
00092 int Automation::paste(int64_t start,
00093 int64_t length,
00094 double scale,
00095 FileXML *file,
00096 int default_only,
00097 AutoConf *autoconf)
00098 {
00099 if(!autoconf) autoconf = edl->session->auto_conf;
00100
00101 for(int i = 0; i < AUTOMATION_TOTAL; i++)
00102 {
00103 if(file->tag.title_is(xml_titles[i]) && autos[i] && autoconf->autos[i])
00104 {
00105 autos[i]->paste(start, length, scale, file, default_only);
00106 return 1;
00107 }
00108 }
00109 return 0;
00110 }
00111
00112 int Automation::copy(int64_t start,
00113 int64_t end,
00114 FileXML *file,
00115 int default_only,
00116 int autos_only)
00117 {
00118
00119 for(int i = 0; i < AUTOMATION_TOTAL; i++)
00120 {
00121 if(autos[i])
00122 {
00123 file->tag.set_title(xml_titles[i]);
00124 file->append_tag();
00125 file->append_newline();
00126 autos[i]->copy(start,
00127 end,
00128 file,
00129 default_only,
00130 autos_only);
00131 char string[BCTEXTLEN];
00132 sprintf(string, "/%s", xml_titles[i]);
00133 file->tag.set_title(string);
00134 file->append_tag();
00135 file->append_newline();
00136 }
00137 }
00138
00139 return 0;
00140 }
00141
00142
00143 void Automation::clear(int64_t start,
00144 int64_t end,
00145 AutoConf *autoconf,
00146 int shift_autos)
00147 {
00148 AutoConf *temp_autoconf = 0;
00149
00150 if(!autoconf)
00151 {
00152 temp_autoconf = new AutoConf;
00153 temp_autoconf->set_all();
00154 autoconf = temp_autoconf;
00155 }
00156
00157 for(int i = 0; i < AUTOMATION_TOTAL; i++)
00158 {
00159 if(autos[i] && autoconf->autos[i])
00160 {
00161 autos[i]->clear(start, end, shift_autos);
00162 }
00163 }
00164
00165 if(temp_autoconf) delete temp_autoconf;
00166 }
00167
00168 void Automation::paste_silence(int64_t start, int64_t end)
00169 {
00170
00171 for(int i = 0; i < AUTOMATION_TOTAL; i++)
00172 {
00173 if(autos[i])
00174 autos[i]->paste_silence(start, end);
00175 }
00176 }
00177
00178
00179
00180
00181 void Automation::insert_track(Automation *automation,
00182 int64_t start_unit,
00183 int64_t length_units,
00184 int replace_default)
00185 {
00186 for(int i = 0; i < AUTOMATION_TOTAL; i++)
00187 {
00188 if(autos[i] && automation->autos[i])
00189 {
00190 autos[i]->insert_track(automation->autos[i],
00191 start_unit,
00192 length_units,
00193 replace_default);
00194 }
00195 }
00196
00197
00198 }
00199
00200 void Automation::resample(double old_rate, double new_rate)
00201 {
00202
00203 for(int i = 0; i < AUTOMATION_TOTAL; i++)
00204 {
00205 if(autos[i]) autos[i]->resample(old_rate, new_rate);
00206 }
00207 }
00208
00209
00210
00211 int Automation::direct_copy_possible(int64_t start, int direction)
00212 {
00213 return 1;
00214 }
00215
00216
00217
00218
00219 void Automation::get_projector(float *x,
00220 float *y,
00221 float *z,
00222 int64_t position,
00223 int direction)
00224 {
00225 }
00226
00227 void Automation::get_camera(float *x,
00228 float *y,
00229 float *z,
00230 int64_t position,
00231 int direction)
00232 {
00233 }
00234
00235
00236
00237
00238 int64_t Automation::get_length()
00239 {
00240 int64_t length = 0;
00241 int64_t total_length = 0;
00242
00243 for(int i = 0; i < AUTOMATION_TOTAL; i++)
00244 {
00245 if(autos[i])
00246 {
00247 length = autos[i]->get_length();
00248 if(length > total_length) total_length = length;
00249 }
00250 }
00251
00252
00253 return total_length;
00254 }
00255
00256 void Automation::get_extents(float *min,
00257 float *max,
00258 int *coords_undefined,
00259 int64_t unit_start,
00260 int64_t unit_end)
00261 {
00262 for(int i = 0; i < AUTOMATION_TOTAL; i++)
00263 {
00264 if(autos[i] && edl->session->auto_conf->autos[i])
00265 {
00266 autos[i]->get_extents(min, max, coords_undefined, unit_start, unit_end);
00267 }
00268 }
00269 }
00270
00271
00272 void Automation::dump()
00273 {
00274 printf(" Automation: %p\n", this);
00275
00276
00277 for(int i = 0; i < AUTOMATION_TOTAL; i++)
00278 {
00279 if(autos[i])
00280 {
00281 printf(" %s %p\n", xml_titles[i], autos[i]);
00282 autos[i]->dump();
00283 }
00284 }
00285
00286 }