From 320a20cbab89dd5c5e98072460285ccff2beeae7 Mon Sep 17 00:00:00 2001 From: Paul Davis Date: Wed, 9 Mar 2022 20:16:21 -0700 Subject: [PATCH] tempo display: during ressaociate markers, update tempo curves as well --- gtk2_ardour/editor_tempodisplay.cc | 1 + gtk2_ardour/tempo_curve.cc | 30 +++++++++++++++++++----------- gtk2_ardour/tempo_curve.h | 5 +++-- 3 files changed, 23 insertions(+), 13 deletions(-) diff --git a/gtk2_ardour/editor_tempodisplay.cc b/gtk2_ardour/editor_tempodisplay.cc index 9474c32fca..9c0117b40f 100644 --- a/gtk2_ardour/editor_tempodisplay.cc +++ b/gtk2_ardour/editor_tempodisplay.cc @@ -127,6 +127,7 @@ Editor::reassociate_metric_marker (TempoMap::SharedPtr const & tmap, TempoMap::M } else if ((tp = dynamic_cast(*m)) != 0) { if (tm->tempo() == *tp) { tm->reset_tempo (*tp); + tm->curve().reset_point (*tp); break; } } diff --git a/gtk2_ardour/tempo_curve.cc b/gtk2_ardour/tempo_curve.cc index 713e326eab..7a1fec57a5 100644 --- a/gtk2_ardour/tempo_curve.cc +++ b/gtk2_ardour/tempo_curve.cc @@ -62,19 +62,19 @@ TempoCurve::TempoCurve (PublicEditor& ed, ArdourCanvas::Item& parent, guint32 rg , _color (rgba) , _min_tempo (temp.note_types_per_minute()) , _max_tempo (temp.note_types_per_minute()) - , _tempo (temp) + , _tempo (&temp) , _start_text (0) , _end_text (0) { /* XXX x arg for Duple should probably be marker width, passed in from owner */ group = new ArdourCanvas::Container (&parent, ArdourCanvas::Duple (marker_width, 1)); #ifdef CANVAS_DEBUG - group->name = string_compose ("TempoCurve::group for %1", _tempo.note_types_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.note_types_per_minute()); + _curve->name = string_compose ("TempoCurve::curve for %1", _tempo->note_types_per_minute()); #endif _curve->set_points_per_segment (3); _curve->set (points); @@ -86,9 +86,9 @@ TempoCurve::TempoCurve (PublicEditor& ed, ArdourCanvas::Item& parent, guint32 rg _start_text->set_color (RGBA_TO_UINT (255,255,255,255)); _end_text->set_color (RGBA_TO_UINT (255,255,255,255)); char buf[10]; - snprintf (buf, sizeof (buf), "%.3f/%d", _tempo.note_types_per_minute(), _tempo.note_type()); + snprintf (buf, sizeof (buf), "%.3f/%d", _tempo->note_types_per_minute(), _tempo->note_type()); _start_text->set (buf); - snprintf (buf, sizeof (buf), "%.3f", _tempo.end_note_types_per_minute()); + snprintf (buf, sizeof (buf), "%.3f", _tempo->end_note_types_per_minute()); _end_text->set (buf); set_color_rgba (rgba); @@ -131,9 +131,9 @@ TempoCurve::set_duration (samplecnt_t duration) ArdourCanvas::Coord duration_pixels = editor.sample_to_pixel (duration); - if (!_tempo.ramped()) { + if (!_tempo->ramped()) { - const double tempo_at = _tempo.note_types_per_minute(); + 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)); @@ -145,7 +145,7 @@ TempoCurve::set_duration (samplecnt_t duration) samplepos_t current_sample = 0; while (current_sample < duration) { - const double tempo_at = _tempo.note_types_per_minute_at_DOUBLE (timepos_t (current_sample)); + const double tempo_at = _tempo->note_types_per_minute_at_DOUBLE (timepos_t (current_sample)); const double y_pos = std::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_sample), std::min (y_pos, curve_height))); @@ -153,7 +153,7 @@ TempoCurve::set_duration (samplecnt_t duration) current_sample += sample_step; } - const double tempo_at = _tempo.note_types_per_minute(); + const double tempo_at = _tempo->note_types_per_minute(); const double y_pos = std::max ((curve_height) - (((tempo_at - _min_tempo) / (_max_tempo - _min_tempo)) * curve_height), 0.0); points.push_back (ArdourCanvas::Duple (duration_pixels, std::min (y_pos, curve_height))); @@ -163,10 +163,12 @@ TempoCurve::set_duration (samplecnt_t duration) char buf[10]; - snprintf (buf, sizeof (buf), "%.3f/%d", _tempo.note_types_per_minute(), _tempo.note_type()); + snprintf (buf, sizeof (buf), "%.3f/%d", _tempo->note_types_per_minute(), _tempo->note_type()); _start_text->set (buf); - snprintf (buf, sizeof (buf), "%.3f", _tempo.end_note_types_per_minute()); + std::cerr << "new start text " << buf << std::endl; + snprintf (buf, sizeof (buf), "%.3f", _tempo->end_note_types_per_minute()); _end_text->set (buf); + std::cerr << "new end text " << buf << std::endl; const double ui_scale = UIConfiguration::instance ().get_ui_scale (); @@ -210,3 +212,9 @@ TempoCurve::set_color_rgba (uint32_t c) _curve->set_outline_color (_color); } + +void +TempoCurve::reset_point (TempoPoint const & tp) +{ + _tempo = &tp; +} diff --git a/gtk2_ardour/tempo_curve.h b/gtk2_ardour/tempo_curve.h index 272769858e..1919e96c1c 100644 --- a/gtk2_ardour/tempo_curve.h +++ b/gtk2_ardour/tempo_curve.h @@ -55,7 +55,8 @@ public: void hide (); void show (); - Temporal::TempoPoint const & tempo () const { return _tempo; } + Temporal::TempoPoint const & tempo () const { return *_tempo; } + void reset_point (Temporal::TempoPoint const &); void set_max_tempo (const double& max) { _max_tempo = max; } void set_min_tempo (const double& min) { _min_tempo = min; } @@ -83,7 +84,7 @@ private: double _min_tempo; double _max_tempo; - Temporal::TempoPoint const & _tempo; + Temporal::TempoPoint const * _tempo; ArdourCanvas::Text* _start_text; ArdourCanvas::Text* _end_text; };