From f1004a445ea3d06eecdf8c29d0d8af711abf25fa Mon Sep 17 00:00:00 2001 From: Asahi Lina Date: Sat, 9 Sep 2023 19:32:59 +0900 Subject: [PATCH] Fix quantization swing - Fix selection of what beats to swing (was always done) - Fix swing strength (lack of precision rounded to 50% or 100%) - Fix model offset not being applied properly Signed-off-by: Asahi Lina --- libs/ardour/quantize.cc | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/libs/ardour/quantize.cc b/libs/ardour/quantize.cc index 500313d182..56fa063e8b 100644 --- a/libs/ardour/quantize.cc +++ b/libs/ardour/quantize.cc @@ -81,8 +81,8 @@ swing_position (Temporal::Beats pos, Temporal::Beats grid, double swing_strength using namespace Temporal; - const bool swing_quantize_grid_position = pos > Beats() && ((pos/grid) % Beats (2, 0)) != Beats(); - const bool swing_previous_grid_position = pos > grid && (((pos-grid)/grid) % Beats (2, 0)) != Beats(); + const bool swing_quantize_grid_position = pos > Beats() && ((pos/grid) % Beats (0, 2)) != Beats(); + const bool swing_previous_grid_position = pos > grid && (((pos-grid)/grid) % Beats (0, 2)) != Beats(); /* one of these will not be subject to swing */ @@ -95,7 +95,7 @@ swing_position (Temporal::Beats pos, Temporal::Beats grid, double swing_strength swung_previous_grid_position = Beats(); } - const ratio_t r (2 * swing_strength, 3); + const ratio_t r (200 * swing_strength, 300); if (swing_previous_grid_position) { swung_previous_grid_position = swung_previous_grid_position + (grid * r); @@ -105,16 +105,16 @@ swing_position (Temporal::Beats pos, Temporal::Beats grid, double swing_strength swung_pos = swung_pos + (grid * r); } - /* now correct for start-of-model offset */ - - pos += offset; - if ((pos - swung_pos).abs() > (pos - swung_previous_grid_position).abs()) { pos = swung_previous_grid_position; } else { pos = swung_pos; } + /* now correct for start-of-model offset */ + + pos += offset; + return pos; }