diff options
author | Paul Davis <paul@linuxaudiosystems.com> | 2009-03-23 20:09:08 +0000 |
---|---|---|
committer | Paul Davis <paul@linuxaudiosystems.com> | 2009-03-23 20:09:08 +0000 |
commit | e79f953efdaecd9867045afc77d039a6cbc533bf (patch) | |
tree | 7091b66093e7d550b87eb12a74c24b6241133f65 | |
parent | 3c62351159b9943221086c283a3718799ef3a933 (diff) |
quantize speed changes in semitone mode to whole semitones, range is 2 octaves
git-svn-id: svn://localhost/ardour2/branches/2.0-ongoing@4882 d708f5d6-7413-0410-9779-e7cbd77b26cf
-rw-r--r-- | gtk2_ardour/ardour_ui2.cc | 34 |
1 files changed, 27 insertions, 7 deletions
diff --git a/gtk2_ardour/ardour_ui2.cc b/gtk2_ardour/ardour_ui2.cc index 1dabb25c4b..6ff37bce2e 100644 --- a/gtk2_ardour/ardour_ui2.cc +++ b/gtk2_ardour/ardour_ui2.cc @@ -370,6 +370,7 @@ ARDOUR_UI::setup_transport () speed_display_box.add (speed_display_label); speed_display_box.set_name (X_("ShuttleDisplay")); + set_size_request_to_display_given_text (speed_display_label, X_("> 24.0"), 2, 2); shuttle_units_button.set_name (X_("ShuttleButton")); shuttle_units_button.signal_clicked().connect (mem_fun(*this, &ARDOUR_UI::shuttle_unit_clicked)); @@ -772,15 +773,33 @@ ARDOUR_UI::use_shuttle_fract (bool force) last_shuttle_request = now; - bool neg = (shuttle_fract < 0.0); + if (Config->get_shuttle_units() == Semitones) { - double fract = 1 - sqrt (1 - (shuttle_fract * shuttle_fract)); // Formula A1 + const double step = 1.0 / 24.0; // range is 24 semitones up & down + double semitones; + double speed; - if (neg) { - fract = -fract; + semitones = round (shuttle_fract / step); + speed = pow (2.0, (semitones / 12.0)); + + session->request_transport_speed (speed); + + } else { + + bool neg; + double fract; + + neg = (shuttle_fract < 0.0); + + fract = 1 - sqrt (1 - (shuttle_fract * shuttle_fract)); // Formula A1 + + if (neg) { + fract = -fract; + } + + session->request_transport_speed (shuttle_max_speed * fract); } - session->request_transport_speed (shuttle_max_speed * fract); // Formula A2 shuttle_box.queue_draw (); } @@ -851,10 +870,11 @@ ARDOUR_UI::update_speed_display () if (Config->get_shuttle_units() == Percentage) { snprintf (buf, sizeof (buf), "%.2f", x); } else { + if (x < 0) { - snprintf (buf, sizeof (buf), "< %.1f", 12.0 * fast_log2 (-x)); + snprintf (buf, sizeof (buf), "< %d", (int) round (12.0 * fast_log2 (-x))); } else { - snprintf (buf, sizeof (buf), "> %.1f", 12.0 * fast_log2 (x)); + snprintf (buf, sizeof (buf), "> %d", (int) round (12.0 * fast_log2 (x))); } } speed_display_label.set_text (buf); |