2 Copyright (C) 1999 Paul Davis
4 This program is free software; you can redistribute it and/or modify
5 it under the terms of the GNU General Public License as published by
6 the Free Software Foundation; either version 2 of the License, or
7 (at your option) any later version.
9 This program is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 GNU General Public License for more details.
14 You should have received a copy of the GNU General Public License
15 along with this program; if not, write to the Free Software
16 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
20 #include <cstdio> // for sprintf
23 #include <pbd/convert.h>
24 #include <pbd/enumwriter.h>
26 #include <gtkmm2ext/utils.h>
28 #include <ardour/ardour.h>
29 #include <ardour/session.h>
30 #include <ardour/tempo.h>
31 #include <ardour/profile.h>
32 #include <sigc++/bind.h>
34 #include "ardour_ui.h"
35 #include "audio_clock.h"
40 using namespace ARDOUR
;
49 sigc::signal
<void> AudioClock::ModeChanged
;
50 vector
<AudioClock
*> AudioClock::clocks
;
52 const uint32_t AudioClock::field_length
[(int) AudioClock::AudioFrames
+1] = {
54 2, /* SMPTE_Minutes */
55 2, /* SMPTE_Seconds */
66 AudioClock::AudioClock (std::string clock_name
, bool transient
, std::string widget_name
, bool allow_edit
, bool duration
, bool with_info
)
68 is_transient (transient
),
69 is_duration (duration
),
70 editable (allow_edit
),
86 bbt_reference_time
= -1;
89 frames_upper_info_label
= manage (new Label
);
90 frames_lower_info_label
= manage (new Label
);
91 smpte_upper_info_label
= manage (new Label
);
92 smpte_lower_info_label
= manage (new Label
);
93 bbt_upper_info_label
= manage (new Label
);
94 bbt_lower_info_label
= manage (new Label
);
96 frames_upper_info_label
->set_name ("AudioClockFramesUpperInfo");
97 frames_lower_info_label
->set_name ("AudioClockFramesLowerInfo");
98 smpte_upper_info_label
->set_name ("AudioClockSMPTEUpperInfo");
99 smpte_lower_info_label
->set_name ("AudioClockSMPTELowerInfo");
100 bbt_upper_info_label
->set_name ("AudioClockBBTUpperInfo");
101 bbt_lower_info_label
->set_name ("AudioClockBBTLowerInfo");
103 Gtkmm2ext::set_size_request_to_display_given_text(*smpte_upper_info_label
, "23.98",0,0);
104 Gtkmm2ext::set_size_request_to_display_given_text(*smpte_lower_info_label
, "NDF",0,0);
106 Gtkmm2ext::set_size_request_to_display_given_text(*bbt_upper_info_label
, "88|88",0,0);
107 Gtkmm2ext::set_size_request_to_display_given_text(*bbt_lower_info_label
, "888.88",0,0);
109 frames_info_box
.pack_start (*frames_upper_info_label
, true, true);
110 frames_info_box
.pack_start (*frames_lower_info_label
, true, true);
111 smpte_info_box
.pack_start (*smpte_upper_info_label
, true, true);
112 smpte_info_box
.pack_start (*smpte_lower_info_label
, true, true);
113 bbt_info_box
.pack_start (*bbt_upper_info_label
, true, true);
114 bbt_info_box
.pack_start (*bbt_lower_info_label
, true, true);
117 frames_upper_info_label
= 0;
118 frames_lower_info_label
= 0;
119 smpte_upper_info_label
= 0;
120 smpte_lower_info_label
= 0;
121 bbt_upper_info_label
= 0;
122 bbt_lower_info_label
= 0;
125 audio_frames_ebox
.add (audio_frames_label
);
127 frames_packer
.set_homogeneous (false);
128 frames_packer
.set_border_width (2);
129 frames_packer
.pack_start (audio_frames_ebox
, false, false);
132 frames_packer
.pack_start (frames_info_box
, false, false, 5);
135 frames_packer_hbox
.pack_start (frames_packer
, true, false);
137 hours_ebox
.add (hours_label
);
138 minutes_ebox
.add (minutes_label
);
139 seconds_ebox
.add (seconds_label
);
140 frames_ebox
.add (frames_label
);
141 bars_ebox
.add (bars_label
);
142 beats_ebox
.add (beats_label
);
143 ticks_ebox
.add (ticks_label
);
144 ms_hours_ebox
.add (ms_hours_label
);
145 ms_minutes_ebox
.add (ms_minutes_label
);
146 ms_seconds_ebox
.add (ms_seconds_label
);
148 smpte_packer
.set_homogeneous (false);
149 smpte_packer
.set_border_width (2);
150 smpte_packer
.pack_start (hours_ebox
, false, false);
151 smpte_packer
.pack_start (colon1
, false, false);
152 smpte_packer
.pack_start (minutes_ebox
, false, false);
153 smpte_packer
.pack_start (colon2
, false, false);
154 smpte_packer
.pack_start (seconds_ebox
, false, false);
155 smpte_packer
.pack_start (colon3
, false, false);
156 smpte_packer
.pack_start (frames_ebox
, false, false);
159 smpte_packer
.pack_start (smpte_info_box
, false, false, 5);
162 smpte_packer_hbox
.pack_start (smpte_packer
, true, false);
164 bbt_packer
.set_homogeneous (false);
165 bbt_packer
.set_border_width (2);
166 bbt_packer
.pack_start (bars_ebox
, false, false);
167 bbt_packer
.pack_start (b1
, false, false);
168 bbt_packer
.pack_start (beats_ebox
, false, false);
169 bbt_packer
.pack_start (b2
, false, false);
170 bbt_packer
.pack_start (ticks_ebox
, false, false);
173 bbt_packer
.pack_start (bbt_info_box
, false, false, 5);
176 bbt_packer_hbox
.pack_start (bbt_packer
, true, false);
178 minsec_packer
.set_homogeneous (false);
179 minsec_packer
.set_border_width (2);
180 minsec_packer
.pack_start (ms_hours_ebox
, false, false);
181 minsec_packer
.pack_start (colon4
, false, false);
182 minsec_packer
.pack_start (ms_minutes_ebox
, false, false);
183 minsec_packer
.pack_start (colon5
, false, false);
184 minsec_packer
.pack_start (ms_seconds_ebox
, false, false);
186 minsec_packer_hbox
.pack_start (minsec_packer
, true, false);
188 clock_frame
.set_shadow_type (Gtk::SHADOW_IN
);
189 clock_frame
.set_name ("BaseFrame");
191 clock_frame
.add (clock_base
);
193 set_widget_name (widget_name
);
195 _mode
= BBT
; /* lie to force mode switch */
198 pack_start (clock_frame
, true, true);
200 /* the clock base handles button releases for menu popup regardless of
201 editable status. if the clock is editable, the clock base is where
202 we pass focus to after leaving the last editable "field", which
203 will then shutdown editing till the user starts it up again.
205 it does this because the focus out event on the field disables
206 keyboard event handling, and we don't connect anything up to
207 notice focus in on the clock base. hence, keyboard event handling
211 clock_base
.add_events (Gdk::BUTTON_PRESS_MASK
|Gdk::BUTTON_RELEASE_MASK
|Gdk::SCROLL_MASK
);
212 clock_base
.signal_button_release_event().connect (bind (mem_fun (*this, &AudioClock::field_button_release_event
), SMPTE_Hours
));
214 Session::SMPTEOffsetChanged
.connect (mem_fun (*this, &AudioClock::smpte_offset_changed
));
220 set (last_when
, true);
223 clocks
.push_back (this);
228 AudioClock::set_widget_name (string name
)
230 Widget::set_name (name
);
232 clock_base
.set_name (name
);
234 audio_frames_label
.set_name (name
);
235 hours_label
.set_name (name
);
236 minutes_label
.set_name (name
);
237 seconds_label
.set_name (name
);
238 frames_label
.set_name (name
);
239 bars_label
.set_name (name
);
240 beats_label
.set_name (name
);
241 ticks_label
.set_name (name
);
242 ms_hours_label
.set_name (name
);
243 ms_minutes_label
.set_name (name
);
244 ms_seconds_label
.set_name (name
);
245 hours_ebox
.set_name (name
);
246 minutes_ebox
.set_name (name
);
247 seconds_ebox
.set_name (name
);
248 frames_ebox
.set_name (name
);
249 audio_frames_ebox
.set_name (name
);
250 bars_ebox
.set_name (name
);
251 beats_ebox
.set_name (name
);
252 ticks_ebox
.set_name (name
);
253 ms_hours_ebox
.set_name (name
);
254 ms_minutes_ebox
.set_name (name
);
255 ms_seconds_ebox
.set_name (name
);
257 colon1
.set_name (name
);
258 colon2
.set_name (name
);
259 colon3
.set_name (name
);
260 colon4
.set_name (name
);
261 colon5
.set_name (name
);
269 AudioClock::setup_events ()
271 clock_base
.set_flags (Gtk::CAN_FOCUS
);
273 hours_ebox
.add_events (Gdk::BUTTON_PRESS_MASK
|Gdk::BUTTON_RELEASE_MASK
|Gdk::KEY_PRESS_MASK
|Gdk::KEY_RELEASE_MASK
|Gdk::FOCUS_CHANGE_MASK
|Gdk::POINTER_MOTION_MASK
|Gdk::SCROLL_MASK
);
274 minutes_ebox
.add_events (Gdk::BUTTON_PRESS_MASK
|Gdk::BUTTON_RELEASE_MASK
|Gdk::KEY_PRESS_MASK
|Gdk::KEY_RELEASE_MASK
|Gdk::FOCUS_CHANGE_MASK
|Gdk::POINTER_MOTION_MASK
|Gdk::SCROLL_MASK
);
275 seconds_ebox
.add_events (Gdk::BUTTON_PRESS_MASK
|Gdk::BUTTON_RELEASE_MASK
|Gdk::KEY_PRESS_MASK
|Gdk::KEY_RELEASE_MASK
|Gdk::FOCUS_CHANGE_MASK
|Gdk::POINTER_MOTION_MASK
|Gdk::SCROLL_MASK
);
276 frames_ebox
.add_events (Gdk::BUTTON_PRESS_MASK
|Gdk::BUTTON_RELEASE_MASK
|Gdk::KEY_PRESS_MASK
|Gdk::KEY_RELEASE_MASK
|Gdk::FOCUS_CHANGE_MASK
|Gdk::POINTER_MOTION_MASK
|Gdk::SCROLL_MASK
);
277 bars_ebox
.add_events (Gdk::BUTTON_PRESS_MASK
|Gdk::BUTTON_RELEASE_MASK
|Gdk::KEY_PRESS_MASK
|Gdk::KEY_RELEASE_MASK
|Gdk::FOCUS_CHANGE_MASK
|Gdk::POINTER_MOTION_MASK
|Gdk::SCROLL_MASK
);
278 beats_ebox
.add_events (Gdk::BUTTON_PRESS_MASK
|Gdk::BUTTON_RELEASE_MASK
|Gdk::KEY_PRESS_MASK
|Gdk::KEY_RELEASE_MASK
|Gdk::FOCUS_CHANGE_MASK
|Gdk::POINTER_MOTION_MASK
|Gdk::SCROLL_MASK
);
279 ticks_ebox
.add_events (Gdk::BUTTON_PRESS_MASK
|Gdk::BUTTON_RELEASE_MASK
|Gdk::KEY_PRESS_MASK
|Gdk::KEY_RELEASE_MASK
|Gdk::FOCUS_CHANGE_MASK
|Gdk::POINTER_MOTION_MASK
|Gdk::SCROLL_MASK
);
280 ms_hours_ebox
.add_events (Gdk::BUTTON_PRESS_MASK
|Gdk::BUTTON_RELEASE_MASK
|Gdk::KEY_PRESS_MASK
|Gdk::KEY_RELEASE_MASK
|Gdk::FOCUS_CHANGE_MASK
|Gdk::POINTER_MOTION_MASK
|Gdk::SCROLL_MASK
);
281 ms_minutes_ebox
.add_events (Gdk::BUTTON_PRESS_MASK
|Gdk::BUTTON_RELEASE_MASK
|Gdk::KEY_PRESS_MASK
|Gdk::KEY_RELEASE_MASK
|Gdk::FOCUS_CHANGE_MASK
|Gdk::POINTER_MOTION_MASK
|Gdk::SCROLL_MASK
);
282 ms_seconds_ebox
.add_events (Gdk::BUTTON_PRESS_MASK
|Gdk::BUTTON_RELEASE_MASK
|Gdk::KEY_PRESS_MASK
|Gdk::KEY_RELEASE_MASK
|Gdk::FOCUS_CHANGE_MASK
|Gdk::POINTER_MOTION_MASK
|Gdk::SCROLL_MASK
);
283 audio_frames_ebox
.add_events (Gdk::BUTTON_PRESS_MASK
|Gdk::BUTTON_RELEASE_MASK
|Gdk::KEY_PRESS_MASK
|Gdk::KEY_RELEASE_MASK
|Gdk::FOCUS_CHANGE_MASK
|Gdk::POINTER_MOTION_MASK
|Gdk::SCROLL_MASK
);
285 hours_ebox
.set_flags (Gtk::CAN_FOCUS
);
286 minutes_ebox
.set_flags (Gtk::CAN_FOCUS
);
287 seconds_ebox
.set_flags (Gtk::CAN_FOCUS
);
288 frames_ebox
.set_flags (Gtk::CAN_FOCUS
);
289 audio_frames_ebox
.set_flags (Gtk::CAN_FOCUS
);
290 bars_ebox
.set_flags (Gtk::CAN_FOCUS
);
291 beats_ebox
.set_flags (Gtk::CAN_FOCUS
);
292 ticks_ebox
.set_flags (Gtk::CAN_FOCUS
);
293 ms_hours_ebox
.set_flags (Gtk::CAN_FOCUS
);
294 ms_minutes_ebox
.set_flags (Gtk::CAN_FOCUS
);
295 ms_seconds_ebox
.set_flags (Gtk::CAN_FOCUS
);
297 hours_ebox
.signal_motion_notify_event().connect (bind (mem_fun(*this, &AudioClock::field_motion_notify_event
), SMPTE_Hours
));
298 minutes_ebox
.signal_motion_notify_event().connect (bind (mem_fun(*this, &AudioClock::field_motion_notify_event
), SMPTE_Minutes
));
299 seconds_ebox
.signal_motion_notify_event().connect (bind (mem_fun(*this, &AudioClock::field_motion_notify_event
), SMPTE_Seconds
));
300 frames_ebox
.signal_motion_notify_event().connect (bind (mem_fun(*this, &AudioClock::field_motion_notify_event
), SMPTE_Frames
));
301 audio_frames_ebox
.signal_motion_notify_event().connect (bind (mem_fun(*this, &AudioClock::field_motion_notify_event
), AudioFrames
));
302 bars_ebox
.signal_motion_notify_event().connect (bind (mem_fun(*this, &AudioClock::field_motion_notify_event
), Bars
));
303 beats_ebox
.signal_motion_notify_event().connect (bind (mem_fun(*this, &AudioClock::field_motion_notify_event
), Beats
));
304 ticks_ebox
.signal_motion_notify_event().connect (bind (mem_fun(*this, &AudioClock::field_motion_notify_event
), Ticks
));
305 ms_hours_ebox
.signal_motion_notify_event().connect (bind (mem_fun(*this, &AudioClock::field_motion_notify_event
), MS_Hours
));
306 ms_minutes_ebox
.signal_motion_notify_event().connect (bind (mem_fun(*this, &AudioClock::field_motion_notify_event
), MS_Minutes
));
307 ms_seconds_ebox
.signal_motion_notify_event().connect (bind (mem_fun(*this, &AudioClock::field_motion_notify_event
), MS_Seconds
));
309 hours_ebox
.signal_button_press_event().connect (bind (mem_fun(*this, &AudioClock::field_button_press_event
), SMPTE_Hours
));
310 minutes_ebox
.signal_button_press_event().connect (bind (mem_fun(*this, &AudioClock::field_button_press_event
), SMPTE_Minutes
));
311 seconds_ebox
.signal_button_press_event().connect (bind (mem_fun(*this, &AudioClock::field_button_press_event
), SMPTE_Seconds
));
312 frames_ebox
.signal_button_press_event().connect (bind (mem_fun(*this, &AudioClock::field_button_press_event
), SMPTE_Frames
));
313 audio_frames_ebox
.signal_button_press_event().connect (bind (mem_fun(*this, &AudioClock::field_button_press_event
), AudioFrames
));
314 bars_ebox
.signal_button_press_event().connect (bind (mem_fun(*this, &AudioClock::field_button_press_event
), Bars
));
315 beats_ebox
.signal_button_press_event().connect (bind (mem_fun(*this, &AudioClock::field_button_press_event
), Beats
));
316 ticks_ebox
.signal_button_press_event().connect (bind (mem_fun(*this, &AudioClock::field_button_press_event
), Ticks
));
317 ms_hours_ebox
.signal_button_press_event().connect (bind (mem_fun(*this, &AudioClock::field_button_press_event
), MS_Hours
));
318 ms_minutes_ebox
.signal_button_press_event().connect (bind (mem_fun(*this, &AudioClock::field_button_press_event
), MS_Minutes
));
319 ms_seconds_ebox
.signal_button_press_event().connect (bind (mem_fun(*this, &AudioClock::field_button_press_event
), MS_Seconds
));
321 hours_ebox
.signal_button_release_event().connect (bind (mem_fun(*this, &AudioClock::field_button_release_event
), SMPTE_Hours
));
322 minutes_ebox
.signal_button_release_event().connect (bind (mem_fun(*this, &AudioClock::field_button_release_event
), SMPTE_Minutes
));
323 seconds_ebox
.signal_button_release_event().connect (bind (mem_fun(*this, &AudioClock::field_button_release_event
), SMPTE_Seconds
));
324 frames_ebox
.signal_button_release_event().connect (bind (mem_fun(*this, &AudioClock::field_button_release_event
), SMPTE_Frames
));
325 audio_frames_ebox
.signal_button_release_event().connect (bind (mem_fun(*this, &AudioClock::field_button_release_event
), AudioFrames
));
326 bars_ebox
.signal_button_release_event().connect (bind (mem_fun(*this, &AudioClock::field_button_release_event
), Bars
));
327 beats_ebox
.signal_button_release_event().connect (bind (mem_fun(*this, &AudioClock::field_button_release_event
), Beats
));
328 ticks_ebox
.signal_button_release_event().connect (bind (mem_fun(*this, &AudioClock::field_button_release_event
), Ticks
));
329 ms_hours_ebox
.signal_button_release_event().connect (bind (mem_fun(*this, &AudioClock::field_button_release_event
), MS_Hours
));
330 ms_minutes_ebox
.signal_button_release_event().connect (bind (mem_fun(*this, &AudioClock::field_button_release_event
), MS_Minutes
));
331 ms_seconds_ebox
.signal_button_release_event().connect (bind (mem_fun(*this, &AudioClock::field_button_release_event
), MS_Seconds
));
333 hours_ebox
.signal_scroll_event().connect (bind (mem_fun(*this, &AudioClock::field_button_scroll_event
), SMPTE_Hours
));
334 minutes_ebox
.signal_scroll_event().connect (bind (mem_fun(*this, &AudioClock::field_button_scroll_event
), SMPTE_Minutes
));
335 seconds_ebox
.signal_scroll_event().connect (bind (mem_fun(*this, &AudioClock::field_button_scroll_event
), SMPTE_Seconds
));
336 frames_ebox
.signal_scroll_event().connect (bind (mem_fun(*this, &AudioClock::field_button_scroll_event
), SMPTE_Frames
));
337 audio_frames_ebox
.signal_scroll_event().connect (bind (mem_fun(*this, &AudioClock::field_button_scroll_event
), AudioFrames
));
338 bars_ebox
.signal_scroll_event().connect (bind (mem_fun(*this, &AudioClock::field_button_scroll_event
), Bars
));
339 beats_ebox
.signal_scroll_event().connect (bind (mem_fun(*this, &AudioClock::field_button_scroll_event
), Beats
));
340 ticks_ebox
.signal_scroll_event().connect (bind (mem_fun(*this, &AudioClock::field_button_scroll_event
), Ticks
));
341 ms_hours_ebox
.signal_scroll_event().connect (bind (mem_fun(*this, &AudioClock::field_button_scroll_event
), MS_Hours
));
342 ms_minutes_ebox
.signal_scroll_event().connect (bind (mem_fun(*this, &AudioClock::field_button_scroll_event
), MS_Minutes
));
343 ms_seconds_ebox
.signal_scroll_event().connect (bind (mem_fun(*this, &AudioClock::field_button_scroll_event
), MS_Seconds
));
345 hours_ebox
.signal_key_press_event().connect (bind (mem_fun(*this, &AudioClock::field_key_press_event
), SMPTE_Hours
));
346 minutes_ebox
.signal_key_press_event().connect (bind (mem_fun(*this, &AudioClock::field_key_press_event
), SMPTE_Minutes
));
347 seconds_ebox
.signal_key_press_event().connect (bind (mem_fun(*this, &AudioClock::field_key_press_event
), SMPTE_Seconds
));
348 frames_ebox
.signal_key_press_event().connect (bind (mem_fun(*this, &AudioClock::field_key_press_event
), SMPTE_Frames
));
349 audio_frames_ebox
.signal_key_press_event().connect (bind (mem_fun(*this, &AudioClock::field_key_press_event
), AudioFrames
));
350 bars_ebox
.signal_key_press_event().connect (bind (mem_fun(*this, &AudioClock::field_key_press_event
), Bars
));
351 beats_ebox
.signal_key_press_event().connect (bind (mem_fun(*this, &AudioClock::field_key_press_event
), Beats
));
352 ticks_ebox
.signal_key_press_event().connect (bind (mem_fun(*this, &AudioClock::field_key_press_event
), Ticks
));
353 ms_hours_ebox
.signal_key_press_event().connect (bind (mem_fun(*this, &AudioClock::field_key_press_event
), MS_Hours
));
354 ms_minutes_ebox
.signal_key_press_event().connect (bind (mem_fun(*this, &AudioClock::field_key_press_event
), MS_Minutes
));
355 ms_seconds_ebox
.signal_key_press_event().connect (bind (mem_fun(*this, &AudioClock::field_key_press_event
), MS_Seconds
));
357 hours_ebox
.signal_key_release_event().connect (bind (mem_fun(*this, &AudioClock::field_key_release_event
), SMPTE_Hours
));
358 minutes_ebox
.signal_key_release_event().connect (bind (mem_fun(*this, &AudioClock::field_key_release_event
), SMPTE_Minutes
));
359 seconds_ebox
.signal_key_release_event().connect (bind (mem_fun(*this, &AudioClock::field_key_release_event
), SMPTE_Seconds
));
360 frames_ebox
.signal_key_release_event().connect (bind (mem_fun(*this, &AudioClock::field_key_release_event
), SMPTE_Frames
));
361 audio_frames_ebox
.signal_key_release_event().connect (bind (mem_fun(*this, &AudioClock::field_key_release_event
), AudioFrames
));
362 bars_ebox
.signal_key_release_event().connect (bind (mem_fun(*this, &AudioClock::field_key_release_event
), Bars
));
363 beats_ebox
.signal_key_release_event().connect (bind (mem_fun(*this, &AudioClock::field_key_release_event
), Beats
));
364 ticks_ebox
.signal_key_release_event().connect (bind (mem_fun(*this, &AudioClock::field_key_release_event
), Ticks
));
365 ms_hours_ebox
.signal_key_release_event().connect (bind (mem_fun(*this, &AudioClock::field_key_release_event
), MS_Hours
));
366 ms_minutes_ebox
.signal_key_release_event().connect (bind (mem_fun(*this, &AudioClock::field_key_release_event
), MS_Minutes
));
367 ms_seconds_ebox
.signal_key_release_event().connect (bind (mem_fun(*this, &AudioClock::field_key_release_event
), MS_Seconds
));
369 hours_ebox
.signal_focus_in_event().connect (bind (mem_fun(*this, &AudioClock::field_focus_in_event
), SMPTE_Hours
));
370 minutes_ebox
.signal_focus_in_event().connect (bind (mem_fun(*this, &AudioClock::field_focus_in_event
), SMPTE_Minutes
));
371 seconds_ebox
.signal_focus_in_event().connect (bind (mem_fun(*this, &AudioClock::field_focus_in_event
), SMPTE_Seconds
));
372 frames_ebox
.signal_focus_in_event().connect (bind (mem_fun(*this, &AudioClock::field_focus_in_event
), SMPTE_Frames
));
373 audio_frames_ebox
.signal_focus_in_event().connect (bind (mem_fun(*this, &AudioClock::field_focus_in_event
), AudioFrames
));
374 bars_ebox
.signal_focus_in_event().connect (bind (mem_fun(*this, &AudioClock::field_focus_in_event
), Bars
));
375 beats_ebox
.signal_focus_in_event().connect (bind (mem_fun(*this, &AudioClock::field_focus_in_event
), Beats
));
376 ticks_ebox
.signal_focus_in_event().connect (bind (mem_fun(*this, &AudioClock::field_focus_in_event
), Ticks
));
377 ms_hours_ebox
.signal_focus_in_event().connect (bind (mem_fun(*this, &AudioClock::field_focus_in_event
), MS_Hours
));
378 ms_minutes_ebox
.signal_focus_in_event().connect (bind (mem_fun(*this, &AudioClock::field_focus_in_event
), MS_Minutes
));
379 ms_seconds_ebox
.signal_focus_in_event().connect (bind (mem_fun(*this, &AudioClock::field_focus_in_event
), MS_Seconds
));
381 hours_ebox
.signal_focus_out_event().connect (bind (mem_fun(*this, &AudioClock::field_focus_out_event
), SMPTE_Hours
));
382 minutes_ebox
.signal_focus_out_event().connect (bind (mem_fun(*this, &AudioClock::field_focus_out_event
), SMPTE_Minutes
));
383 seconds_ebox
.signal_focus_out_event().connect (bind (mem_fun(*this, &AudioClock::field_focus_out_event
), SMPTE_Seconds
));
384 frames_ebox
.signal_focus_out_event().connect (bind (mem_fun(*this, &AudioClock::field_focus_out_event
), SMPTE_Frames
));
385 audio_frames_ebox
.signal_focus_out_event().connect (bind (mem_fun(*this, &AudioClock::field_focus_out_event
), AudioFrames
));
386 bars_ebox
.signal_focus_out_event().connect (bind (mem_fun(*this, &AudioClock::field_focus_out_event
), Bars
));
387 beats_ebox
.signal_focus_out_event().connect (bind (mem_fun(*this, &AudioClock::field_focus_out_event
), Beats
));
388 ticks_ebox
.signal_focus_out_event().connect (bind (mem_fun(*this, &AudioClock::field_focus_out_event
), Ticks
));
389 ms_hours_ebox
.signal_focus_out_event().connect (bind (mem_fun(*this, &AudioClock::field_focus_out_event
), MS_Hours
));
390 ms_minutes_ebox
.signal_focus_out_event().connect (bind (mem_fun(*this, &AudioClock::field_focus_out_event
), MS_Minutes
));
391 ms_seconds_ebox
.signal_focus_out_event().connect (bind (mem_fun(*this, &AudioClock::field_focus_out_event
), MS_Seconds
));
393 clock_base
.signal_focus_in_event().connect (mem_fun (*this, &AudioClock::drop_focus_handler
));
397 AudioClock::drop_focus_handler (GdkEventFocus
* ignored
)
399 Keyboard::magic_widget_drop_focus ();
404 AudioClock::on_realize ()
408 /* styles are not available until the widgets are bound to a window */
410 set_size_requests ();
414 AudioClock::set (nframes_t when
, bool force
, nframes_t offset
, int which
)
417 if ((!force
&& !is_visible()) || session
== 0) {
421 if (when
== last_when
&& !offset
&& !force
) {
425 bool pdelta
= Config
->get_primary_clock_delta_edit_cursor();
426 bool sdelta
= Config
->get_secondary_clock_delta_edit_cursor();
428 if (offset
&& which
== 1 && pdelta
) {
429 when
= (when
> offset
) ? when
- offset
: offset
- when
;
430 } else if (offset
&& which
== 2 && sdelta
) {
431 when
= (when
> offset
) ? when
- offset
: offset
- when
;
434 if (which
== 1 && pdelta
&& !last_pdelta
) {
435 set_widget_name("TransportClockDisplayDelta");
437 } else if (which
== 1 && !pdelta
&& last_pdelta
) {
438 set_widget_name("TransportClockDisplay");
440 } else if (which
== 2 && sdelta
&& !last_sdelta
) {
441 set_widget_name("SecondaryClockDisplayDelta");
443 } else if (which
== 2 && !sdelta
&& last_sdelta
) {
444 set_widget_name("SecondaryClockDisplay");
450 set_smpte (when
, force
);
454 set_bbt (when
, force
);
458 set_minsec (when
, force
);
462 set_frames (when
, force
);
473 AudioClock::smpte_offset_changed ()
480 current
= current_duration();
482 current
= current_time ();
492 AudioClock::set_frames (nframes_t when
, bool force
)
495 snprintf (buf
, sizeof (buf
), "%u", when
);
496 audio_frames_label
.set_text (buf
);
498 if (frames_upper_info_label
) {
499 nframes_t rate
= session
->frame_rate();
501 if (fmod (rate
, 1000.0) == 0.000) {
502 sprintf (buf
, "%uK", rate
/1000);
504 sprintf (buf
, "%.3fK", rate
/1000.0f
);
507 if (frames_upper_info_label
->get_text() != buf
) {
508 frames_upper_info_label
->set_text (buf
);
511 float vid_pullup
= Config
->get_video_pullup();
513 if (vid_pullup
== 0.0) {
514 if (frames_lower_info_label
->get_text () != _("none")) {
515 frames_lower_info_label
->set_text(_("none"));
518 sprintf (buf
, "%-6.4f", vid_pullup
);
519 if (frames_lower_info_label
->get_text() != buf
) {
520 frames_lower_info_label
->set_text (buf
);
527 AudioClock::set_minsec (nframes_t when
, bool force
)
536 hrs
= (int) floor (left
/ (session
->frame_rate() * 60.0f
* 60.0f
));
537 left
-= (nframes_t
) floor (hrs
* session
->frame_rate() * 60.0f
* 60.0f
);
538 mins
= (int) floor (left
/ (session
->frame_rate() * 60.0f
));
539 left
-= (nframes_t
) floor (mins
* session
->frame_rate() * 60.0f
);
540 secs
= left
/ (float) session
->frame_rate();
542 if (force
|| hrs
!= ms_last_hrs
) {
543 sprintf (buf
, "%02d", hrs
);
544 ms_hours_label
.set_text (buf
);
548 if (force
|| mins
!= ms_last_mins
) {
549 sprintf (buf
, "%02d", mins
);
550 ms_minutes_label
.set_text (buf
);
554 if (force
|| secs
!= ms_last_secs
) {
555 sprintf (buf
, "%06.3f", secs
);
556 ms_seconds_label
.set_text (buf
);
562 AudioClock::set_smpte (nframes_t when
, bool force
)
568 session
->smpte_duration (when
, smpte
);
570 session
->smpte_time (when
, smpte
);
573 if (force
|| smpte
.hours
!= last_hrs
|| smpte
.negative
!= last_negative
) {
574 if (smpte
.negative
) {
575 sprintf (buf
, "-%02" PRIu32
, smpte
.hours
);
577 sprintf (buf
, " %02" PRIu32
, smpte
.hours
);
579 hours_label
.set_text (buf
);
580 last_hrs
= smpte
.hours
;
581 last_negative
= smpte
.negative
;
584 if (force
|| smpte
.minutes
!= last_mins
) {
585 sprintf (buf
, "%02" PRIu32
, smpte
.minutes
);
586 minutes_label
.set_text (buf
);
587 last_mins
= smpte
.minutes
;
590 if (force
|| smpte
.seconds
!= last_secs
) {
591 sprintf (buf
, "%02" PRIu32
, smpte
.seconds
);
592 seconds_label
.set_text (buf
);
593 last_secs
= smpte
.seconds
;
596 if (force
|| smpte
.frames
!= last_frames
) {
597 sprintf (buf
, "%02" PRIu32
, smpte
.frames
);
598 frames_label
.set_text (buf
);
599 last_frames
= smpte
.frames
;
602 if (smpte_upper_info_label
) {
603 double smpte_frames
= session
->smpte_frames_per_second();
605 if ( fmod(smpte_frames
, 1.0) == 0.0) {
606 sprintf (buf
, "%u", int (smpte_frames
));
608 sprintf (buf
, "%.2f", smpte_frames
);
611 if (smpte_upper_info_label
->get_text() != buf
) {
612 smpte_upper_info_label
->set_text (buf
);
615 if ((fabs(smpte_frames
- 29.97) < 0.0001) || smpte_frames
== 30) {
616 if (session
->smpte_drop_frames()) {
619 sprintf (buf
, "NDF");
622 // there is no drop frame alternative
626 if (smpte_lower_info_label
->get_text() != buf
) {
627 smpte_lower_info_label
->set_text (buf
);
633 AudioClock::set_bbt (nframes_t when
, bool force
)
638 /* handle a common case */
645 session
->tempo_map().bbt_time (when
, bbt
);
650 session
->tempo_map().bbt_time (when
, bbt
);
653 sprintf (buf
, "%03" PRIu32
, bbt
.bars
);
654 if (force
|| bars_label
.get_text () != buf
) {
655 bars_label
.set_text (buf
);
657 sprintf (buf
, "%02" PRIu32
, bbt
.beats
);
658 if (force
|| beats_label
.get_text () != buf
) {
659 beats_label
.set_text (buf
);
661 sprintf (buf
, "%04" PRIu32
, bbt
.ticks
);
662 if (force
|| ticks_label
.get_text () != buf
) {
663 ticks_label
.set_text (buf
);
666 if (bbt_upper_info_label
) {
669 if (bbt_reference_time
< 0) {
672 pos
= bbt_reference_time
;
675 TempoMap::Metric
m (session
->tempo_map().metric_at (pos
));
677 sprintf (buf
, "%-5.2f", m
.tempo().beats_per_minute());
678 if (bbt_lower_info_label
->get_text() != buf
) {
679 bbt_lower_info_label
->set_text (buf
);
681 sprintf (buf
, "%g|%g", m
.meter().beats_per_bar(), m
.meter().note_divisor());
682 if (bbt_upper_info_label
->get_text() != buf
) {
683 bbt_upper_info_label
->set_text (buf
);
689 AudioClock::set_session (Session
*s
)
696 XMLNode
* node
= session
->extra_xml (X_("ClockModes"));
697 AudioClock::Mode amode
;
700 if ((prop
= node
->property (_name
)) != 0) {
701 amode
= AudioClock::Mode (string_2_enum (prop
->value(), amode
));
706 set (last_when
, true);
715 hours_ebox
.grab_focus ();
719 bars_ebox
.grab_focus ();
723 ms_hours_ebox
.grab_focus ();
727 frames_ebox
.grab_focus ();
737 AudioClock::field_key_press_event (GdkEventKey
*ev
, Field field
)
739 /* all key activity is handled on key release */
744 AudioClock::field_key_release_event (GdkEventKey
*ev
, Field field
)
749 bool move_on
= false;
753 label
= &hours_label
;
756 label
= &minutes_label
;
759 label
= &seconds_label
;
762 label
= &frames_label
;
766 label
= &audio_frames_label
;
770 label
= &ms_hours_label
;
773 label
= &ms_minutes_label
;
776 label
= &ms_seconds_label
;
783 label
= &beats_label
;
786 label
= &ticks_label
;
792 switch (ev
->keyval
) {
836 if (_mode
== MinSec
&& field
== MS_Seconds
) {
851 clock_base
.grab_focus ();
852 ChangeAborted(); /* EMIT SIGNAL */
861 if (key_entry_state
== 0) {
863 /* initialize with a fresh new string */
865 if (field
!= AudioFrames
) {
866 for (uint32_t xn
= 0; xn
< field_length
[field
] - 1; ++xn
) {
875 string existing
= label
->get_text();
876 if (existing
.length() >= field_length
[field
]) {
877 new_text
= existing
.substr (1, field_length
[field
] - 1);
879 new_text
= existing
.substr (0, field_length
[field
] - 1);
883 new_text
+= new_char
;
884 label
->set_text (new_text
);
888 if (key_entry_state
== field_length
[field
]) {
894 if (key_entry_state
) {
901 // Check SMPTE fields for sanity (may also adjust fields)
902 smpte_sanitize_display();
907 // Bars should never be, unless this clock is for a duration
908 if (atoi(bars_label
.get_text()) == 0 && !is_duration
) {
909 bars_label
.set_text("001");
911 // beats should never be 0, unless this clock is for a duration
912 if (atoi(beats_label
.get_text()) == 0 && !is_duration
) {
913 beats_label
.set_text("01");
920 ValueChanged(); /* EMIT_SIGNAL */
923 /* move on to the next field.
931 minutes_ebox
.grab_focus ();
934 seconds_ebox
.grab_focus ();
937 frames_ebox
.grab_focus ();
940 clock_base
.grab_focus ();
945 clock_base
.grab_focus ();
951 ms_minutes_ebox
.grab_focus ();
954 ms_seconds_ebox
.grab_focus ();
957 clock_base
.grab_focus ();
963 beats_ebox
.grab_focus ();
966 ticks_ebox
.grab_focus ();
969 clock_base
.grab_focus ();
978 //if user hit Enter, lose focus
979 switch (ev
->keyval
) {
982 clock_base
.grab_focus ();
989 AudioClock::field_focus_in_event (GdkEventFocus
*ev
, Field field
)
993 Keyboard::magic_widget_grab_focus ();
997 hours_ebox
.set_flags (Gtk::HAS_FOCUS
);
998 hours_ebox
.set_state (Gtk::STATE_ACTIVE
);
1001 minutes_ebox
.set_flags (Gtk::HAS_FOCUS
);
1002 minutes_ebox
.set_state (Gtk::STATE_ACTIVE
);
1005 seconds_ebox
.set_flags (Gtk::HAS_FOCUS
);
1006 seconds_ebox
.set_state (Gtk::STATE_ACTIVE
);
1009 frames_ebox
.set_flags (Gtk::HAS_FOCUS
);
1010 frames_ebox
.set_state (Gtk::STATE_ACTIVE
);
1014 audio_frames_ebox
.set_flags (Gtk::HAS_FOCUS
);
1015 audio_frames_ebox
.set_state (Gtk::STATE_ACTIVE
);
1019 ms_hours_ebox
.set_flags (Gtk::HAS_FOCUS
);
1020 ms_hours_ebox
.set_state (Gtk::STATE_ACTIVE
);
1023 ms_minutes_ebox
.set_flags (Gtk::HAS_FOCUS
);
1024 ms_minutes_ebox
.set_state (Gtk::STATE_ACTIVE
);
1027 ms_seconds_ebox
.set_flags (Gtk::HAS_FOCUS
);
1028 ms_seconds_ebox
.set_state (Gtk::STATE_ACTIVE
);
1031 bars_ebox
.set_flags (Gtk::HAS_FOCUS
);
1032 bars_ebox
.set_state (Gtk::STATE_ACTIVE
);
1035 beats_ebox
.set_flags (Gtk::HAS_FOCUS
);
1036 beats_ebox
.set_state (Gtk::STATE_ACTIVE
);
1039 ticks_ebox
.set_flags (Gtk::HAS_FOCUS
);
1040 ticks_ebox
.set_state (Gtk::STATE_ACTIVE
);
1048 AudioClock::field_focus_out_event (GdkEventFocus
*ev
, Field field
)
1053 hours_ebox
.unset_flags (Gtk::HAS_FOCUS
);
1054 hours_ebox
.set_state (Gtk::STATE_NORMAL
);
1057 minutes_ebox
.unset_flags (Gtk::HAS_FOCUS
);
1058 minutes_ebox
.set_state (Gtk::STATE_NORMAL
);
1061 seconds_ebox
.unset_flags (Gtk::HAS_FOCUS
);
1062 seconds_ebox
.set_state (Gtk::STATE_NORMAL
);
1065 frames_ebox
.unset_flags (Gtk::HAS_FOCUS
);
1066 frames_ebox
.set_state (Gtk::STATE_NORMAL
);
1070 audio_frames_ebox
.unset_flags (Gtk::HAS_FOCUS
);
1071 audio_frames_ebox
.set_state (Gtk::STATE_NORMAL
);
1075 ms_hours_ebox
.unset_flags (Gtk::HAS_FOCUS
);
1076 ms_hours_ebox
.set_state (Gtk::STATE_NORMAL
);
1079 ms_minutes_ebox
.unset_flags (Gtk::HAS_FOCUS
);
1080 ms_minutes_ebox
.set_state (Gtk::STATE_NORMAL
);
1083 ms_seconds_ebox
.unset_flags (Gtk::HAS_FOCUS
);
1084 ms_seconds_ebox
.set_state (Gtk::STATE_NORMAL
);
1088 bars_ebox
.unset_flags (Gtk::HAS_FOCUS
);
1089 bars_ebox
.set_state (Gtk::STATE_NORMAL
);
1092 beats_ebox
.unset_flags (Gtk::HAS_FOCUS
);
1093 beats_ebox
.set_state (Gtk::STATE_NORMAL
);
1096 ticks_ebox
.unset_flags (Gtk::HAS_FOCUS
);
1097 ticks_ebox
.set_state (Gtk::STATE_NORMAL
);
1101 Keyboard::magic_widget_drop_focus ();
1107 AudioClock::field_button_release_event (GdkEventButton
*ev
, Field field
)
1110 gdk_pointer_ungrab (GDK_CURRENT_TIME
);
1112 if (ev
->y
> drag_start_y
+1 || ev
->y
< drag_start_y
-1 || Keyboard::modifier_state_equals (ev
->state
, Keyboard::TertiaryModifier
)){
1113 // we actually dragged so return without setting editing focus, or we shift clicked
1119 if (ops_menu
== 0) {
1122 ops_menu
->popup (1, ev
->time
);
1126 if (Keyboard::is_context_menu_event (ev
)) {
1127 if (ops_menu
== 0) {
1130 ops_menu
->popup (1, ev
->time
);
1134 switch (ev
->button
) {
1138 hours_ebox
.grab_focus();
1141 minutes_ebox
.grab_focus();
1144 seconds_ebox
.grab_focus();
1147 frames_ebox
.grab_focus();
1151 audio_frames_ebox
.grab_focus();
1155 ms_hours_ebox
.grab_focus();
1158 ms_minutes_ebox
.grab_focus();
1161 ms_seconds_ebox
.grab_focus();
1165 bars_ebox
.grab_focus ();
1168 beats_ebox
.grab_focus ();
1171 ticks_ebox
.grab_focus ();
1184 AudioClock::field_button_press_event (GdkEventButton
*ev
, Field field
)
1186 if (session
== 0) return false;
1188 nframes_t frames
= 0;
1190 switch (ev
->button
) {
1192 if (Keyboard::modifier_state_equals (ev
->state
, Keyboard::TertiaryModifier
)) {
1194 ValueChanged (); /* EMIT_SIGNAL */
1197 /* make absolutely sure that the pointer is grabbed */
1198 gdk_pointer_grab(ev
->window
,false ,
1199 GdkEventMask( Gdk::POINTER_MOTION_MASK
| Gdk::BUTTON_PRESS_MASK
|Gdk::BUTTON_RELEASE_MASK
),
1200 NULL
,NULL
,ev
->time
);
1203 drag_start_y
= ev
->y
;
1208 if (Keyboard::modifier_state_equals (ev
->state
, Keyboard::TertiaryModifier
)) {
1210 ValueChanged (); /* EMIT_SIGNAL */
1215 /* used for context sensitive menu */
1228 AudioClock::field_button_scroll_event (GdkEventScroll
*ev
, Field field
)
1234 nframes_t frames
= 0;
1236 switch (ev
->direction
) {
1239 frames
= get_frames (field
);
1241 if (Keyboard::modifier_state_equals (ev
->state
, Keyboard::PrimaryModifier
)) {
1244 set (current_time() + frames
, true);
1245 ValueChanged (); /* EMIT_SIGNAL */
1249 case GDK_SCROLL_DOWN
:
1250 frames
= get_frames (field
);
1252 if (Keyboard::modifier_state_equals (ev
->state
, Keyboard::PrimaryModifier
)) {
1256 if ((double)current_time() - (double)frames
< 0.0) {
1259 set (current_time() - frames
, true);
1262 ValueChanged (); /* EMIT_SIGNAL */
1275 AudioClock::field_motion_notify_event (GdkEventMotion
*ev
, Field field
)
1277 if (session
== 0 || !dragging
) {
1281 float pixel_frame_scale_factor
= 0.2f
;
1284 if (Keyboard::modifier_state_equals (ev->state, Keyboard::PrimaryModifier)) {
1285 pixel_frame_scale_factor = 0.1f;
1289 if (Keyboard::modifier_state_contains (ev->state,
1290 Keyboard::PrimaryModifier|Keyboard::SecondaryModifier)) {
1292 pixel_frame_scale_factor = 0.025f;
1295 double y_delta
= ev
->y
- drag_y
;
1297 drag_accum
+= y_delta
*pixel_frame_scale_factor
;
1301 if (trunc(drag_accum
) != 0) {
1306 dir
= (drag_accum
< 0 ? 1:-1);
1307 pos
= current_time();
1308 frames
= get_frames (field
,pos
,dir
);
1310 if (frames
!= 0 && frames
* drag_accum
< current_time()) {
1312 set ((nframes_t
) floor (pos
- drag_accum
* frames
), false); // minus because up is negative in computer-land
1320 ValueChanged(); /* EMIT_SIGNAL */
1329 AudioClock::get_frames (Field field
,nframes_t pos
,int dir
)
1332 nframes_t frames
= 0;
1336 frames
= (nframes_t
) floor (3600.0 * session
->frame_rate());
1339 frames
= (nframes_t
) floor (60.0 * session
->frame_rate());
1342 frames
= session
->frame_rate();
1345 frames
= (nframes_t
) floor (session
->frame_rate() / session
->smpte_frames_per_second());
1353 frames
= (nframes_t
) floor (3600.0 * session
->frame_rate());
1356 frames
= (nframes_t
) floor (60.0 * session
->frame_rate());
1359 frames
= session
->frame_rate();
1366 frames
= session
->tempo_map().bbt_duration_at(pos
,bbt
,dir
);
1372 frames
= session
->tempo_map().bbt_duration_at(pos
,bbt
,dir
);
1378 frames
= session
->tempo_map().bbt_duration_at(pos
,bbt
,dir
);
1386 AudioClock::current_time (nframes_t pos
) const
1392 ret
= smpte_frame_from_display ();
1395 ret
= bbt_frame_from_display (pos
);
1399 ret
= minsec_frame_from_display ();
1403 ret
= audio_frame_from_display ();
1414 AudioClock::current_duration (nframes_t pos
) const
1420 ret
= smpte_frame_from_display ();
1423 ret
= bbt_frame_duration_from_display (pos
);
1427 ret
= minsec_frame_from_display ();
1431 ret
= audio_frame_from_display ();
1442 AudioClock::smpte_sanitize_display()
1444 // Check SMPTE fields for sanity, possibly adjusting values
1445 if (atoi(minutes_label
.get_text()) > 59) {
1446 minutes_label
.set_text("59");
1449 if (atoi(seconds_label
.get_text()) > 59) {
1450 seconds_label
.set_text("59");
1453 switch ((long)rint(session
->smpte_frames_per_second())) {
1455 if (atoi(frames_label
.get_text()) > 23) {
1456 frames_label
.set_text("23");
1460 if (atoi(frames_label
.get_text()) > 24) {
1461 frames_label
.set_text("24");
1465 if (atoi(frames_label
.get_text()) > 29) {
1466 frames_label
.set_text("29");
1473 if (session
->smpte_drop_frames()) {
1474 if ((atoi(minutes_label
.get_text()) % 10) && (atoi(seconds_label
.get_text()) == 0) && (atoi(frames_label
.get_text()) < 2)) {
1475 frames_label
.set_text("02");
1481 AudioClock::smpte_frame_from_display () const
1490 smpte
.hours
= atoi (hours_label
.get_text());
1491 smpte
.minutes
= atoi (minutes_label
.get_text());
1492 smpte
.seconds
= atoi (seconds_label
.get_text());
1493 smpte
.frames
= atoi (frames_label
.get_text());
1494 smpte
.rate
= session
->smpte_frames_per_second();
1495 smpte
.drop
= session
->smpte_drop_frames();
1497 session
->smpte_to_sample( smpte
, sample
, false /* use_offset */, false /* use_subframes */ );
1501 #define SMPTE_SAMPLE_TEST_1
1502 #define SMPTE_SAMPLE_TEST_2
1503 #define SMPTE_SAMPLE_TEST_3
1504 #define SMPTE_SAMPLE_TEST_4
1505 #define SMPTE_SAMPLE_TEST_5
1506 #define SMPTE_SAMPLE_TEST_6
1507 #define SMPTE_SAMPLE_TEST_7
1509 // Testcode for smpte<->sample conversions (P.S.)
1512 nframes_t oldsample
= 0;
1514 nframes_t sample_increment
;
1516 sample_increment
= (long)rint(session
->frame_rate() / session
->smpte_frames_per_second
);
1518 #ifdef SMPTE_SAMPLE_TEST_1
1519 // Test 1: use_offset = false, use_subframes = false
1520 cout
<< "use_offset = false, use_subframes = false" << endl
;
1521 for (int i
= 0; i
< 108003; i
++) {
1522 session
->smpte_to_sample( smpte1
, sample1
, false /* use_offset */, false /* use_subframes */ );
1523 session
->sample_to_smpte( sample1
, smpte2
, false /* use_offset */, false /* use_subframes */ );
1525 if ((i
> 0) && ( ((sample1
- oldsample
) != sample_increment
) && ((sample1
- oldsample
) != (sample_increment
+ 1)) && ((sample1
- oldsample
) != (sample_increment
- 1)))) {
1526 cout
<< "ERROR: sample increment not right: " << (sample1
- oldsample
) << " != " << sample_increment
<< endl
;
1527 cout
<< "smpte1: " << smpte1
.hours
<< ":" << smpte1
.minutes
<< ":" << smpte1
.seconds
<< ":" << smpte1
.frames
<< "::" << smpte1
.subframes
<< " -> ";
1528 cout
<< "sample: " << sample1
<< endl
;
1529 cout
<< "sample: " << sample1
<< " -> ";
1530 cout
<< "smpte2: " << smpte2
.hours
<< ":" << smpte2
.minutes
<< ":" << smpte2
.seconds
<< ":" << smpte2
.frames
<< "::" << smpte2
.subframes
<< endl
;
1534 if (smpte2
.hours
!= smpte1
.hours
|| smpte2
.minutes
!= smpte1
.minutes
|| smpte2
.seconds
!= smpte2
.seconds
|| smpte2
.frames
!= smpte1
.frames
) {
1535 cout
<< "ERROR: smpte2 not equal smpte1" << endl
;
1536 cout
<< "smpte1: " << smpte1
.hours
<< ":" << smpte1
.minutes
<< ":" << smpte1
.seconds
<< ":" << smpte1
.frames
<< "::" << smpte1
.subframes
<< " -> ";
1537 cout
<< "sample: " << sample1
<< endl
;
1538 cout
<< "sample: " << sample1
<< " -> ";
1539 cout
<< "smpte2: " << smpte2
.hours
<< ":" << smpte2
.minutes
<< ":" << smpte2
.seconds
<< ":" << smpte2
.frames
<< "::" << smpte2
.subframes
<< endl
;
1542 oldsample
= sample1
;
1543 session
->smpte_increment( smpte1
);
1546 cout
<< "sample_increment: " << sample_increment
<< endl
;
1547 cout
<< "sample: " << sample1
<< " -> ";
1548 cout
<< "smpte: " << smpte2
.hours
<< ":" << smpte2
.minutes
<< ":" << smpte2
.seconds
<< ":" << smpte2
.frames
<< "::" << smpte2
.subframes
<< endl
;
1551 #ifdef SMPTE_SAMPLE_TEST_2
1552 // Test 2: use_offset = true, use_subframes = false
1553 cout
<< "use_offset = true, use_subframes = false" << endl
;
1559 smpte1
.subframes
= 0;
1560 sample1
= oldsample
= 0;
1562 session
->sample_to_smpte( sample1
, smpte1
, true /* use_offset */, false /* use_subframes */ );
1563 cout
<< "Starting at sample: " << sample1
<< " -> ";
1564 cout
<< "smpte: " << (smpte1
.negative
? "-" : "") << smpte1
.hours
<< ":" << smpte1
.minutes
<< ":" << smpte1
.seconds
<< ":" << smpte1
.frames
<< "::" << smpte1
.subframes
<< endl
;
1566 for (int i
= 0; i
< 108003; i
++) {
1567 session
->smpte_to_sample( smpte1
, sample1
, true /* use_offset */, false /* use_subframes */ );
1568 session
->sample_to_smpte( sample1
, smpte2
, true /* use_offset */, false /* use_subframes */ );
1570 // cout << "smpte: " << (smpte1.negative ? "-" : "") << smpte1.hours << ":" << smpte1.minutes << ":" << smpte1.seconds << ":" << smpte1.frames << "::" << smpte1.subframes << " -> ";
1571 // cout << "sample: " << sample1 << endl;
1572 // cout << "sample: " << sample1 << " -> ";
1573 // cout << "smpte: " << (smpte2.negative ? "-" : "") << smpte2.hours << ":" << smpte2.minutes << ":" << smpte2.seconds << ":" << smpte2.frames << "::" << smpte2.subframes << endl;
1575 if ((i
> 0) && ( ((sample1
- oldsample
) != sample_increment
) && ((sample1
- oldsample
) != (sample_increment
+ 1)) && ((sample1
- oldsample
) != (sample_increment
- 1)))) {
1576 cout
<< "ERROR: sample increment not right: " << (sample1
- oldsample
) << " != " << sample_increment
<< endl
;
1577 cout
<< "smpte1: " << (smpte1
.negative
? "-" : "") << smpte1
.hours
<< ":" << smpte1
.minutes
<< ":" << smpte1
.seconds
<< ":" << smpte1
.frames
<< "::" << smpte1
.subframes
<< " -> ";
1578 cout
<< "sample: " << sample1
<< endl
;
1579 cout
<< "sample: " << sample1
<< " -> ";
1580 cout
<< "smpte2: " << (smpte2
.negative
? "-" : "") << smpte2
.hours
<< ":" << smpte2
.minutes
<< ":" << smpte2
.seconds
<< ":" << smpte2
.frames
<< "::" << smpte2
.subframes
<< endl
;
1584 if (smpte2
.hours
!= smpte1
.hours
|| smpte2
.minutes
!= smpte1
.minutes
|| smpte2
.seconds
!= smpte2
.seconds
|| smpte2
.frames
!= smpte1
.frames
) {
1585 cout
<< "ERROR: smpte2 not equal smpte1" << endl
;
1586 cout
<< "smpte1: " << (smpte1
.negative
? "-" : "") << smpte1
.hours
<< ":" << smpte1
.minutes
<< ":" << smpte1
.seconds
<< ":" << smpte1
.frames
<< "::" << smpte1
.subframes
<< " -> ";
1587 cout
<< "sample: " << sample1
<< endl
;
1588 cout
<< "sample: " << sample1
<< " -> ";
1589 cout
<< "smpte2: " << (smpte2
.negative
? "-" : "") << smpte2
.hours
<< ":" << smpte2
.minutes
<< ":" << smpte2
.seconds
<< ":" << smpte2
.frames
<< "::" << smpte2
.subframes
<< endl
;
1592 oldsample
= sample1
;
1593 session
->smpte_increment( smpte1
);
1596 cout
<< "sample_increment: " << sample_increment
<< endl
;
1597 cout
<< "sample: " << sample1
<< " -> ";
1598 cout
<< "smpte: " << (smpte2
.negative
? "-" : "") << smpte2
.hours
<< ":" << smpte2
.minutes
<< ":" << smpte2
.seconds
<< ":" << smpte2
.frames
<< "::" << smpte2
.subframes
<< endl
;
1601 #ifdef SMPTE_SAMPLE_TEST_3
1602 // Test 3: use_offset = true, use_subframes = false, decrement
1603 cout
<< "use_offset = true, use_subframes = false, decrement" << endl
;
1605 session
->sample_to_smpte( sample1
, smpte1
, true /* use_offset */, false /* use_subframes */ );
1606 cout
<< "Starting at sample: " << sample1
<< " -> ";
1607 cout
<< "smpte: " << (smpte1
.negative
? "-" : "") << smpte1
.hours
<< ":" << smpte1
.minutes
<< ":" << smpte1
.seconds
<< ":" << smpte1
.frames
<< "::" << smpte1
.subframes
<< endl
;
1609 for (int i
= 0; i
< 108003; i
++) {
1610 session
->smpte_to_sample( smpte1
, sample1
, true /* use_offset */, false /* use_subframes */ );
1611 session
->sample_to_smpte( sample1
, smpte2
, true /* use_offset */, false /* use_subframes */ );
1613 // cout << "smpte: " << (smpte1.negative ? "-" : "") << smpte1.hours << ":" << smpte1.minutes << ":" << smpte1.seconds << ":" << smpte1.frames << "::" << smpte1.subframes << " -> ";
1614 // cout << "sample: " << sample1 << endl;
1615 // cout << "sample: " << sample1 << " -> ";
1616 // cout << "smpte: " << (smpte2.negative ? "-" : "") << smpte2.hours << ":" << smpte2.minutes << ":" << smpte2.seconds << ":" << smpte2.frames << "::" << smpte2.subframes << endl;
1618 if ((i
> 0) && ( ((oldsample
- sample1
) != sample_increment
) && ((oldsample
- sample1
) != (sample_increment
+ 1)) && ((oldsample
- sample1
) != (sample_increment
- 1)))) {
1619 cout
<< "ERROR: sample increment not right: " << (oldsample
- sample1
) << " != " << sample_increment
<< endl
;
1620 cout
<< "smpte1: " << (smpte1
.negative
? "-" : "") << smpte1
.hours
<< ":" << smpte1
.minutes
<< ":" << smpte1
.seconds
<< ":" << smpte1
.frames
<< "::" << smpte1
.subframes
<< " -> ";
1621 cout
<< "sample: " << sample1
<< endl
;
1622 cout
<< "sample: " << sample1
<< " -> ";
1623 cout
<< "smpte2: " << (smpte2
.negative
? "-" : "") << smpte2
.hours
<< ":" << smpte2
.minutes
<< ":" << smpte2
.seconds
<< ":" << smpte2
.frames
<< "::" << smpte2
.subframes
<< endl
;
1627 if (smpte2
.hours
!= smpte1
.hours
|| smpte2
.minutes
!= smpte1
.minutes
|| smpte2
.seconds
!= smpte2
.seconds
|| smpte2
.frames
!= smpte1
.frames
) {
1628 cout
<< "ERROR: smpte2 not equal smpte1" << endl
;
1629 cout
<< "smpte1: " << (smpte1
.negative
? "-" : "") << smpte1
.hours
<< ":" << smpte1
.minutes
<< ":" << smpte1
.seconds
<< ":" << smpte1
.frames
<< "::" << smpte1
.subframes
<< " -> ";
1630 cout
<< "sample: " << sample1
<< endl
;
1631 cout
<< "sample: " << sample1
<< " -> ";
1632 cout
<< "smpte2: " << (smpte2
.negative
? "-" : "") << smpte2
.hours
<< ":" << smpte2
.minutes
<< ":" << smpte2
.seconds
<< ":" << smpte2
.frames
<< "::" << smpte2
.subframes
<< endl
;
1635 oldsample
= sample1
;
1636 session
->smpte_decrement( smpte1
);
1639 cout
<< "sample_decrement: " << sample_increment
<< endl
;
1640 cout
<< "sample: " << sample1
<< " -> ";
1641 cout
<< "smpte: " << (smpte2
.negative
? "-" : "") << smpte2
.hours
<< ":" << smpte2
.minutes
<< ":" << smpte2
.seconds
<< ":" << smpte2
.frames
<< "::" << smpte2
.subframes
<< endl
;
1645 #ifdef SMPTE_SAMPLE_TEST_4
1646 // Test 4: use_offset = true, use_subframes = true
1647 cout
<< "use_offset = true, use_subframes = true" << endl
;
1649 for (long sub
= 5; sub
< 80; sub
+= 5) {
1654 smpte1
.subframes
= 0;
1655 sample1
= oldsample
= (sample_increment
* sub
) / 80;
1657 session
->sample_to_smpte( sample1
, smpte1
, true /* use_offset */, true /* use_subframes */ );
1659 cout
<< "starting at sample: " << sample1
<< " -> ";
1660 cout
<< "smpte: " << (smpte1
.negative
? "-" : "") << smpte1
.hours
<< ":" << smpte1
.minutes
<< ":" << smpte1
.seconds
<< ":" << smpte1
.frames
<< "::" << smpte1
.subframes
<< endl
;
1662 for (int i
= 0; i
< 108003; i
++) {
1663 session
->smpte_to_sample( smpte1
, sample1
, true /* use_offset */, true /* use_subframes */ );
1664 session
->sample_to_smpte( sample1
, smpte2
, true /* use_offset */, true /* use_subframes */ );
1666 if ((i
> 0) && ( ((sample1
- oldsample
) != sample_increment
) && ((sample1
- oldsample
) != (sample_increment
+ 1)) && ((sample1
- oldsample
) != (sample_increment
- 1)))) {
1667 cout
<< "ERROR: sample increment not right: " << (sample1
- oldsample
) << " != " << sample_increment
<< endl
;
1668 cout
<< "smpte1: " << (smpte1
.negative
? "-" : "") << smpte1
.hours
<< ":" << smpte1
.minutes
<< ":" << smpte1
.seconds
<< ":" << smpte1
.frames
<< "::" << smpte1
.subframes
<< " -> ";
1669 cout
<< "sample: " << sample1
<< endl
;
1670 cout
<< "sample: " << sample1
<< " -> ";
1671 cout
<< "smpte2: " << (smpte2
.negative
? "-" : "") << smpte2
.hours
<< ":" << smpte2
.minutes
<< ":" << smpte2
.seconds
<< ":" << smpte2
.frames
<< "::" << smpte2
.subframes
<< endl
;
1675 if (smpte2
.hours
!= smpte1
.hours
|| smpte2
.minutes
!= smpte1
.minutes
|| smpte2
.seconds
!= smpte2
.seconds
|| smpte2
.frames
!= smpte1
.frames
|| smpte2
.subframes
!= smpte1
.subframes
) {
1676 cout
<< "ERROR: smpte2 not equal smpte1" << endl
;
1677 cout
<< "smpte1: " << (smpte1
.negative
? "-" : "") << smpte1
.hours
<< ":" << smpte1
.minutes
<< ":" << smpte1
.seconds
<< ":" << smpte1
.frames
<< "::" << smpte1
.subframes
<< " -> ";
1678 cout
<< "sample: " << sample1
<< endl
;
1679 cout
<< "sample: " << sample1
<< " -> ";
1680 cout
<< "smpte2: " << (smpte2
.negative
? "-" : "") << smpte2
.hours
<< ":" << smpte2
.minutes
<< ":" << smpte2
.seconds
<< ":" << smpte2
.frames
<< "::" << smpte2
.subframes
<< endl
;
1683 oldsample
= sample1
;
1684 session
->smpte_increment( smpte1
);
1687 cout
<< "sample_increment: " << sample_increment
<< endl
;
1688 cout
<< "sample: " << sample1
<< " -> ";
1689 cout
<< "smpte: " << (smpte2
.negative
? "-" : "") << smpte2
.hours
<< ":" << smpte2
.minutes
<< ":" << smpte2
.seconds
<< ":" << smpte2
.frames
<< "::" << smpte2
.subframes
<< endl
;
1691 for (int i
= 0; i
< 108003; i
++) {
1692 session
->smpte_to_sample( smpte1
, sample1
, true /* use_offset */, true /* use_subframes */ );
1693 session
->sample_to_smpte( sample1
, smpte2
, true /* use_offset */, true /* use_subframes */ );
1695 if ((i
> 0) && ( ((oldsample
- sample1
) != sample_increment
) && ((oldsample
- sample1
) != (sample_increment
+ 1)) && ((oldsample
- sample1
) != (sample_increment
- 1)))) {
1696 cout
<< "ERROR: sample increment not right: " << (oldsample
- sample1
) << " != " << sample_increment
<< endl
;
1697 cout
<< "smpte1: " << (smpte1
.negative
? "-" : "") << smpte1
.hours
<< ":" << smpte1
.minutes
<< ":" << smpte1
.seconds
<< ":" << smpte1
.frames
<< "::" << smpte1
.subframes
<< " -> ";
1698 cout
<< "sample: " << sample1
<< endl
;
1699 cout
<< "sample: " << sample1
<< " -> ";
1700 cout
<< "smpte2: " << (smpte2
.negative
? "-" : "") << smpte2
.hours
<< ":" << smpte2
.minutes
<< ":" << smpte2
.seconds
<< ":" << smpte2
.frames
<< "::" << smpte2
.subframes
<< endl
;
1704 if (smpte2
.hours
!= smpte1
.hours
|| smpte2
.minutes
!= smpte1
.minutes
|| smpte2
.seconds
!= smpte2
.seconds
|| smpte2
.frames
!= smpte1
.frames
|| smpte2
.subframes
!= smpte1
.subframes
) {
1705 cout
<< "ERROR: smpte2 not equal smpte1" << endl
;
1706 cout
<< "smpte1: " << (smpte1
.negative
? "-" : "") << smpte1
.hours
<< ":" << smpte1
.minutes
<< ":" << smpte1
.seconds
<< ":" << smpte1
.frames
<< "::" << smpte1
.subframes
<< " -> ";
1707 cout
<< "sample: " << sample1
<< endl
;
1708 cout
<< "sample: " << sample1
<< " -> ";
1709 cout
<< "smpte2: " << (smpte2
.negative
? "-" : "") << smpte2
.hours
<< ":" << smpte2
.minutes
<< ":" << smpte2
.seconds
<< ":" << smpte2
.frames
<< "::" << smpte2
.subframes
<< endl
;
1712 oldsample
= sample1
;
1713 session
->smpte_decrement( smpte1
);
1716 cout
<< "sample_decrement: " << sample_increment
<< endl
;
1717 cout
<< "sample: " << sample1
<< " -> ";
1718 cout
<< "smpte: " << (smpte2
.negative
? "-" : "") << smpte2
.hours
<< ":" << smpte2
.minutes
<< ":" << smpte2
.seconds
<< ":" << smpte2
.frames
<< "::" << smpte2
.subframes
<< endl
;
1723 #ifdef SMPTE_SAMPLE_TEST_5
1724 // Test 5: use_offset = true, use_subframes = false, increment seconds
1725 cout
<< "use_offset = true, use_subframes = false, increment seconds" << endl
;
1731 smpte1
.subframes
= 0;
1732 sample1
= oldsample
= 0;
1733 sample_increment
= session
->frame_rate();
1735 session
->sample_to_smpte( sample1
, smpte1
, true /* use_offset */, false /* use_subframes */ );
1736 cout
<< "Starting at sample: " << sample1
<< " -> ";
1737 cout
<< "smpte: " << (smpte1
.negative
? "-" : "") << smpte1
.hours
<< ":" << smpte1
.minutes
<< ":" << smpte1
.seconds
<< ":" << smpte1
.frames
<< "::" << smpte1
.subframes
<< endl
;
1739 for (int i
= 0; i
< 3600; i
++) {
1740 session
->smpte_to_sample( smpte1
, sample1
, true /* use_offset */, false /* use_subframes */ );
1741 session
->sample_to_smpte( sample1
, smpte2
, true /* use_offset */, false /* use_subframes */ );
1743 // cout << "smpte: " << (smpte1.negative ? "-" : "") << smpte1.hours << ":" << smpte1.minutes << ":" << smpte1.seconds << ":" << smpte1.frames << "::" << smpte1.subframes << " -> ";
1744 // cout << "sample: " << sample1 << endl;
1745 // cout << "sample: " << sample1 << " -> ";
1746 // cout << "smpte: " << (smpte2.negative ? "-" : "") << smpte2.hours << ":" << smpte2.minutes << ":" << smpte2.seconds << ":" << smpte2.frames << "::" << smpte2.subframes << endl;
1748 // if ((i > 0) && ( ((sample1 - oldsample) != sample_increment) && ((sample1 - oldsample) != (sample_increment + 1)) && ((sample1 - oldsample) != (sample_increment - 1))))
1750 // cout << "ERROR: sample increment not right: " << (sample1 - oldsample) << " != " << sample_increment << endl;
1754 if (smpte2
.hours
!= smpte1
.hours
|| smpte2
.minutes
!= smpte1
.minutes
|| smpte2
.seconds
!= smpte2
.seconds
|| smpte2
.frames
!= smpte1
.frames
) {
1755 cout
<< "ERROR: smpte2 not equal smpte1" << endl
;
1756 cout
<< "smpte: " << (smpte1
.negative
? "-" : "") << smpte1
.hours
<< ":" << smpte1
.minutes
<< ":" << smpte1
.seconds
<< ":" << smpte1
.frames
<< "::" << smpte1
.subframes
<< " -> ";
1757 cout
<< "sample: " << sample1
<< endl
;
1758 cout
<< "sample: " << sample1
<< " -> ";
1759 cout
<< "smpte: " << (smpte2
.negative
? "-" : "") << smpte2
.hours
<< ":" << smpte2
.minutes
<< ":" << smpte2
.seconds
<< ":" << smpte2
.frames
<< "::" << smpte2
.subframes
<< endl
;
1762 oldsample
= sample1
;
1763 session
->smpte_increment_seconds( smpte1
);
1766 cout
<< "sample_increment: " << sample_increment
<< endl
;
1767 cout
<< "sample: " << sample1
<< " -> ";
1768 cout
<< "smpte: " << (smpte2
.negative
? "-" : "") << smpte2
.hours
<< ":" << smpte2
.minutes
<< ":" << smpte2
.seconds
<< ":" << smpte2
.frames
<< "::" << smpte2
.subframes
<< endl
;
1772 #ifdef SMPTE_SAMPLE_TEST_6
1773 // Test 6: use_offset = true, use_subframes = false, increment minutes
1774 cout
<< "use_offset = true, use_subframes = false, increment minutes" << endl
;
1780 smpte1
.subframes
= 0;
1781 sample1
= oldsample
= 0;
1782 sample_increment
= session
->frame_rate() * 60;
1784 session
->sample_to_smpte( sample1
, smpte1
, true /* use_offset */, false /* use_subframes */ );
1785 cout
<< "Starting at sample: " << sample1
<< " -> ";
1786 cout
<< "smpte: " << (smpte1
.negative
? "-" : "") << smpte1
.hours
<< ":" << smpte1
.minutes
<< ":" << smpte1
.seconds
<< ":" << smpte1
.frames
<< "::" << smpte1
.subframes
<< endl
;
1788 for (int i
= 0; i
< 60; i
++) {
1789 session
->smpte_to_sample( smpte1
, sample1
, true /* use_offset */, false /* use_subframes */ );
1790 session
->sample_to_smpte( sample1
, smpte2
, true /* use_offset */, false /* use_subframes */ );
1792 // cout << "smpte: " << (smpte1.negative ? "-" : "") << smpte1.hours << ":" << smpte1.minutes << ":" << smpte1.seconds << ":" << smpte1.frames << "::" << smpte1.subframes << " -> ";
1793 // cout << "sample: " << sample1 << endl;
1794 // cout << "sample: " << sample1 << " -> ";
1795 // cout << "smpte: " << (smpte2.negative ? "-" : "") << smpte2.hours << ":" << smpte2.minutes << ":" << smpte2.seconds << ":" << smpte2.frames << "::" << smpte2.subframes << endl;
1797 // if ((i > 0) && ( ((sample1 - oldsample) != sample_increment) && ((sample1 - oldsample) != (sample_increment + 1)) && ((sample1 - oldsample) != (sample_increment - 1))))
1799 // cout << "ERROR: sample increment not right: " << (sample1 - oldsample) << " != " << sample_increment << endl;
1803 if (smpte2
.hours
!= smpte1
.hours
|| smpte2
.minutes
!= smpte1
.minutes
|| smpte2
.seconds
!= smpte2
.seconds
|| smpte2
.frames
!= smpte1
.frames
) {
1804 cout
<< "ERROR: smpte2 not equal smpte1" << endl
;
1805 cout
<< "smpte: " << (smpte1
.negative
? "-" : "") << smpte1
.hours
<< ":" << smpte1
.minutes
<< ":" << smpte1
.seconds
<< ":" << smpte1
.frames
<< "::" << smpte1
.subframes
<< " -> ";
1806 cout
<< "sample: " << sample1
<< endl
;
1807 cout
<< "sample: " << sample1
<< " -> ";
1808 cout
<< "smpte: " << (smpte2
.negative
? "-" : "") << smpte2
.hours
<< ":" << smpte2
.minutes
<< ":" << smpte2
.seconds
<< ":" << smpte2
.frames
<< "::" << smpte2
.subframes
<< endl
;
1811 oldsample
= sample1
;
1812 session
->smpte_increment_minutes( smpte1
);
1815 cout
<< "sample_increment: " << sample_increment
<< endl
;
1816 cout
<< "sample: " << sample1
<< " -> ";
1817 cout
<< "smpte: " << (smpte2
.negative
? "-" : "") << smpte2
.hours
<< ":" << smpte2
.minutes
<< ":" << smpte2
.seconds
<< ":" << smpte2
.frames
<< "::" << smpte2
.subframes
<< endl
;
1820 #ifdef SMPTE_SAMPLE_TEST_7
1821 // Test 7: use_offset = true, use_subframes = false, increment hours
1822 cout
<< "use_offset = true, use_subframes = false, increment hours" << endl
;
1828 smpte1
.subframes
= 0;
1829 sample1
= oldsample
= 0;
1830 sample_increment
= session
->frame_rate() * 60 * 60;
1832 session
->sample_to_smpte( sample1
, smpte1
, true /* use_offset */, false /* use_subframes */ );
1833 cout
<< "Starting at sample: " << sample1
<< " -> ";
1834 cout
<< "smpte: " << (smpte1
.negative
? "-" : "") << smpte1
.hours
<< ":" << smpte1
.minutes
<< ":" << smpte1
.seconds
<< ":" << smpte1
.frames
<< "::" << smpte1
.subframes
<< endl
;
1836 for (int i
= 0; i
< 10; i
++) {
1837 session
->smpte_to_sample( smpte1
, sample1
, true /* use_offset */, false /* use_subframes */ );
1838 session
->sample_to_smpte( sample1
, smpte2
, true /* use_offset */, false /* use_subframes */ );
1840 // cout << "smpte: " << (smpte1.negative ? "-" : "") << smpte1.hours << ":" << smpte1.minutes << ":" << smpte1.seconds << ":" << smpte1.frames << "::" << smpte1.subframes << " -> ";
1841 // cout << "sample: " << sample1 << endl;
1842 // cout << "sample: " << sample1 << " -> ";
1843 // cout << "smpte: " << (smpte2.negative ? "-" : "") << smpte2.hours << ":" << smpte2.minutes << ":" << smpte2.seconds << ":" << smpte2.frames << "::" << smpte2.subframes << endl;
1845 // if ((i > 0) && ( ((sample1 - oldsample) != sample_increment) && ((sample1 - oldsample) != (sample_increment + 1)) && ((sample1 - oldsample) != (sample_increment - 1))))
1847 // cout << "ERROR: sample increment not right: " << (sample1 - oldsample) << " != " << sample_increment << endl;
1851 if (smpte2
.hours
!= smpte1
.hours
|| smpte2
.minutes
!= smpte1
.minutes
|| smpte2
.seconds
!= smpte2
.seconds
|| smpte2
.frames
!= smpte1
.frames
) {
1852 cout
<< "ERROR: smpte2 not equal smpte1" << endl
;
1853 cout
<< "smpte: " << (smpte1
.negative
? "-" : "") << smpte1
.hours
<< ":" << smpte1
.minutes
<< ":" << smpte1
.seconds
<< ":" << smpte1
.frames
<< "::" << smpte1
.subframes
<< " -> ";
1854 cout
<< "sample: " << sample1
<< endl
;
1855 cout
<< "sample: " << sample1
<< " -> ";
1856 cout
<< "smpte: " << (smpte2
.negative
? "-" : "") << smpte2
.hours
<< ":" << smpte2
.minutes
<< ":" << smpte2
.seconds
<< ":" << smpte2
.frames
<< "::" << smpte2
.subframes
<< endl
;
1859 oldsample
= sample1
;
1860 session
->smpte_increment_hours( smpte1
);
1863 cout
<< "sample_increment: " << sample_increment
<< endl
;
1864 cout
<< "sample: " << sample1
<< " -> ";
1865 cout
<< "smpte: " << (smpte2
.negative
? "-" : "") << smpte2
.hours
<< ":" << smpte2
.minutes
<< ":" << smpte2
.seconds
<< ":" << smpte2
.frames
<< "::" << smpte2
.subframes
<< endl
;
1874 AudioClock::minsec_frame_from_display () const
1880 int hrs
= atoi (ms_hours_label
.get_text());
1881 int mins
= atoi (ms_minutes_label
.get_text());
1882 float secs
= atof (ms_seconds_label
.get_text());
1884 nframes_t sr
= session
->frame_rate();
1886 return (nframes_t
) floor ((hrs
* 60.0f
* 60.0f
* sr
) + (mins
* 60.0f
* sr
) + (secs
* sr
));
1890 AudioClock::bbt_frame_from_display (nframes_t pos
) const
1893 error
<< "AudioClock::current_time() called with BBT mode but without session!" << endmsg
;
1898 any
.type
= AnyTime::BBT
;
1900 any
.bbt
.bars
= atoi (bars_label
.get_text());
1901 any
.bbt
.beats
= atoi (beats_label
.get_text());
1902 any
.bbt
.ticks
= atoi (ticks_label
.get_text());
1909 nframes_t ret
= session
->convert_to_frames_at (pos
, any
);
1916 AudioClock::bbt_frame_duration_from_display (nframes_t pos
) const
1919 error
<< "AudioClock::current_time() called with BBT mode but without session!" << endmsg
;
1926 bbt
.bars
= atoi (bars_label
.get_text());
1927 bbt
.beats
= atoi (beats_label
.get_text());
1928 bbt
.ticks
= atoi (ticks_label
.get_text());
1930 return session
->tempo_map().bbt_duration_at(pos
,bbt
,1);
1934 AudioClock::audio_frame_from_display () const
1936 return (nframes_t
) atoi (audio_frames_label
.get_text());
1940 AudioClock::build_ops_menu ()
1942 using namespace Menu_Helpers
;
1943 ops_menu
= new Menu
;
1944 MenuList
& ops_items
= ops_menu
->items();
1945 ops_menu
->set_name ("ArdourContextMenu");
1947 if (!Profile
->get_sae()) {
1948 ops_items
.push_back (MenuElem (_("Timecode"), bind (mem_fun(*this, &AudioClock::set_mode
), SMPTE
)));
1950 ops_items
.push_back (MenuElem (_("Bars:Beats"), bind (mem_fun(*this, &AudioClock::set_mode
), BBT
)));
1951 ops_items
.push_back (MenuElem (_("Minutes:Seconds"), bind (mem_fun(*this, &AudioClock::set_mode
), MinSec
)));
1952 ops_items
.push_back (MenuElem (_("Samples"), bind (mem_fun(*this, &AudioClock::set_mode
), Frames
)));
1953 ops_items
.push_back (MenuElem (_("Off"), bind (mem_fun(*this, &AudioClock::set_mode
), Off
)));
1957 AudioClock::set_mode (Mode m
)
1959 /* slightly tricky: this is called from within the ARDOUR_UI
1960 constructor by some of its clock members. at that time
1961 the instance pointer is unset, so we have to be careful.
1962 the main idea is to drop keyboard focus in case we had
1963 started editing the clock and then we switch clock mode.
1966 clock_base
.grab_focus ();
1972 clock_base
.remove ();
1978 clock_base
.add (smpte_packer_hbox
);
1982 clock_base
.add (bbt_packer_hbox
);
1986 clock_base
.add (minsec_packer_hbox
);
1990 clock_base
.add (frames_packer_hbox
);
1994 clock_base
.add (off_hbox
);
1998 set_size_requests ();
2000 set (last_when
, true);
2001 clock_base
.show_all ();
2002 key_entry_state
= 0;
2004 if (!is_transient
) {
2005 ModeChanged (); /* EMIT SIGNAL */
2010 AudioClock::set_size_requests ()
2012 /* note that in some fonts, "88" is narrower than "00", hence the 2 pixel padding */
2016 Gtkmm2ext::set_size_request_to_display_given_text (hours_label
, "-00", 5, 5);
2017 Gtkmm2ext::set_size_request_to_display_given_text (minutes_label
, "00", 5, 5);
2018 Gtkmm2ext::set_size_request_to_display_given_text (seconds_label
, "00", 5, 5);
2019 Gtkmm2ext::set_size_request_to_display_given_text (frames_label
, "00", 5, 5);
2023 Gtkmm2ext::set_size_request_to_display_given_text (bars_label
, "-000", 5, 5);
2024 Gtkmm2ext::set_size_request_to_display_given_text (beats_label
, "00", 5, 5);
2025 Gtkmm2ext::set_size_request_to_display_given_text (ticks_label
, "0000", 5, 5);
2029 Gtkmm2ext::set_size_request_to_display_given_text (ms_hours_label
, "00", 5, 5);
2030 Gtkmm2ext::set_size_request_to_display_given_text (ms_minutes_label
, "00", 5, 5);
2031 Gtkmm2ext::set_size_request_to_display_given_text (ms_seconds_label
, "00.000", 5, 5);
2035 Gtkmm2ext::set_size_request_to_display_given_text (audio_frames_label
, "0000000000", 5, 5);
2039 Gtkmm2ext::set_size_request_to_display_given_text (off_hbox
, "00000", 5, 5);
2046 AudioClock::set_bbt_reference (nframes64_t pos
)
2048 bbt_reference_time
= pos
;