r1014: Enable horizontal scrolling with the mouse wheel by pressing Ctrl.
[cinelerra_cv/ct.git] / cinelerra / atrack.C
blob5314cf544d81eb908e46f2edb483b68b659beae9
1 #include "aedit.h"
2 #include "aedits.h"
3 #include "amodule.h"
4 #include "apluginset.h"
5 #include "atrack.h"
6 #include "autoconf.h"
7 #include "aautomation.h"
8 #include "edit.h"
9 #include "edl.h"
10 #include "edlsession.h"
11 #include "cache.h"
12 #include "clip.h"
13 #include "datatype.h"
14 #include "file.h"
15 #include "filexml.h"
16 #include "floatautos.h"
17 #include "language.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>
29 ATrack::ATrack(EDL *edl, Tracks *tracks)
30  : Track(edl, tracks)
32         data_type = TRACK_AUDIO;
35 ATrack::~ATrack()
39 // Used by PlaybackEngine
40 void ATrack::synchronize_params(Track *track)
42         Track::synchronize_params(track);
44         ATrack *atrack = (ATrack*)track;
47 int ATrack::copy_settings(Track *track)
49         Track::copy_settings(track);
51         ATrack *atrack = (ATrack*)track;
52         return 0;
56 int ATrack::save_header(FileXML *file)
58         file->tag.set_property("TYPE", "AUDIO");
59         return 0;
62 int ATrack::save_derived(FileXML *file)
64         char string[BCTEXTLEN];
65         file->append_newline();
66         return 0;
69 int ATrack::load_header(FileXML *file, uint32_t load_flags)
71         return 0;
75 int ATrack::load_derived(FileXML *file, uint32_t load_flags)
77         return 0;
80 int ATrack::create_objects()
82         Track::create_objects();
83         automation = new AAutomation(edl, this);
84         automation->create_objects();
85         edits = new AEdits(edl, this);
86         return 0;
89 int ATrack::vertical_span(Theme *theme)
91         int track_h = Track::vertical_span(theme);
92         int patch_h = 0;
93         if(expand_view)
94         {
95                 patch_h += theme->title_h + theme->play_h + theme->fade_h + theme->meter_h + theme->pan_h;
96         }
97         return MAX(track_h, patch_h);
100 PluginSet* ATrack::new_plugins()
102         return new APluginSet(edl, this);
105 int ATrack::load_defaults(BC_Hash *defaults)
107         Track::load_defaults(defaults);
108         return 0;
111 void ATrack::set_default_title()
113         Track *current = ListItem<Track>::owner->first;
114         int i;
115         for(i = 0; current; current = NEXT)
116         {
117                 if(current->data_type == TRACK_AUDIO) i++;
118         }
119         sprintf(title, _("Audio %d"), i);
122 int64_t ATrack::to_units(double position, int round)
124         if(round)
125                 return Units::round(position * edl->session->sample_rate);
126         else
127                 return Units::to_int64(position * edl->session->sample_rate);
130 double ATrack::to_doubleunits(double position)
132         return position * edl->session->sample_rate;
135 double ATrack::from_units(int64_t position)
137         return (double)position / edl->session->sample_rate;
141 int ATrack::identical(int64_t sample1, int64_t sample2)
143 // Units of samples
144         if(labs(sample1 - sample2) <= 1) return 1; else return 0;
170 int64_t ATrack::length()
172         return edits->length();
175 int ATrack::get_dimensions(double &view_start, 
176         double &view_units, 
177         double &zoom_units)
179         view_start = (double)edl->local_session->view_start * edl->session->sample_rate;
180         view_units = (double)0;
181 //      view_units = (double)tracks->view_samples();
182         zoom_units = (double)edl->local_session->zoom_sample;
191 int ATrack::paste_derived(int64_t start, int64_t end, int64_t total_length, FileXML *xml, int &current_channel)
193         if(!strcmp(xml->tag.get_title(), "PANAUTOS"))
194         {
195                 current_channel = xml->tag.get_property("CHANNEL", current_channel);
196 //              pan_autos->paste(start, end, total_length, xml, "/PANAUTOS", mwindow->session->autos_follow_edits);
197                 return 1;
198         }
199         return 0;