2 #include "automation.h"
8 #include "edlsession.h"
13 #include "localsession.h"
18 #include "mainsession.h"
21 #include "trackcanvas.h"
23 #include "transportque.inc"
27 Tracks::Tracks(EDL *edl)
49 void Tracks::equivalent_output(Tracks *tracks, double *result)
51 if(total_playable_vtracks() != tracks->total_playable_vtracks())
57 Track *current = first;
58 Track *that_current = tracks->first;
59 while(current || that_current)
61 // Get next video track
62 while(current && current->data_type != TRACK_VIDEO)
65 while(that_current && that_current->data_type != TRACK_VIDEO)
66 that_current = that_current->next;
68 // One doesn't exist but the other does
69 if((!current && that_current) ||
70 (current && !that_current))
77 if(current && that_current)
79 current->equivalent_output(that_current, result);
81 that_current = that_current->next;
90 void Tracks::get_affected_edits(ArrayList<Edit*> *drag_edits, double position, Track *start_track)
92 drag_edits->remove_all();
94 for(Track *track = start_track;
98 //printf("Tracks::get_affected_edits 1 %p %d %d\n", track, track->data_type, track->record);
101 for(Edit *edit = track->edits->first; edit; edit = edit->next)
103 double startproject = track->from_units(edit->startproject);
104 //printf("Tracks::get_affected_edits 1 %d\n", edl->equivalent(startproject, position));
105 if(edl->equivalent(startproject, position))
107 drag_edits->append(edit);
118 Tracks& Tracks::operator=(Tracks &tracks)
122 for(Track *current = tracks.first; current; current = NEXT)
124 switch(current->data_type)
127 new_track = add_audio_track(0, 0);
130 new_track = add_video_track(0, 0);
133 *new_track = *current;
138 int Tracks::load(FileXML *xml, int &track_offset, uint32_t load_flags)
140 // add the appropriate type of track
141 char string[BCTEXTLEN];
145 xml->tag.get_property("TYPE", string);
147 if((load_flags & LOAD_ALL) == LOAD_ALL ||
148 (load_flags & LOAD_EDITS))
150 if(!strcmp(string, "VIDEO"))
152 add_video_track(0, 0);
156 add_audio_track(0, 0); // default to audio
162 track = get_item_number(track_offset);
167 if(track) track->load(xml, track_offset, load_flags);
172 Track* Tracks::add_audio_track(int above, Track *dst_track)
175 ATrack* new_track = new ATrack(edl, this);
178 dst_track = (above ? first : last);
183 insert_before(dst_track, (Track*)new_track);
187 insert_after(dst_track, (Track*)new_track);
188 // Shift effects referenced below the destination track
191 // Shift effects referenced below the new track
192 for(Track *track = last;
193 track && track != new_track;
194 track = track->previous)
196 change_modules(number_of(track) - 1, number_of(track), 0);
200 new_track->create_objects();
201 new_track->set_default_title();
204 for(Track *current = first;
205 current != (Track*)new_track;
208 if(current->data_type == TRACK_AUDIO) current_pan++;
209 if(current_pan >= edl->session->audio_channels) current_pan = 0;
214 PanAuto* pan_auto = (PanAuto*)new_track->automation->pan_autos->default_auto;
215 pan_auto->values[current_pan] = 1.0;
217 BC_Pan::calculate_stick_position(edl->session->audio_channels,
218 edl->session->achannel_positions,
227 Track* Tracks::add_video_track(int above, Track *dst_track)
230 VTrack* new_track = new VTrack(edl, this);
232 dst_track = (above ? first : last);
236 insert_before(dst_track, (Track*)new_track);
240 insert_after(dst_track, (Track*)new_track);
245 // Shift effects referenced below the new track
246 for(Track *track = last;
247 track && track != new_track;
248 track = track->previous)
250 change_modules(number_of(track) - 1, number_of(track), 0);
255 new_track->create_objects();
256 new_track->set_default_title();
261 int Tracks::delete_track()
267 int Tracks::delete_track(Track *track)
269 int old_location = number_of(track);
270 // Shift effects referenced below the deleted track
271 for(Track *current = last;
272 current && current != track;
275 change_modules(number_of(current), number_of(current) - 1, 0);
277 if(track) delete track;
282 int Tracks::total_of(int type)
285 IntAuto *mute_keyframe = 0;
287 for(Track *current = first; current; current = NEXT)
289 long unit_start = current->to_units(edl->local_session->selectionstart, 0);
290 mute_keyframe = (IntAuto*)current->automation->mute_autos->get_prev_auto(
293 (Auto*)mute_keyframe);
296 (current->play && type == PLAY) ||
297 (current->record && type == RECORD) ||
298 (current->gang && type == GANG) ||
299 (current->draw && type == DRAW) ||
300 (mute_keyframe->value && type == MUTE) ||
301 (current->expand_view && type == EXPAND);
306 int Tracks::recordable_audio_tracks()
309 for(Track *current = first; current; current = NEXT)
310 if(current->data_type == TRACK_AUDIO && current->record) result++;
314 int Tracks::recordable_video_tracks()
317 for(Track *current = first; current; current = NEXT)
319 if(current->data_type == TRACK_VIDEO && current->record) result++;
325 int Tracks::playable_audio_tracks()
329 for(Track *current = first; current; current = NEXT)
331 if(current->data_type == TRACK_AUDIO && current->play)
340 int Tracks::playable_video_tracks()
344 for(Track *current = first; current; current = NEXT)
346 if(current->data_type == TRACK_VIDEO && current->play)
354 int Tracks::total_audio_tracks()
357 for(Track *current = first; current; current = NEXT)
358 if(current->data_type == TRACK_AUDIO) result++;
362 int Tracks::total_video_tracks()
365 for(Track *current = first; current; current = NEXT)
366 if(current->data_type == TRACK_VIDEO) result++;
370 double Tracks::total_playable_length()
373 for(Track *current = first; current; current = NEXT)
375 double length = current->get_length();
376 if(length > total) total = length;
381 double Tracks::total_recordable_length()
384 for(Track *current = first; current; current = NEXT)
388 double length = current->get_length();
389 if(length > total) total = length;
395 double Tracks::total_length()
398 for(Track *current = first; current; current = NEXT)
400 if(current->get_length() > total) total = current->get_length();
405 double Tracks::total_video_length()
408 for(Track *current = first; current; current = NEXT)
410 if(current->data_type == TRACK_VIDEO &&
411 current->get_length() > total) total = current->get_length();
417 void Tracks::translate_camera(float offset_x, float offset_y)
419 for(Track *current = first; current; current = NEXT)
421 if(current->data_type == TRACK_VIDEO)
423 ((VTrack*)current)->translate_camera(offset_x, offset_y);
427 void Tracks::translate_projector(float offset_x, float offset_y)
429 for(Track *current = first; current; current = NEXT)
431 if(current->data_type == TRACK_VIDEO)
433 ((VTrack*)current)->translate_projector(offset_x, offset_y);
438 void Tracks::update_y_pixels(Theme *theme)
440 int y = -edl->local_session->track_start;
441 for(Track *current = first; current; current = NEXT)
443 //printf("Tracks::update_y_pixels %d\n", y);
444 current->y_pixel = y;
445 y += current->vertical_span(theme);
451 for(Track* current = first; current; current = NEXT)
453 printf(" Track: %x\n", current);
460 void Tracks::select_all(int type,
463 for(Track* current = first; current; current = NEXT)
465 double position = edl->local_session->selectionstart;
467 if(type == PLAY) current->play = value;
468 if(type == RECORD) current->record = value;
469 if(type == GANG) current->gang = value;
470 if(type == DRAW) current->draw = value;
474 ((IntAuto*)current->automation->mute_autos->get_auto_for_editing(position))->value = value;
477 if(type == EXPAND) current->expand_view = value;
522 // ===================================== file operations
524 int Tracks::popup_transition(int cursor_x, int cursor_y)
527 for(Track* current = first; current && !result; current = NEXT)
529 result = current->popup_transition(cursor_x, cursor_y);
535 int Tracks::change_channels(int oldchannels, int newchannels)
537 for(Track *current = first; current; current = NEXT)
538 { current->change_channels(oldchannels, newchannels); }
544 int Tracks::totalpixels()
547 for(Track* current = first; current; current = NEXT)
549 result += edl->local_session->zoom_track;
554 int Tracks::number_of(Track *track)
557 for(Track *current = first; current && current != track; current = NEXT)
564 Track* Tracks::number(int number)
568 for(current = first; current && i < number; current = NEXT)
576 int Tracks::total_playable_vtracks()
579 for(Track *current = first; current; current = NEXT)
581 if(current->data_type == TRACK_VIDEO && current->play) result++;