13
0

Tempo curve cleanup, now also works on optimized builds.

This commit is contained in:
nick_m 2016-10-17 01:28:33 +11:00
parent 29f6044180
commit 92920307ae
2 changed files with 20 additions and 15 deletions

View File

@ -51,15 +51,8 @@ TempoCurve::TempoCurve (PublicEditor& ed, ArdourCanvas::Container& parent, guint
#ifdef CANVAS_DEBUG
_curve->name = string_compose ("TempoCurve::curve for %1", _tempo.beats_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,17 +108,23 @@ 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.beats_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.beats_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);

View File

@ -31,7 +31,7 @@ FramedCurve::FramedCurve (Canvas* c)
: PolyItem (c)
, n_samples (0)
, points_per_segment (16)
, curve_fill (None)
, curve_fill (Inside)
{
}
@ -39,7 +39,7 @@ FramedCurve::FramedCurve (Item* parent)
: PolyItem (parent)
, n_samples (0)
, points_per_segment (16)
, curve_fill (None)
, curve_fill (Inside)
{
}
@ -85,8 +85,15 @@ FramedCurve::interpolate ()
}
samples.clear ();
InterpolatedCurve::interpolate (curve_points, points_per_segment, CatmullRomCentripetal, false, samples);
n_samples = samples.size();
if (_points.size() == 3) {
samples.push_back (curve_points.front());
samples.push_back (curve_points.back());
n_samples = 2;
} else {
InterpolatedCurve::interpolate (curve_points, points_per_segment, CatmullRomCentripetal, false, samples);
n_samples = samples.size();
}
}
void