4 #include "cwindowgui.h"
6 #include "edlsession.h"
7 #include "levelwindow.h"
8 #include "levelwindowgui.h"
9 #include "localsession.h"
10 #include "mainclock.h"
11 #include "meterpanel.h"
13 #include "mwindowgui.h"
16 #include "playbackengine.h"
17 #include "renderengine.h"
18 #include "mainsession.h"
19 #include "trackcanvas.h"
30 Tracking::Tracking(MWindow *mwindow)
33 this->gui = mwindow->gui;
34 this->mwindow = mwindow;
48 void Tracking::create_objects()
55 int Tracking::start_playback(double new_position)
57 last_position = new_position;
64 int Tracking::stop_playback()
66 // Wait to change state
73 // Final position is updated continuously during playback
75 double position = get_tracking_position();
77 update_tracker(position);
78 //printf("Tracking::stop_playback %ld\n", position);
84 PlaybackEngine* Tracking::get_playback_engine()
86 return mwindow->cwindow->playback_engine;
89 double Tracking::get_tracking_position()
91 //printf("Tracking::get_tracking_position %ld\n", get_playback_engine()->get_tracking_position());
92 return get_playback_engine()->get_tracking_position();
95 int Tracking::get_pixel(double position)
97 return (int64_t)((position - mwindow->edl->local_session->view_start) *
98 mwindow->edl->session->sample_rate /
99 mwindow->edl->local_session->zoom_sample +
104 void Tracking::update_meters(int64_t position)
106 double output_levels[MAXCHANNELS];
107 //printf("Tracking::update_meters 1\n");
108 int do_audio = get_playback_engine()->get_output_levels(output_levels, position);
112 module_levels.remove_all();
113 get_playback_engine()->get_module_levels(&module_levels, position);
115 mwindow->cwindow->gui->lock_window();
116 mwindow->cwindow->gui->meters->update(output_levels);
117 mwindow->cwindow->gui->unlock_window();
119 mwindow->lwindow->gui->lock_window();
120 mwindow->lwindow->gui->panel->update(output_levels);
121 mwindow->lwindow->gui->unlock_window();
123 //for(int i = 0; i < module_levels.total; i++)
124 // printf("Tracking::update_meters 2 %f\n", module_levels.values[i]);
126 mwindow->gui->lock_window();
127 mwindow->gui->patchbay->update_meters(&module_levels);
128 mwindow->gui->unlock_window();
130 //printf("Tracking::update_meters 3\n");
133 void Tracking::stop_meters()
135 //printf("Tracking::stop_meters 1\n");
136 mwindow->cwindow->gui->lock_window();
137 mwindow->cwindow->gui->meters->stop_meters();
138 mwindow->cwindow->gui->unlock_window();
140 mwindow->gui->lock_window();
141 mwindow->gui->patchbay->stop_meters();
142 mwindow->gui->unlock_window();
144 mwindow->lwindow->gui->lock_window();
145 mwindow->lwindow->gui->panel->stop_meters();
146 mwindow->lwindow->gui->unlock_window();
147 //printf("Tracking::stop_meters 2\n");
153 void Tracking::update_tracker(double position)
157 void Tracking::draw()
162 pixel = get_pixel(last_position);
165 gui->canvas->set_color(GREEN);
166 gui->canvas->set_inverse();
167 gui->canvas->draw_line(pixel, 0, pixel, gui->canvas->get_h());
168 gui->canvas->set_opaque();
169 //printf("Tracking::draw %d %d\n", pixel, gui->canvas->get_h());
170 gui->canvas->flash(pixel, 0, pixel + 1, gui->canvas->get_h());
172 gui->unlock_window();
176 int Tracking::wait_for_startup()
179 startup_lock.unlock();
186 int64_t last_peak = -1;
187 int64_t last_peak_number = 0; // for zeroing peaks
188 int64_t *peak_samples;
189 int64_t current_peak = 0, starting_peak;
194 startup_lock.unlock();
196 //printf("Tracking::run 1\n");
202 //printf("Tracking::run 2\n");
204 if(state != PAUSED && state != DONE)
207 if(state != PAUSED && state != DONE)
210 //printf("Tracking::run 3\n");
211 // can be stopped during wait
212 if(get_playback_engine()->tracking_active)
214 // Get position of cursor
215 position = get_tracking_position();
217 //printf("Tracking::run 4 %ld\n", position);
219 update_tracker(position);
221 //printf("Tracking::run 5\n");
225 //printf("Tracking::run 6\n");