One fix.
[ardour.git] / gtk2_ardour / tempo_curve.cc
index 6a9a20727bf9fe3c9ce13bdf785185dd373f214b..c15d58fb0907717918448515c28dc76ce5a50a61 100644 (file)
@@ -26,7 +26,7 @@ void TempoCurve::setup_sizes(const double timebar_height)
 {
        curve_height = floor (timebar_height) - 2.5;
 }
-
+/* ignores Tempo note type - only note_types_per_minute is potentially curved */
 TempoCurve::TempoCurve (PublicEditor& ed, ArdourCanvas::Container& parent, guint32 rgba, ARDOUR::TempoSection& temp, framepos_t frame, bool handle_events)
 
        : editor (ed)
@@ -34,8 +34,8 @@ TempoCurve::TempoCurve (PublicEditor& ed, ArdourCanvas::Container& parent, guint
        , _curve (0)
        , _shown (false)
        , _color (rgba)
-       , _min_tempo (temp.beats_per_minute())
-       , _max_tempo (temp.beats_per_minute())
+       , _min_tempo (temp.note_types_per_minute())
+       , _max_tempo (temp.note_types_per_minute())
        , _tempo (temp)
 
 {
@@ -44,22 +44,15 @@ TempoCurve::TempoCurve (PublicEditor& ed, ArdourCanvas::Container& parent, guint
 
        group = new ArdourCanvas::Container (&parent, ArdourCanvas::Duple (unit_position, 1));
 #ifdef CANVAS_DEBUG
-       group->name = string_compose ("TempoCurve::group for %1", _tempo.beats_per_minute());
+       group->name = string_compose ("TempoCurve::group for %1", _tempo.note_types_per_minute());
 #endif
 
        _curve = new ArdourCanvas::FramedCurve (group);
 #ifdef CANVAS_DEBUG
-       _curve->name = string_compose ("TempoCurve::curve for %1", _tempo.beats_per_minute());
+       _curve->name = string_compose ("TempoCurve::curve for %1", _tempo.note_types_per_minute());
 #endif
-       _curve->set_fill_mode (ArdourCanvas::FramedCurve::Inside);
        _curve->set_points_per_segment (3);
-
        points = new ArdourCanvas::Points ();
-       points->push_back (ArdourCanvas::Duple (0.0, 0.0));
-       points->push_back (ArdourCanvas::Duple (1.0, 0.0));
-       points->push_back (ArdourCanvas::Duple (1.0, curve_height));
-       points->push_back (ArdourCanvas::Duple (0.0, curve_height));
-
        _curve->set (*points);
 
        set_color_rgba (rgba);
@@ -76,7 +69,6 @@ TempoCurve::TempoCurve (PublicEditor& ed, ArdourCanvas::Container& parent, guint
                //group->Event.connect (sigc::bind (sigc::mem_fun (editor, &PublicEditor::canvas_marker_event), group, this));
        }
 
-       set_position (_tempo.frame(), UINT32_MAX);
        _curve->Event.connect (sigc::bind (sigc::mem_fun (editor, &PublicEditor::canvas_tempo_curve_event), _curve, this));
 
 }
@@ -116,24 +108,30 @@ TempoCurve::set_position (framepos_t frame, framepos_t end_frame)
        _end_frame = end_frame;
 
        points->clear();
-
        points = new ArdourCanvas::Points ();
+
        points->push_back (ArdourCanvas::Duple (0.0, curve_height));
 
-       if (end_frame == UINT32_MAX) {
-               const double tempo_at = _tempo.tempo_at_frame (frame, editor.session()->frame_rate());
+       if (end_frame == (framepos_t) UINT32_MAX) {
+               const double tempo_at = _tempo.note_types_per_minute();
                const double y_pos =  (curve_height) - (((tempo_at - _min_tempo) / (_max_tempo - _min_tempo)) * curve_height);
 
                points->push_back (ArdourCanvas::Duple (0.0, y_pos));
                points->push_back (ArdourCanvas::Duple (ArdourCanvas::COORD_MAX - 5.0, y_pos));
 
+       } else if (_tempo.type() == ARDOUR::TempoSection::Constant) {
+               const double tempo_at = _tempo.note_types_per_minute();
+               const double y_pos =  (curve_height) - (((tempo_at - _min_tempo) / (_max_tempo - _min_tempo)) * curve_height);
+
+               points->push_back (ArdourCanvas::Duple (0.0, y_pos));
+               points->push_back (ArdourCanvas::Duple (editor.sample_to_pixel (end_frame - frame), y_pos));
        } else {
 
                const framepos_t frame_step = max ((end_frame - frame) / 5, (framepos_t) 1);
                framepos_t current_frame = frame;
 
                while (current_frame < (end_frame - frame_step)) {
-                       const double tempo_at = _tempo.tempo_at_frame (current_frame, editor.session()->frame_rate());
+                       const double tempo_at = _tempo.tempo_at_minute (_tempo.minute_at_frame (current_frame)).note_types_per_minute();
                        const double y_pos = max ((curve_height) - (((tempo_at - _min_tempo) / (_max_tempo - _min_tempo)) * curve_height), 0.0);
 
                        points->push_back (ArdourCanvas::Duple (editor.sample_to_pixel (current_frame - frame), min (y_pos, curve_height)));
@@ -141,7 +139,7 @@ TempoCurve::set_position (framepos_t frame, framepos_t end_frame)
                        current_frame += frame_step;
                }
 
-               const double tempo_at = _tempo.tempo_at_frame (end_frame, editor.session()->frame_rate());
+               const double tempo_at = _tempo.tempo_at_minute (_tempo.minute_at_frame (end_frame)).note_types_per_minute();
                const double y_pos = max ((curve_height) - (((tempo_at - _min_tempo) / (_max_tempo - _min_tempo)) * curve_height), 0.0);
 
                points->push_back (ArdourCanvas::Duple (editor.sample_to_pixel ((end_frame - 1) - frame), min (y_pos, curve_height)));