4 * Copyright (C) 2008 Adam Williams <broadcast at earthling dot net>
5 * Copyright (C) 2003-2016 Cinelerra CV contributors
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation; either version 2 of the License, or
10 * (at your option) any later version.
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
17 * You should have received a copy of the GNU General Public License
18 * along with this program; if not, write to the Free Software
19 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
26 #include "apluginset.h"
29 #include "aautomation.h"
32 #include "edlsession.h"
38 #include "floatautos.h"
40 #include "localsession.h"
41 #include "mainsession.h"
44 #include "trackcanvas.h"
51 ATrack::ATrack(EDL *edl, Tracks *tracks)
54 data_type = TRACK_AUDIO;
55 data_h = edl->local_session->zoom_atrack;
62 // Used by PlaybackEngine
63 void ATrack::synchronize_params(Track *track)
65 Track::synchronize_params(track);
66 //ATrack *atrack = (ATrack*)track;
69 int ATrack::copy_settings(Track *track)
71 Track::copy_settings(track);
72 //ATrack *atrack = (ATrack*)track;
77 int ATrack::save_header(FileXML *file)
79 file->tag.set_property("TYPE", "AUDIO");
83 int ATrack::save_derived(FileXML *file)
85 file->append_newline();
89 int ATrack::load_header(FileXML *file, uint32_t load_flags)
95 int ATrack::load_derived(FileXML *file, uint32_t load_flags)
100 void ATrack::create_objects()
102 Track::create_objects();
103 automation = new AAutomation(edl, this);
104 automation->create_objects();
105 edits = new AEdits(edl, this);
108 int ATrack::vertical_span(Theme *theme)
110 int track_h = Track::vertical_span(theme);
111 int patch_h = theme->title_h;
113 patch_h += theme->play_h + theme->fade_h + theme->meter_h + theme->pan_h;
114 return MAX(track_h, patch_h);
117 PluginSet* ATrack::new_plugins()
119 return new APluginSet(edl, this);
122 int ATrack::load_defaults(BC_Hash *defaults)
124 Track::load_defaults(defaults);
128 void ATrack::set_default_title()
130 Track *current = ListItem<Track>::list->first;
132 for(i = 0; current; current = NEXT)
134 if(current->data_type == TRACK_AUDIO) i++;
136 sprintf(title, _("Audio %d"), i);
137 BC_Resources::encode_to_utf8(title, BCTEXTLEN);
140 int64_t ATrack::to_units(double position, int round)
142 return round ? Units::round(position * edl->session->sample_rate) :
143 Units::to_int64(position * edl->session->sample_rate + 1e-6);
146 double ATrack::to_doubleunits(double position)
148 return position * edl->session->sample_rate;
151 double ATrack::from_units(int64_t position)
153 return (double)position / edl->session->sample_rate;
156 int ATrack::identical(int64_t sample1, int64_t sample2)
159 if(labs(sample1 - sample2) <= 1) return 1; else return 0;
162 int64_t ATrack::length()
164 return edits->length();
167 int ATrack::paste_derived(int64_t start, int64_t end, int64_t total_length, FileXML *xml, int ¤t_channel)
169 if(!strcmp(xml->tag.get_title(), "PANAUTOS"))
171 current_channel = xml->tag.get_property("CHANNEL", current_channel);
172 // pan_autos->paste(start, end, total_length, xml, "/PANAUTOS", mwindow->session->autos_follow_edits);