Remove LocaleGuard from ARDOUR::Pannable class
[ardour.git] / libs / ardour / tempo.cc
index c04f6803fd345fa45f8ddd844647b23b2d77831f..32cb6c67ee1a40d77bb566518f98c1de10615bfb 100644 (file)
@@ -159,8 +159,6 @@ TempoSection::TempoSection (const XMLNode& node, framecnt_t sample_rate)
        , _locked_to_meter (false)
        , _clamped (false)
 {
-       LocaleGuard lg;
-
        _legacy_bbt = BBT_Time (0, 0, 0);
 
        BBT_Time bbt;
@@ -206,7 +204,7 @@ TempoSection::TempoSection (const XMLNode& node, framecnt_t sample_rate)
        }
 
        TempoSection::Type old_type;
-       if (!node.get_property ("tempo-type", old_type)) {
+       if (node.get_property ("tempo-type", old_type)) {
                /* sessions with a tempo-type node contain no end-beats-per-minute.
                   if the legacy node indicates a constant tempo, simply fill this in with the
                   start tempo. otherwise we need the next neighbour to know what it will be.
@@ -242,7 +240,6 @@ XMLNode&
 TempoSection::get_state() const
 {
        XMLNode *root = new XMLNode (xml_state_node_name);
-       LocaleGuard lg;
 
        MetricSection::add_state_to_node (*root);
 
@@ -553,7 +550,6 @@ const string MeterSection::xml_state_node_name = "Meter";
 MeterSection::MeterSection (const XMLNode& node, const framecnt_t sample_rate)
        : MetricSection (0.0, 0, MusicTime, false, sample_rate), Meter (TempoMap::default_meter())
 {
-       LocaleGuard lg;
        pair<double, BBT_Time> start;
        start.first = 0.0;
 
@@ -612,7 +608,6 @@ XMLNode&
 MeterSection::get_state() const
 {
        XMLNode *root = new XMLNode (xml_state_node_name);
-       LocaleGuard lg;
 
        MetricSection::add_state_to_node (*root);
 
@@ -1882,7 +1877,7 @@ TempoMap::quarter_note_at_tempo (const Tempo& tempo) const
 {
        Glib::Threads::RWLock::ReaderLock lm (lock);
 
-       return pulse_at_tempo_locked (_metrics, tempo) * 4.0;;
+       return pulse_at_tempo_locked (_metrics, tempo) * 4.0;
 }
 
 /** Returns the whole-note pulse corresponding to the supplied  BBT (meter-based) beat.
@@ -3780,6 +3775,16 @@ TempoMap::gui_twist_tempi (TempoSection* ts, const Tempo& bpm, const framepos_t
 
        return can_solve;
 }
+
+/** Returns the frame position of the musical position zero */
+framepos_t
+TempoMap::music_origin ()
+{
+       Glib::Threads::RWLock::ReaderLock lm (lock);
+
+       return first_tempo().frame();
+}
+
 /** Returns the exact bbt-based beat corresponding to the bar, beat or quarter note subdivision nearest to
  * the supplied frame, possibly returning a negative value.
  *
@@ -4162,11 +4167,11 @@ TempoMap::get_grid (vector<TempoMap::BBTPoint>& points,
        if (bar_mod == 0) {
                while (pos >= 0 && pos < upper) {
                        pos = frame_at_minute (minute_at_beat_locked (_metrics, cnt));
-                       const TempoSection tempo = tempo_section_at_minute_locked (_metrics, minute_at_frame (pos));
                        const MeterSection meter = meter_section_at_minute_locked (_metrics, minute_at_frame (pos));
                        const BBT_Time bbt = bbt_at_beat_locked (_metrics, cnt);
+                       const double qn = pulse_at_beat_locked (_metrics, cnt) * 4.0;
 
-                       points.push_back (BBTPoint (meter, tempo_at_minute_locked (_metrics, minute_at_frame (pos)), pos, bbt.bars, bbt.beats, tempo.c()));
+                       points.push_back (BBTPoint (meter, tempo_at_minute_locked (_metrics, minute_at_frame (pos)), pos, bbt.bars, bbt.beats, qn));
                        ++cnt;
                }
        } else {
@@ -4181,9 +4186,10 @@ TempoMap::get_grid (vector<TempoMap::BBTPoint>& points,
 
                while (pos >= 0 && pos < upper) {
                        pos = frame_at_minute (minute_at_bbt_locked (_metrics, bbt));
-                       const TempoSection tempo = tempo_section_at_minute_locked (_metrics, minute_at_frame (pos));
                        const MeterSection meter = meter_section_at_minute_locked (_metrics, minute_at_frame (pos));
-                       points.push_back (BBTPoint (meter, tempo_at_minute_locked (_metrics, minute_at_frame (pos)), pos, bbt.bars, bbt.beats, tempo.c()));
+                       const double qn = pulse_at_bbt_locked (_metrics, bbt) * 4.0;
+
+                       points.push_back (BBTPoint (meter, tempo_at_minute_locked (_metrics, minute_at_frame (pos)), pos, bbt.bars, bbt.beats, qn));
                        bbt.bars += bar_mod;
                }
        }