1 #include "automation.h"
6 #include "localsession.h"
9 static char *xml_autogrouptypes_titlesmax[] =
11 "AUTOGROUPTYPE_AUDIO_FADE_MAX",
12 "AUTOGROUPTYPE_VIDEO_FADE_MAX",
13 "AUTOGROUPTYPE_ZOOM_MAX",
14 "AUTOGROUPTYPE_X_MAX",
15 "AUTOGROUPTYPE_Y_MAX",
16 "AUTOGROUPTYPE_INT255_MAX"
19 static char *xml_autogrouptypes_titlesmin[] =
21 "AUTOGROUPTYPE_AUDIO_FADE_MIN",
22 "AUTOGROUPTYPE_VIDEO_FADE_MIN",
23 "AUTOGROUPTYPE_ZOOM_MIN",
24 "AUTOGROUPTYPE_X_MIN",
25 "AUTOGROUPTYPE_Y_MIN",
26 "AUTOGROUPTYPE_INT255_MIN"
30 LocalSession::LocalSession(EDL *edl)
34 selectionstart = selectionend = 0;
35 in_point = out_point = -1;
36 strcpy(folder, CLIP_FOLDER);
37 sprintf(clip_title, "Program");
38 strcpy(clip_notes, "Hello world");
40 preview_start = preview_end = 0;
50 automation_mins[AUTOGROUPTYPE_AUDIO_FADE] = -80;
51 automation_maxs[AUTOGROUPTYPE_AUDIO_FADE] = 6;
53 automation_mins[AUTOGROUPTYPE_VIDEO_FADE] = 0;
54 automation_maxs[AUTOGROUPTYPE_VIDEO_FADE] = 100;
56 automation_mins[AUTOGROUPTYPE_ZOOM] = 0.001;
57 automation_maxs[AUTOGROUPTYPE_ZOOM] = 4;
59 automation_mins[AUTOGROUPTYPE_X] = -100;
60 automation_maxs[AUTOGROUPTYPE_X] = 100;
62 automation_mins[AUTOGROUPTYPE_Y] = -100;
63 automation_maxs[AUTOGROUPTYPE_Y] = 100;
65 automation_mins[AUTOGROUPTYPE_INT255] = 0;
66 automation_maxs[AUTOGROUPTYPE_INT255] = 255;
68 zoombar_showautotype = AUTOGROUPTYPE_AUDIO_FADE;
69 red = green = blue = 0;
72 LocalSession::~LocalSession()
76 void LocalSession::copy_from(LocalSession *that)
78 strcpy(clip_title, that->clip_title);
79 strcpy(clip_notes, that->clip_notes);
80 strcpy(folder, that->folder);
81 in_point = that->in_point;
82 loop_playback = that->loop_playback;
83 loop_start = that->loop_start;
84 loop_end = that->loop_end;
85 out_point = that->out_point;
86 selectionend = that->selectionend;
87 selectionstart = that->selectionstart;
88 track_start = that->track_start;
89 view_start = that->view_start;
90 zoom_sample = that->zoom_sample;
91 zoom_y = that->zoom_y;
92 zoom_track = that->zoom_track;
93 preview_start = that->preview_start;
94 preview_end = that->preview_end;
97 for (int i = 0; i < AUTOGROUPTYPE_COUNT; i++) {
98 automation_mins[i] = that->automation_mins[i];
99 automation_maxs[i] = that->automation_maxs[i];
104 void LocalSession::save_xml(FileXML *file, double start)
106 file->tag.set_title("LOCALSESSION");
108 file->tag.set_property("IN_POINT", in_point - start);
109 file->tag.set_property("LOOP_PLAYBACK", loop_playback);
110 file->tag.set_property("LOOP_START", loop_start - start);
111 file->tag.set_property("LOOP_END", loop_end - start);
112 file->tag.set_property("OUT_POINT", out_point - start);
113 file->tag.set_property("SELECTION_START", selectionstart - start);
114 file->tag.set_property("SELECTION_END", selectionend - start);
115 file->tag.set_property("CLIP_TITLE", clip_title);
116 file->tag.set_property("CLIP_NOTES", clip_notes);
117 file->tag.set_property("FOLDER", folder);
118 file->tag.set_property("TRACK_START", track_start);
119 file->tag.set_property("VIEW_START", view_start);
120 file->tag.set_property("ZOOM_SAMPLE", zoom_sample);
121 //printf("EDLSession::save_session 1\n");
122 file->tag.set_property("ZOOMY", zoom_y);
123 //printf("EDLSession::save_session 1 %d\n", zoom_track);
124 file->tag.set_property("ZOOM_TRACK", zoom_track);
126 double preview_start = this->preview_start - start;
127 if(preview_start < 0) preview_start = 0;
128 double preview_end = this->preview_end - start;
129 if(preview_end < 0) preview_end = 0;
131 file->tag.set_property("PREVIEW_START", preview_start);
132 file->tag.set_property("PREVIEW_END", preview_end);
133 file->tag.set_property("RED", red);
134 file->tag.set_property("GREEN", green);
135 file->tag.set_property("BLUE", blue);
137 for (int i = 0; i < AUTOGROUPTYPE_COUNT; i++) {
138 if (!Automation::autogrouptypes_fixedrange[i]) {
139 file->tag.set_property(xml_autogrouptypes_titlesmin[i],automation_mins[i]);
140 file->tag.set_property(xml_autogrouptypes_titlesmax[i],automation_maxs[i]);
144 file->tag.set_title("/LOCALSESSION");
146 file->append_newline();
147 file->append_newline();
150 void LocalSession::synchronize_params(LocalSession *that)
152 loop_playback = that->loop_playback;
153 loop_start = that->loop_start;
154 loop_end = that->loop_end;
155 preview_start = that->preview_start;
156 preview_end = that->preview_end;
163 void LocalSession::load_xml(FileXML *file, unsigned long load_flags)
165 if(load_flags & LOAD_SESSION)
167 clipboard_length = 0;
168 // Overwritten by MWindow::load_filenames
169 file->tag.get_property("CLIP_TITLE", clip_title);
170 file->tag.get_property("CLIP_NOTES", clip_notes);
171 file->tag.get_property("FOLDER", folder);
172 loop_playback = file->tag.get_property("LOOP_PLAYBACK", 0);
173 loop_start = file->tag.get_property("LOOP_START", (double)0);
174 loop_end = file->tag.get_property("LOOP_END", (double)0);
175 selectionstart = file->tag.get_property("SELECTION_START", (double)0);
176 selectionend = file->tag.get_property("SELECTION_END", (double)0);
177 track_start = file->tag.get_property("TRACK_START", track_start);
178 view_start = file->tag.get_property("VIEW_START", view_start);
179 zoom_sample = file->tag.get_property("ZOOM_SAMPLE", zoom_sample);
180 zoom_y = file->tag.get_property("ZOOMY", zoom_y);
181 zoom_track = file->tag.get_property("ZOOM_TRACK", zoom_track);
182 preview_start = file->tag.get_property("PREVIEW_START", preview_start);
183 preview_end = file->tag.get_property("PREVIEW_END", preview_end);
184 red = file->tag.get_property("RED", red);
185 green = file->tag.get_property("GREEN", green);
186 blue = file->tag.get_property("BLUE", blue);
188 for (int i = 0; i < AUTOGROUPTYPE_COUNT; i++) {
189 if (!Automation::autogrouptypes_fixedrange[i]) {
190 automation_mins[i] = file->tag.get_property(xml_autogrouptypes_titlesmin[i],automation_mins[i]);
191 automation_maxs[i] = file->tag.get_property(xml_autogrouptypes_titlesmax[i],automation_maxs[i]);
197 // on operations like cut, paste, slice, clear... we should also undo the cursor position as users
198 // expect - this is additionally important in keyboard-only editing in viewer window
199 if(load_flags & LOAD_SESSION || load_flags & LOAD_TIMEBAR)
201 selectionstart = file->tag.get_property("SELECTION_START", (double)0);
202 selectionend = file->tag.get_property("SELECTION_END", (double)0);
207 if(load_flags & LOAD_TIMEBAR)
209 in_point = file->tag.get_property("IN_POINT", (double)-1);
210 out_point = file->tag.get_property("OUT_POINT", (double)-1);
214 void LocalSession::boundaries()
216 zoom_sample = MAX(1, zoom_sample);
219 int LocalSession::load_defaults(BC_Hash *defaults)
221 loop_playback = defaults->get("LOOP_PLAYBACK", 0);
222 loop_start = defaults->get("LOOP_START", (double)0);
223 loop_end = defaults->get("LOOP_END", (double)0);
224 selectionstart = defaults->get("SELECTIONSTART", selectionstart);
225 selectionend = defaults->get("SELECTIONEND", selectionend);
226 // track_start = defaults->get("TRACK_START", 0);
227 // view_start = defaults->get("VIEW_START", 0);
228 zoom_sample = defaults->get("ZOOM_SAMPLE", 16384);
229 zoom_y = defaults->get("ZOOMY", 64);
230 zoom_track = defaults->get("ZOOM_TRACK", 64);
231 red = defaults->get("RED", 0.0);
232 green = defaults->get("GREEN", 0.0);
233 blue = defaults->get("BLUE", 0.0);
235 for (int i = 0; i < AUTOGROUPTYPE_COUNT; i++) {
236 if (!Automation::autogrouptypes_fixedrange[i]) {
237 automation_mins[i] = defaults->get(xml_autogrouptypes_titlesmin[i], automation_mins[i]);
238 automation_maxs[i] = defaults->get(xml_autogrouptypes_titlesmax[i], automation_maxs[i]);
245 int LocalSession::save_defaults(BC_Hash *defaults)
247 defaults->update("LOOP_PLAYBACK", loop_playback);
248 defaults->update("LOOP_START", loop_start);
249 defaults->update("LOOP_END", loop_end);
250 defaults->update("SELECTIONSTART", selectionstart);
251 defaults->update("SELECTIONEND", selectionend);
252 defaults->update("TRACK_START", track_start);
253 defaults->update("VIEW_START", view_start);
254 defaults->update("ZOOM_SAMPLE", zoom_sample);
255 defaults->update("ZOOMY", zoom_y);
256 defaults->update("ZOOM_TRACK", zoom_track);
257 defaults->update("RED", red);
258 defaults->update("GREEN", green);
259 defaults->update("BLUE", blue);
261 for (int i = 0; i < AUTOGROUPTYPE_COUNT; i++) {
262 if (!Automation::autogrouptypes_fixedrange[i]) {
263 defaults->update(xml_autogrouptypes_titlesmin[i], automation_mins[i]);
264 defaults->update(xml_autogrouptypes_titlesmax[i], automation_maxs[i]);
271 void LocalSession::set_selectionstart(double value)
273 this->selectionstart = value;
276 void LocalSession::set_selectionend(double value)
278 this->selectionend = value;
281 void LocalSession::set_inpoint(double value)
286 void LocalSession::set_outpoint(double value)
291 void LocalSession::unset_inpoint()
296 void LocalSession::unset_outpoint()
303 double LocalSession::get_selectionstart(int highlight_only)
305 if(highlight_only || !EQUIV(selectionstart, selectionend))
306 return selectionstart;
314 return selectionstart;
317 double LocalSession::get_selectionend(int highlight_only)
319 if(highlight_only || !EQUIV(selectionstart, selectionend))
331 double LocalSession::get_inpoint()
336 double LocalSession::get_outpoint()
341 int LocalSession::inpoint_valid()
343 return in_point >= 0;
346 int LocalSession::outpoint_valid()
348 return out_point >= 0;