initial commit
[goodguy/history.git] / cinelerra-5.0 / cinelerra / vtracking.C
1
2 /*
3  * CINELERRA
4  * Copyright (C) 2008 Adam Williams <broadcast at earthling dot net>
5  * 
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.
10  * 
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.
15  * 
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
19  * 
20  */
21
22 #include "edl.h"
23 #include "edlsession.h"
24 #include "localsession.h"
25 #include "mainclock.h"
26 #include "meterpanel.h"
27 #include "mwindow.h"
28 #include "vplayback.h"
29 #include "vtimebar.h"
30 #include "vtracking.h"
31 #include "vwindow.h"
32 #include "vwindowgui.h"
33
34
35 VTracking::VTracking(MWindow *mwindow, VWindow *vwindow)
36  : Tracking(mwindow)
37 {
38         this->vwindow = vwindow;
39 }
40
41 VTracking::~VTracking()
42 {
43 }
44
45 PlaybackEngine* VTracking::get_playback_engine()
46 {
47         return vwindow->playback_engine;
48 }
49
50 void VTracking::update_tracker(double position)
51 {
52 //printf("VTracking::update_tracker %ld\n", position);
53         vwindow->gui->lock_window("VTracking::update_tracker");
54         vwindow->get_edl()->local_session->set_selectionstart(position);
55         vwindow->get_edl()->local_session->set_selectionend(position);
56
57         vwindow->gui->clock->update(position);
58
59 // This is going to boost the latency but we need to update the timebar
60         vwindow->gui->timebar->update(1);
61
62         vwindow->gui->unlock_window();
63
64         update_meters((int64_t)(position * mwindow->edl->session->sample_rate));
65 }
66
67 void VTracking::update_meters(int64_t position)
68 {
69         double output_levels[MAXCHANNELS];
70
71         int do_audio = get_playback_engine()->get_output_levels(output_levels, 
72                 position);
73         if(do_audio)
74         {
75                 vwindow->gui->lock_window("VTracking::update_meters");
76                 vwindow->gui->meters->update(output_levels);
77                 vwindow->gui->unlock_window();
78         }
79 }
80
81 void VTracking::stop_meters()
82 {
83         vwindow->gui->lock_window("VTracking::stop_meters");
84         vwindow->gui->meters->stop_meters();
85         vwindow->gui->unlock_window();
86 }
87
88 void VTracking::draw()
89 {
90 }