a more reliable/robust/less complex version of previous commit
[ardour.git] / gtk2_ardour / audio_clock.cc
index 4afe4a418d7366d42bf693d7eaa58aea3782ccec..16b4151a81840a380c46cf45404ecafcfef46db6 100644 (file)
@@ -42,7 +42,7 @@
 #include "keyboard.h"
 #include "gui_thread.h"
 #include "ui_config.h"
-#include "i18n.h"
+#include "pbd/i18n.h"
 
 using namespace ARDOUR;
 using namespace ARDOUR_UI_UTILS;
@@ -923,6 +923,12 @@ AudioClock::session_property_changed (const PropertyChange&)
        set (last_when, true);
 }
 
+void
+AudioClock::metric_position_changed ()
+{
+       set (last_when, true);
+}
+
 void
 AudioClock::session_configuration_changed (std::string p)
 {
@@ -1252,12 +1258,12 @@ AudioClock::set_bbt (framepos_t when, bool /*force*/)
                        BBT.beats = 0;
                        BBT.ticks = 0;
                } else {
-                       _session->tempo_map().bbt_time (when, BBT);
+                       BBT = _session->tempo_map().bbt_at_frame (when);
                        BBT.bars--;
                        BBT.beats--;
                }
        } else {
-               _session->tempo_map().bbt_time (when, BBT);
+               BBT = _session->tempo_map().bbt_at_frame (when);
        }
 
        if (negative) {
@@ -1281,7 +1287,7 @@ AudioClock::set_bbt (framepos_t when, bool /*force*/)
 
                TempoMetric m (_session->tempo_map().metric_at (pos));
 
-               sprintf (buf, "%-5.1f", _session->tempo_map().tempo_at (pos));
+               sprintf (buf, "%-5.3f", _session->tempo_map().tempo_at_frame (pos).beats_per_minute());
                _left_layout->set_markup (string_compose ("<span size=\"%1\">" TXTSPAN "%3</span> <span foreground=\"green\">%2</span></span>",
                                                          INFO_FONT_SIZE, buf, _("Tempo")));
 
@@ -1300,6 +1306,7 @@ AudioClock::set_session (Session *s)
 
                _session->config.ParameterChanged.connect (_session_connections, invalidator (*this), boost::bind (&AudioClock::session_configuration_changed, this, _1), gui_context());
                _session->tempo_map().PropertyChanged.connect (_session_connections, invalidator (*this), boost::bind (&AudioClock::session_property_changed, this, _1), gui_context());
+               _session->tempo_map().MetricPositionChanged.connect (_session_connections, invalidator (*this), boost::bind (&AudioClock::metric_position_changed, this), gui_context());
 
                XMLProperty const * prop;
                XMLNode* node = _session->extra_xml (X_("ClockModes"));