4 * Copyright (C) 2008 Adam Williams <broadcast at earthling dot net>
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.
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.
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
25 #include "apluginset.h"
28 #include "aautomation.h"
31 #include "edlsession.h"
37 #include "floatautos.h"
39 #include "localsession.h"
40 #include "mainsession.h"
43 #include "trackcanvas.h"
50 ATrack::ATrack(EDL *edl, Tracks *tracks)
53 data_type = TRACK_AUDIO;
60 // Used by PlaybackEngine
61 void ATrack::synchronize_params(Track *track)
63 Track::synchronize_params(track);
64 //ATrack *atrack = (ATrack*)track;
67 int ATrack::copy_settings(Track *track)
69 Track::copy_settings(track);
70 //ATrack *atrack = (ATrack*)track;
75 int ATrack::save_header(FileXML *file)
77 file->tag.set_property("TYPE", "AUDIO");
81 int ATrack::save_derived(FileXML *file)
83 file->append_newline();
87 int ATrack::load_header(FileXML *file, uint32_t load_flags)
93 int ATrack::load_derived(FileXML *file, uint32_t load_flags)
98 void ATrack::create_objects()
100 Track::create_objects();
101 automation = new AAutomation(edl, this);
102 automation->create_objects();
103 edits = new AEdits(edl, this);
106 int ATrack::vertical_span(Theme *theme)
108 int track_h = Track::vertical_span(theme);
109 int patch_h = theme->title_h;
111 patch_h += theme->play_h + theme->fade_h + theme->meter_h + theme->pan_h;
112 return MAX(track_h, patch_h);
115 PluginSet* ATrack::new_plugins()
117 return new APluginSet(edl, this);
120 int ATrack::load_defaults(BC_Hash *defaults)
122 Track::load_defaults(defaults);
126 void ATrack::set_default_title()
128 Track *current = ListItem<Track>::list->first;
130 for(i = 0; current; current = NEXT)
132 if(current->data_type == TRACK_AUDIO) i++;
134 sprintf(title, _("Audio %d"), i);
135 BC_Resources::encode_to_utf8(title, BCTEXTLEN);
138 int64_t ATrack::to_units(double position, int round)
140 return round ? Units::round(position * edl->session->sample_rate) :
141 Units::to_int64(position * edl->session->sample_rate + 1e-6);
144 double ATrack::to_doubleunits(double position)
146 return position * edl->session->sample_rate;
149 double ATrack::from_units(int64_t position)
151 return (double)position / edl->session->sample_rate;
154 int ATrack::identical(int64_t sample1, int64_t sample2)
157 if(labs(sample1 - sample2) <= 1) return 1; else return 0;
160 int64_t ATrack::length()
162 return edits->length();
165 int ATrack::paste_derived(int64_t start, int64_t end, int64_t total_length, FileXML *xml, int ¤t_channel)
167 if(!strcmp(xml->tag.get_title(), "PANAUTOS"))
169 current_channel = xml->tag.get_property("CHANNEL", current_channel);
170 // pan_autos->paste(start, end, total_length, xml, "/PANAUTOS", mwindow->session->autos_follow_edits);