r125: This commit was manufactured by cvs2svn to create tag 'r1_1_7-last'.
[cinelerra_cv/mob.git] / hvirtual / cinelerra / atrack.C
blob7fd14c02f9176a75957cf46150fa6da2e78a61a4
1 #include "aedit.h"
2 #include "aedits.h"
3 #include "amodule.h"
4 #include "apluginset.h"
5 #include "assets.h"
6 #include "atrack.h"
7 #include "autoconf.h"
8 #include "aautomation.h"
9 #include "edit.h"
10 #include "edl.h"
11 #include "edlsession.h"
12 #include "cache.h"
13 #include "clip.h"
14 #include "datatype.h"
15 #include "file.h"
16 #include "filexml.h"
17 #include "floatautos.h"
18 #include "localsession.h"
19 #include "mainsession.h"
20 #include "panautos.h"
21 #include "theme.h"
22 #include "trackcanvas.h"
23 #include "tracks.h"
25 #include <string.h>
27 #include <libintl.h>
28 #define _(String) gettext(String)
29 #define gettext_noop(String) String
30 #define N_(String) gettext_noop (String)
33 ATrack::ATrack(EDL *edl, Tracks *tracks)
34  : Track(edl, tracks)
36         data_type = TRACK_AUDIO;
39 ATrack::~ATrack()
43 // Used by PlaybackEngine
44 void ATrack::synchronize_params(Track *track)
46         Track::synchronize_params(track);
48         ATrack *atrack = (ATrack*)track;
51 int ATrack::copy_settings(Track *track)
53         Track::copy_settings(track);
55         ATrack *atrack = (ATrack*)track;
56         return 0;
60 int ATrack::save_header(FileXML *file)
62         file->tag.set_property("TYPE", "AUDIO");
63         return 0;
66 int ATrack::save_derived(FileXML *file)
68         char string[BCTEXTLEN];
69         file->append_newline();
70         return 0;
73 int ATrack::load_header(FileXML *file, uint32_t load_flags)
75         return 0;
79 int ATrack::load_derived(FileXML *file, uint32_t load_flags)
81         return 0;
84 int ATrack::create_objects()
86         Track::create_objects();
87         automation = new AAutomation(edl, this);
88         automation->create_objects();
89         edits = new AEdits(edl, this);
90         return 0;
93 int ATrack::vertical_span(Theme *theme)
95         int track_h = Track::vertical_span(theme);
96         int patch_h = 0;
97         if(expand_view)
98         {
99                 patch_h += theme->title_h + theme->play_h + theme->fade_h + theme->meter_h + theme->pan_h;
100         }
101         return MAX(track_h, patch_h);
104 PluginSet* ATrack::new_plugins()
106         return new APluginSet(edl, this);
109 int ATrack::load_defaults(Defaults *defaults)
111         Track::load_defaults(defaults);
112         return 0;
115 void ATrack::set_default_title()
117         Track *current = ListItem<Track>::owner->first;
118         int i;
119         for(i = 0; current; current = NEXT)
120         {
121                 if(current->data_type == TRACK_AUDIO) i++;
122         }
123         sprintf(title, _("Audio %d"), i);
126 int64_t ATrack::to_units(double position, int round)
128         if(round)
129                 return Units::round(position * edl->session->sample_rate);
130         else
131                 return Units::to_int64(position * edl->session->sample_rate);
134 double ATrack::to_doubleunits(double position)
136         return position * edl->session->sample_rate;
139 double ATrack::from_units(int64_t position)
141         return (double)position / edl->session->sample_rate;
145 int ATrack::identical(int64_t sample1, int64_t sample2)
147 // Units of samples
148         if(labs(sample1 - sample2) <= 1) return 1; else return 0;
174 int64_t ATrack::length()
176         return edits->length();
179 int ATrack::get_dimensions(double &view_start, 
180         double &view_units, 
181         double &zoom_units)
183         view_start = (double)edl->local_session->view_start * edl->session->sample_rate;
184         view_units = (double)0;
185 //      view_units = (double)tracks->view_samples();
186         zoom_units = (double)edl->local_session->zoom_sample;
195 int ATrack::paste_derived(int64_t start, int64_t end, int64_t total_length, FileXML *xml, int &current_channel)
197         if(!strcmp(xml->tag.get_title(), "PANAUTOS"))
198         {
199                 current_channel = xml->tag.get_property("CHANNEL", current_channel);
200 //              pan_autos->paste(start, end, total_length, xml, "/PANAUTOS", mwindow->session->autos_follow_edits);
201                 return 1;
202         }
203         return 0;