From e1d82bce040e43615db37f2abc00686fef6c39bc Mon Sep 17 00:00:00 2001 From: Paul Davis Date: Wed, 7 Nov 2018 16:25:29 -0500 Subject: [PATCH] use rational number for step durations --- gtk2_ardour/beatbox_gui.cc | 9 +++++---- gtk2_ardour/beatbox_gui.h | 6 +++--- 2 files changed, 8 insertions(+), 7 deletions(-) diff --git a/gtk2_ardour/beatbox_gui.cc b/gtk2_ardour/beatbox_gui.cc index 94f7996cba..dab698dca5 100644 --- a/gtk2_ardour/beatbox_gui.cc +++ b/gtk2_ardour/beatbox_gui.cc @@ -512,7 +512,8 @@ StepView::render (ArdourCanvas::Rect const & area, Cairo::RefPtr context->rectangle (origin.x + 2, origin.y + (_step_dimen - height - 2), _step_dimen - 4, height); context->fill (); } else if (_seq.mode() == SequencerGrid::Duration) { - const double height = (_step_dimen - 4) * (_step.duration()); + const Step::DurationRatio d (_step.duration()); + const double height = ((_step_dimen - 4.0) * d.numerator()) / d.denominator(); const Duple origin = item_to_window (Duple (0, 0)); context->rectangle (origin.x + 2, origin.y + (_step_dimen - height - 2), _step_dimen - 4, height); context->fill (); @@ -594,8 +595,8 @@ StepView::scroll_event (GdkEventScroll* ev) cerr << "adjust velocity by " << amt << endl; adjust_step_velocity (amt); } else if (_seq.mode() == SequencerGrid::Duration) { - cerr << "adjust velocity by " << amt << endl; - adjust_step_duration (amt/32.0); /* adjust by 1/32 of the sequencer step size */ + cerr << "adjust duration by " << Step::DurationRatio (amt, 32) << endl; + adjust_step_duration (Step::DurationRatio (amt, 32)); /* adjust by 1/32 of the sequencer step size */ } else if (_seq.mode() == SequencerGrid::Octave) { adjust_step_octave (amt); } else if (_seq.mode() == SequencerGrid::Group) { @@ -623,7 +624,7 @@ StepView::adjust_step_octave (int amt) } void -StepView::adjust_step_duration (double amt) +StepView::adjust_step_duration (Step::DurationRatio const & amt) { _step.adjust_duration (amt); } diff --git a/gtk2_ardour/beatbox_gui.h b/gtk2_ardour/beatbox_gui.h index 225d65258b..d349b5ceb4 100644 --- a/gtk2_ardour/beatbox_gui.h +++ b/gtk2_ardour/beatbox_gui.h @@ -39,6 +39,8 @@ #include "canvas/canvas.h" #include "canvas/rectangle.h" +#include "ardour/step_sequencer.h" + #include "widgets/ardour_button.h" #include "widgets/ardour_dropdown.h" #include "ardour_dialog.h" @@ -59,8 +61,6 @@ class Widget; namespace ARDOUR { class BeatBox; -class Step; -class StepSequencer; } class SequencerGrid; @@ -88,7 +88,7 @@ class StepView : public ArdourCanvas::Rectangle, public sigc::trackable { void adjust_step_pitch (int amt); void adjust_step_velocity (int amt); - void adjust_step_duration (double); + void adjust_step_duration (ARDOUR::Step::DurationRatio const &); void adjust_step_octave (int amt); void step_changed (PBD::PropertyChange const &);